标签:输出 tca otp 配置 read 步骤 模式 flag done
通过改变RCC_HSECR寄存器中的HSETUNE[5:0]位域的值来校准HSE的输出频率
1、将HSE时钟配置为MCO模式输出到PA8引脚
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
2、改变RCC_HSECR寄存器中的HSETUNE[5:0]位域的值(0-63)
LOOP((0<=p_otp->hse_tuning<=63):
__HAL_RCC_HSE_CONFIG(RCC_HSE_OFF);
while (LL_RCC_HSE_IsReady());
LL_RCC_HSE_SetCapacitorTuning(p_otp->hse_tuning);
__HAL_RCC_HSE_CONFIG(RCC_HSE_ON);
while (LL_RCC_HSE_IsReady());
通过不断改变p_otp->hse_tuning的值调整HSE的时钟频率直到PA8引脚上的时钟信号满足要求
3、保存HSETUNE[5:0]位域的值,将校准后的值保存在OTP区
#ifdef __GNUC__
typedef struct __attribute__((packed))
#else
typedef __packed struct
#endif
{
uint8_t additional_data[6]; /*!< 48 bits of data to fill OTP slot (e.g: BD or MAC address, key..) */
uint8_t hse_tuning; /*!< Load capacitance to be applied on HSE pad */
uint8_t index; /*!< Structure index */
} OTP_DATA_t;
OTP_DATA_t otp_data;
memcpy(otp_data.additional_data, (void*)ADDITIONAL_DATA_PTR, 6);
otp_data.hse_tuning = val & 0x3F;
otp_data.index = OTP_HSE_STR_IDX;
idx = GetOTPFreeIdx();
当校准之后后续程序启动就只有第4步骤,前123步骤是校准时候需要做的
标签:输出 tca otp 配置 read 步骤 模式 flag done
原文地址:https://www.cnblogs.com/yeshenmeng/p/10838441.html