SAME70 External Interrupt issue

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, below is my code that toggles PC8 when ever edge is detected on interrupt. The problem is when i remove the line delay_us from else block PC8 Never toggles why?

static void Button1_Handler(uint32_t id, uint32_t mask)
{
if (ID_PIOA == id && PIO_PA6 == mask) {
uc_button=true;
}
}

static void configure_INT(void) //Echo pin
{
/* Configure Pushbutton 1 */
pmc_enable_periph_clk(PIOA);
pio_set_debounce_filter(PIOA, PIO_PA6, 10);
/* Interrupt on rising edge */
pio_handler_set(PIOA, ID_PIOA,
PIO_PA6, PIN_CLK_ATTR, Button1_Handler);
NVIC_EnableIRQ((IRQn_Type) ID_PIOA);
pio_handler_set_priority(PIOA,
(IRQn_Type) ID_PIOA, 0); //0 for highest priority
pio_enable_interrupt(PIOA, PIO_PA6);
}
And the main code is

while (true) {
if (uc_button == true) {
uc_button=false;

ioport_toggle_pin_level(PC8);

}
else
{
delay_us(1);
}
}

This topic has a solution.

Last Edited: Sun. Sep 29, 2019 - 06:27 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uc_button needs to be declared volatile. Also why is a uc_ variable being used as a bool?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To use this variable as a flag. Any issue in it?