This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO interrupts not working with bootloader

Hello everyone. I am having problems using the interrups when a bootloader is programmed on the chip. My test program works fine when there is no bootloader. With the bootloader it never jumps to the interrupt handler. I am using the nrf51 and the s110 softdevice. I do the following in the bootloader to jump to the application.

sd_mbr_command_t com = {SD_MBR_COMMAND_INIT_SD, };
err_code = sd_mbr_command(&com);
APP_ERROR_CHECK(err_code);
err_code = sd_softdevice_vector_table_base_set(APP_START_ADDRESS);
APP_ERROR_CHECK(err_code);

Here is the code from my app. It basically blinks a led until a button is pressed and in the interrupt the chip is reset.

extern "C"{
#include "nrf_delay.h"
}

#include <stdbool.h>
#include <stdint.h>
#include "nrf_gpio.h"
#include "nrf_sdm.h"
#include "nrf_mbr.h"

extern "C"{
void GPIOTE_IRQHandler(void) // Interrupt HAndler
  {
      if(NRF_GPIOTE->EVENTS_IN[0] != 0)
      {
          //sd_mbr_command_t com = {SD_MBR_COMMAND_INIT_SD, };
          NRF_GPIOTE->EVENTS_IN[0] = 0;
          NRF_POWER->GPREGRET = 0x80;
          NVIC_SystemReset();
          //sd_softdevice_vector_table_base_set(0x0003C000);
          //sd_mbr_command(&com);
      }
  }
}

void config_CTS_Reset(void){
  NRF_GPIOTE->CONFIG[0] = (uint32_t)1 | // Event mode on IN[0]
                          ((uint32_t)8<<8) | // Pin 10 selected for Event
                          ((uint32_t)1<<16) ; // Generate event when rising edge on pin
  NRF_GPIOTE->INTENSET = (uint32_t)1; //Enable interrupt on IN[0]
  NVIC_EnableIRQ(GPIOTE_IRQn);
}

int main(void)
{
  //sd_softdevice_vector_table_base_set(0x0);

  NRF_GPIO -> PIN_CNF[21] =  ( (uint32_t)1 |    // Set as Output
                             ( (uint32_t)1 << 1) | // Disconnect input buffer
                             ( (uint32_t)0 << 2) |  //  No Pull
                             ( (uint32_t)0 << 8)); // Drive S0S1
  config_CTS_Reset();

  for(;;){
      NRF_GPIO->OUTCLR = (uint32_t)1 << 21;
      nrf_delay_ms(300);
      NRF_GPIO->OUTSET = (uint32_t)1 << 21;
      nrf_delay_ms(300);
  }

}
Parents
  • You have not configured the input pin as an input pin with Sense enabled.

    void config_CTS_Reset(void){
        NRF_GPIOTE->CONFIG[0] = (GPIOTE_INTENSET_IN0_Set << GPIOTE_INTENSET_IN0_Pos) |       // Event mode on IN[0]
                                (0x0A << GPIOTE_CONFIG_PSEL_Pos)  |  // Pin 10 selected for Event
                                (GPIOTE_CONFIG_POLARITY_LoToHi << GPIOTE_CONFIG_POLARITY_Pos) ;   // Generate event when rising edge on pin
        
    
        NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Set << GPIOTE_INTENSET_IN0_Pos;   //Enable interrupt on IN[0]
        NVIC_EnableIRQ(GPIOTE_IRQn);
    }
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        //sd_softdevice_vector_table_base_set(0x0);
    
        NRF_GPIO -> PIN_CNF[21] =  ( (uint32_t)1 |    // Set as Output
                                 ( (uint32_t)1 << 1) | // Disconnect input buffer
                                 ( (uint32_t)0 << 2) |  //  No Pull
                                 ( (uint32_t)0 << 8)); // Drive S0S1
        
        NRF_GPIO -> PIN_CNF[10] =  ( GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |    // Set as INPUT
                                    (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)| // Connect input buffer
                                    (GPIO_PIN_CNF_PULL_Pulldown << GPIO_PIN_CNF_PULL_Pos)|  //  No Pull
                                    (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |  // Drive S0S1
                                    (GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos); //Sense when input is HIGH
        
        config_CTS_Reset();
    
        for(;;){
            NRF_GPIO->OUTCLR = (uint32_t)1 << 21;
            nrf_delay_ms(300);
            NRF_GPIO->OUTSET = (uint32_t)1 << 21;
            nrf_delay_ms(300);
        }
    }
    
  • With this code I had the same problem. It works without the bootloader, but when the bootloader is on the chip it doesn't work.

Reply Children
No Data
Related