분주하는 부분에서 약간 헤맸습니다.
/*******************************************************************************
* Function Name :
* Parameters : None
* Return : None
* Description :
DEBUGPRINT("%d \r\n", SystemCoreClock);//400000000
*******************************************************************************/
void Config_TIM(void)
{
uint32_t Prescaler;
Prescaler = (uint32_t)(SystemCoreClock / (2*1000000)) - 1;
Init_Timer(eTimer2, 1000000, eInterruptEnable, Prescaler);
}
/*******************************************************************************
* Function Name :
* Parameters : None
* Return :
* Description :
*******************************************************************************/
int Init_Timer(const uint8_t a_chTimer, const uint32_t a_nUs, const InterruptEnableState a_chInt, const uint32_t a_nPrescaler)
{
/* Initial autoreload value */
if(a_nPrescaler > 65536){
return 1;
}
if(a_chTimer == 1){
}
else if(a_chTimer == 2){
/* Enable the timer peripheral clock */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
/* Set counter mode */
/* Reset value is LL_TIM_COUNTERMODE_UP */
LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP);
/* Set the pre-scaler value to have TIM2 counter clock equal to 10 kHz */
LL_TIM_SetPrescaler(TIM2, a_nPrescaler);
// LL_TIM_SetClockDivision(TIM2, 64);
/* Set the auto-reload value to have an initial update event frequency of 10 Hz */
LL_TIM_SetAutoReload(TIM2, a_nUs);
if(a_chInt == eInterruptEnable){
/* Enable the update interrupt */
LL_TIM_EnableIT_UPDATE(TIM2);
/* Configure the NVIC to handle TIM2 update interrupt */
NVIC_SetPriority(TIM2_IRQn, 0);
NVIC_EnableIRQ(TIM2_IRQn);
}
/* Enable counter */
LL_TIM_EnableCounter(TIM2);
/* Force update generation */
LL_TIM_GenerateEvent_UPDATE(TIM2);
}
return 0;
}
'초보의 아웅다웅 설계하기 > STM32' 카테고리의 다른 글
STM32H750 내부 Flash 사용하기 (0) | 2019.12.28 |
---|---|
STM32F723 UART LL_DRIVER 예제 (0) | 2019.11.17 |
STM32H743 UART LL_Driver 예제 (0) | 2019.11.09 |
Intel-Hex 프로토콜 구조 (0) | 2019.11.04 |
SPI Slave에서 입력 데이터 처리 (0) | 2019.09.30 |