Hallo,
I am playing around with ch32v003fun from cnlohr, and like it a lot :-)
I have started to play with timerinterrupts, and use the following code to get a timer1 interrupt, which is working well.
void init_timer1() {
RCC->APB2PCENR |= RCC_APB2Periph_TIM1;
TIM1->CTLR1 |= TIM_CounterMode_Up | TIM_CKD_DIV1;
TIM1->CTLR2 = TIM_MMS_1;
TIM1->ATRLR = 3000-1;
TIM1->PSC = 0;
TIM1->RPTCR = 0;
TIM1->SWEVGR = TIM_PSCReloadMode_Immediate;
NVIC_EnableIRQ(TIM1_UP_IRQn);
TIM1->INTFR = ~TIM_FLAG_Update;
TIM1->DMAINTENR |= TIM_IT_Update;
TIM1->CTLR1 |= TIM_CEN;
}
void TIM1_UP_IRQHandler(void) __attribute__((interrupt));
void TIM1_UP_IRQHandler() {
if(TIM1->INTFR & TIM_FLAG_Update) {
TIM1->INTFR = ~TIM_FLAG_Update;
// Toggle a pin here
}
}
But when I change to the following, it does not work at all, and I have no more ideas

. Any help whould be preciated.
void init_timer2() {
RCC->APB2PCENR |= RCC_APB1Periph_TIM2;
TIM2->CTLR1 |= TIM_CounterMode_Up | TIM_CKD_DIV1;
TIM2->CTLR2 = TIM_MMS_1;
TIM2->ATRLR = 3000-1;
TIM2->PSC = 0;
TIM2->RPTCR = 0;
TIM2->SWEVGR = TIM_PSCReloadMode_Immediate;
NVIC_EnableIRQ(TIM2_IRQn);
TIM2->INTFR = ~TIM_FLAG_Update;
TIM2->DMAINTENR |= TIM_IT_Update;
TIM2->CTLR1 |= TIM_CEN;
}
void TIM2_IRQHandler(void) __attribute__((interrupt));
void TIM2_IRQHandler(){
if(TIM2->INTFR & TIM_FLAG_Update) {
TIM2->INTFR = ~TIM_FLAG_Update;
// Toggle a pin here
}
}