Hello there,
I am trying to build a test program which uses the PB0 as an external interrupt line to turn the LED connected to PC8 ON. Here is my simple program.
int main (void){
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN| RCC_APB2ENR_IOPCEN | RCC_APB2ENR_AFIOEN; // enable the PortA, PortC
RCC->APB1ENR |= RCC_APB1ENR_DACEN; // enable DAC and TIM3 clock
GPIOC->CRH =0x0002; // configure PC8 as output
EXTI->IMR = EXTI_IMR_MR0;
EXTI->RTSR = EXTI_RTSR_TR0;
EXTI->FTSR = EXTI_FTSR_TR0;
AFIO ->EXTICR[1] = AFIO_EXTICR1_EXTI0_PB;
NVIC_EnableIRQ(EXTI0_IRQn);
while(1){
}
}
void EXTI0_IRQHandler(void)
{
while(1)
{
GPIOC -> ODR = 0x0100;
}
}
I am not sure what I did wrong, but somehow the program doesn't work.
Any suggestions?
Thanks!
[ADMIN ED: code formatting]