Hi, I want to start TIMER1 by a GPIO_TE. When the program enter the TIMER1_IRQHandler(), I want to disable the ppi. And when the program leave the TIMER1_IRQHandler(), I want to enable the ppi again. But I found once I disable the ppi, the program run to HardFault_Handler immediatly. It sames that I can't modefy ppi any more after program initial. It's the program(my sd is 6.0.0 and sdk is 5.2.0):
int main(void)
{
ble_stack_init();
gpiote_init();
ppi_init();
init_timer1();
while(1){}
}
static void gpiote_init(void)
{
APP_GPIOTE_INIT(1);
nrf_gpiote_event_config(MF_GPIOTE_CHANNEL_NUMBER, KEY_START, GPIOTE_CONFIG_POLARITY_HiToLo);
}
static void ppi_init(void)
{
sd_ppi_channel_assign(0, &NRF_GPIOTE->EVENTS_IN[MF_GPIOTE_CHANNEL_NUMBER], &NRF_TIMER1->TASKS_START);
sd_ppi_channel_enable_set(1 << 0);
}
void init_timer1()
{
NRF_TIMER1->PRESCALER = 1;
NRF_TIMER1->TASKS_CLEAR = 1;
NRF_TIMER1->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
NRF_TIMER1->CC[0] = 10;
NRF_TIMER1->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER1->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk;
NRF_TIMER1->EVENTS_COMPARE[0] = 0;
NRF_TIMER1->EVENTS_COMPARE[1] = 0;
NRF_TIMER1->EVENTS_COMPARE[2] = 0;
NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;
sd_nvic_SetPriority(TIMER1_IRQn, 1);
sd_nvic_EnableIRQ(TIMER1_IRQn);
}
void TIMER1_IRQHandler()
{
sd_ppi_channel_enable_clr(1 << 0);
clear_timer1_event_compare();
NRF_TIMER1->TASKS_STOP = 1;
......
sd_ppi_channel_enable_set(1 << 0);
}