ST电机MCLib 生成文件比较
参考文章:STM32 PMSM SDK 5.2 training
ST电机库v5.4.4源代码分析(4): 电角度和力矩方向分析(Hall传感器)
speed unit 和 dpp 解释
一、6step不同工作模式下文章的差异
有三种选择,hall传感器。encode传感器,状态观察传感器。
1。头文件比较
-
hall与encoder

hall传感器里多了hall_speed_pos_fdbk.h.
有差异的文件是
driver_parameters.h,
main.h,
mc_config.h,
mc_configuration_registers.h,
parameters_conversion.h -
hall与观察传感器

不同的文件与 1 相同。
2。源文件比较
-
hall与encoder比较

不同的文件如下:
hall多一个文件: hall_speed_pos_fdbk.c
不同的文件为:
main.c
mc_config.c
mc_task.c
register_interface.c
stm32g4xx_hal_msp.c
stm32g4xx_mc_it,c -
hall与observer比较

不同的文件与上述相同.
二、hall_speed_pos_fdbk.c解析
1。api
void HALL_Init(HALL_Handle_t *pHandle);
void HALL_Clear(HALL_Handle_t *pHandle);
void *HALL_TIMx_UP_IRQHandler(void *pHandleVoid);
void *HALL_TIMx_CC_IRQHandler(void *pHandleVoid);
int16_t HALL_CalcElAngle(HALL_Handle_t *pHandle);
bool HALL_CalcAvrgMecSpeedUnit(HALL_Handle_t *pHandle, int16_t *hMecSpeedUnit);
void HALL_Init(HALL_Handle_t *pHandle):
It initializes the hardware peripherals (TIMx, GPIO and NVIC)
required for the speed position sensor management using HALL
sensors.
2。硬件接口定义:
uint32_t TIMClockFreq;
TIM_TypeDef *TIMx;
uint32_t H1Pin; used,
GPIO_TypeDef *H2Port;
uint32_t ICx_Filter;
3。stm32xxx.h中定义的一些寄存器直接操作及原子操作:
/** @addtogroup Exported_macros
* @{
*/
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
#define READ_BIT(REG, BIT) ((REG) & (BIT))
#define CLEAR_REG(REG) ((REG) = (0x0))
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
#define READ_REG(REG) ((REG))
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
/* Use of CMSIS compiler intrinsics for register exclusive access */
/* Atomic 32-bit register access macro to set one or several bits */
#define ATOMIC_SET_BIT(REG, BIT) \
do {
\
uint32_t val; \
do {
\
val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
} while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
} while(0)
/* Atomic 32-bit register access macro to clear one or several bits */
#define ATOMIC_CLEAR_BIT(REG, BIT) \
do {
\
uint32_t val; \
do {
\
val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
} while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
} while(0)
/* Atomic 32-bit register access macro to clear and set one or several bits */
#define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
do {
\
uint32_t val; \
do {
\
val = (__LDREXW((__IO uint32_t *</

本文围绕ST电机MCLib生成文件展开,对比了6step不同工作模式下文章差异,包括头文件和源文件。详细解析了hall_speed_pos_fdbk.c文件,涉及api、硬件接口定义等内容。还介绍了API调用情况,如init mc_task.c mcboot()等,为STM32电机控制开发提供参考。
最低0.47元/天 解锁文章
9332

被折叠的 条评论
为什么被折叠?



