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

GPIO not working with SD

Hello,

I have configured a 1 ms timer (Timer 2) interrupt. I am just updating some static variables for reference in the 1 ms interrupt. Everything seems to be working fine here (SD enabled). However I tried to toggle one of the GPIO pins in the 1 ms interrupt routine every 6 ms. Looks like this does not go well with SD. The control is in SD and is not returning to any one of my functions. I am not sure what the problem is. After this the SD stops broadcasting and nothing works. After I reset the controller via debugger it starts broadcasting and the same thing repeats.

Are there known issues in this regard? If not then can anyone let me know what might be the problem? I am not sure if I have given sufficient details. If not do let me know.

I am using: SD: 7.1 SDK 6

Thanks in advance!

Parents
  • What you are trying to achieve is basic and that should work otherwise there would have been a lot of reports here regarding that. I have verified this on SDK 7.2 with just one advertiser and there were no problems with the gpio. I verified even with 0.1ms timer interrupt and it just worked fine.

    post your code here and I can check for you.

  • Hey Thanks for your response! Here is the code:

    1 ms timer configuration: NRF_TIMER2->TASKS_STOP = 1; // Stop timer, if it was running NRF_TIMER2->TASKS_CLEAR = 1; NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer; // Timer mode (not counter) NRF_TIMER2->EVENTS_COMPARE[0] = 0; // clean up possible old events NRF_TIMER2->EVENTS_COMPARE[1] = 0; NRF_TIMER2->EVENTS_COMPARE[2] = 0; NRF_TIMER2->EVENTS_COMPARE[3] = 0;

    // Timer is polled, but enable the compare0 interrupt in order to wakeup from CPU sleep
    NRF_TIMER2->INTENSET    = TIMER_INTENSET_COMPARE0_Msk;
    	NRF_TIMER2->SHORTS      = 1 << TIMER_SHORTS_COMPARE0_CLEAR_Pos;    // Clear the count every time timer reaches the CCREG0 count
    NRF_TIMER2->PRESCALER   = 9;                                       // Input clock is 16MHz, timer clock = 2 ^ prescale -> interval 1us 9
    NRF_TIMER2->CC[0]       = 32;                          
    	NVIC_EnableIRQ(TIMER2_IRQn);
    	NRF_TIMER2->TASKS_START = 1;
    

    1 ms Timer IRQ:

    void TIMER2_IRQHandler(void) { if ((NRF_TIMER2->EVENTS_COMPARE[0] != 0) && ((NRF_TIMER2->INTENSET & TIMER_INTENSET_COMPARE0_Msk) != 0)) { NRF_TIMER2->EVENTS_COMPARE[0] = 0; //Clear compare register 0 event ms_update_timer(); h++; if((h<6) && (BuzzerTimer != 0)) { nrf_gpio_pin_set(BUZZER_0); } else { nrf_gpio_pin_clear(BUZZER_0); h=0; }

    }
    

    }

    Is it possible to check with SD 7.1? Thanks for your time.

Reply
  • Hey Thanks for your response! Here is the code:

    1 ms timer configuration: NRF_TIMER2->TASKS_STOP = 1; // Stop timer, if it was running NRF_TIMER2->TASKS_CLEAR = 1; NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer; // Timer mode (not counter) NRF_TIMER2->EVENTS_COMPARE[0] = 0; // clean up possible old events NRF_TIMER2->EVENTS_COMPARE[1] = 0; NRF_TIMER2->EVENTS_COMPARE[2] = 0; NRF_TIMER2->EVENTS_COMPARE[3] = 0;

    // Timer is polled, but enable the compare0 interrupt in order to wakeup from CPU sleep
    NRF_TIMER2->INTENSET    = TIMER_INTENSET_COMPARE0_Msk;
    	NRF_TIMER2->SHORTS      = 1 << TIMER_SHORTS_COMPARE0_CLEAR_Pos;    // Clear the count every time timer reaches the CCREG0 count
    NRF_TIMER2->PRESCALER   = 9;                                       // Input clock is 16MHz, timer clock = 2 ^ prescale -> interval 1us 9
    NRF_TIMER2->CC[0]       = 32;                          
    	NVIC_EnableIRQ(TIMER2_IRQn);
    	NRF_TIMER2->TASKS_START = 1;
    

    1 ms Timer IRQ:

    void TIMER2_IRQHandler(void) { if ((NRF_TIMER2->EVENTS_COMPARE[0] != 0) && ((NRF_TIMER2->INTENSET & TIMER_INTENSET_COMPARE0_Msk) != 0)) { NRF_TIMER2->EVENTS_COMPARE[0] = 0; //Clear compare register 0 event ms_update_timer(); h++; if((h<6) && (BuzzerTimer != 0)) { nrf_gpio_pin_set(BUZZER_0); } else { nrf_gpio_pin_clear(BUZZER_0); h=0; }

    }
    

    }

    Is it possible to check with SD 7.1? Thanks for your time.

Children
No Data
Related