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);
}
}