2021-04-21 08:24 AM
I am trying to generate a small program to toggle the onboard LED (PA5) using the onboard switch (PC13) using an interrupt. I set a breakpoint in my ISR and I never go there. I have gone over all the register settings and they look correct: (i.e. enabled the clock on each of the GPIOs and SYSCFG, I have set up the mask for IRQ, I have set up the NVIC to use #40 (PC13))....can someone give me some advice as to what to look for? Below is my main code file. I can supply more if necessary. Seems that I am missing a link between peripheral and NVIC.
thanks
Steve
void delay(void)
{
for (uint32_t i = 0; i < 50000/2; i++);
}
int main(void)
{
GPIO_Handle_t GpioLed, GpioBtn;
memset(&GpioLed, 0, sizeof(GpioLed));
memset(&GpioBtn, 0, sizeof(GpioBtn));
GpioLed.pGPIOx = GPIOA;
GpioLed.GPIO_PinConfig.GPIO_PinNumber = GPIO_PIN_NO_5;
GpioLed.GPIO_PinConfig.GPIO_PinMode = GPIO_MODE_OUT;
GpioLed.GPIO_PinConfig.GPIO_PinOPType = GPIO_OP_TYPE_PP;
GpioLed.GPIO_PinConfig.GPIO_PinPuPdCntrl = GPIO_NO_PUPD;
GPIO_PeriClockControl(GPIOA, ENABLE);
GPIO_Init(&GpioLed);
GpioBtn.pGPIOx = GPIOC;
GpioBtn.GPIO_PinConfig.GPIO_PinNumber = GPIO_PIN_NO_13;
GpioBtn.GPIO_PinConfig.GPIO_PinMode = GPIO_MODE_IT_FT;
GpioBtn.GPIO_PinConfig.GPIO_PinSpeed = GPIO_SPEED_FAST;
GpioBtn.GPIO_PinConfig.GPIO_PinPuPdCntrl = GPIO_NO_PUPD;
GPIO_PeriClockControl(GPIOC, ENABLE);
GPIO_Init(&GpioBtn);
//IRQ configurations
GPIO_IRQPriorityConfig(IRQ_NO_EXTI15_10,NVIC_IRQ_PRI15);
GPIO_IRQInterruptConfig(IRQ_NO_EXTI15_10,ENABLE);
while(1);
}
void EXTI15_10_IRQHandler(void)
{
GPIO_IRQHandling(GPIO_PIN_NO_13);
delay();
GPIO_ToggleOutputPin(GPIOA, GPIO_PIN_NO_5);
}
2021-04-22 06:13 AM
Thank for all the help ... I will check out Yiu's book
To your question last evening....
NVIC->ISER : 0x2 ------------------yes this is what I see in this register AFTER I step over the following command in debugger:
*((__vo uint32_t *)0xE000E104) |= (1<<8);
Turns out this command changes the following register BUT my code still works?!?!
NVIC->ICER : 0x100
As you can see from ICER the correct bit is set ....Looks to me like when you write to ISER it does NOT read back as the manual says. Looks more like a write to ISER should be confirmed with a read of ICER. I guess this just supports your above comment on how bad the ARM manual is....
2021-04-22 06:48 AM
> Looks to me like when you write to ISER it does NOT read back as the manual says.
It should.
> Looks more like a write to ISER should be confirmed with a read of ICER.
No, there's no reason for that.
I would suspect the debugger to display something else - maybe an older value.
JW