/************************* Configure TMR0_1_A***************************/
(void)TMR0_StructInit(&stcTmr0Init);
stcTmr0Init.u32ClockSrc = TMR0_CLK_SRC_XTAL32;
stcTmr0Init.u32ClockDiv = TMR0_CLK_DIV32;
stcTmr0Init.u32Func = TMR0_FUNC_CMP;
uint16_t u16CompareValue;
u16CompareValue = (9600U / ((uint16_t)1U << (stcTmr0Init.u32ClockDiv >> TMR0_BCONR_CKDIVA_POS)) - 1U);
stcTmr0Init.u16CompareValue = u16CompareValue;
(void)TMR0_Init(CM_TMR0_1, TMR0_CH_A, &stcTmr0Init);
DDL_DelayMS(1U);
TMR0_HWStartCondCmd(CM_TMR0_1, TMR0_CH_A, ENABLE);
DDL_DelayMS(1U);
TMR0_HWClearCondCmd(CM_TMR0_1, TMR0_CH_A, ENABLE);
DDL_DelayMS(1U);
/************************* Configure TMR0_1_B***************************/
(void)TMR0_StructInit(&stcTmr0Init);
stcTmr0Init.u32ClockSrc = TMR0_CLK_SRC_XTAL32;
stcTmr0Init.u32ClockDiv = TMR0_CLK_DIV1;
stcTmr0Init.u32Func = TMR0_FUNC_CMP;
uint16_t u16CompareValue; //重复定义了啊
u16CompareValue = (9600U - 4U);
stcTmr0Init.u16CompareValue = u16CompareValue;
(void)TMR0_Init(CM_TMR0_1, TMR0_CH_B, &stcTmr0Init);
DDL_DelayMS(1U);
TMR0_HWStartCondCmd(CM_TMR0_1, TMR0_CH_B, ENABLE);
DDL_DelayMS(1U);
TMR0_HWClearCondCmd(CM_TMR0_1, TMR0_CH_B, ENABLE);
DDL_DelayMS(1U);
|