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

Timer1 max value

Hello,

I'm working on nrf52832-DK with SDK11 on Timer1. I can't use TIMER0 because I'm using also the softdevice.

My code source is :

//handler
void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
    
    switch(event_type)
    {
        case NRF_TIMER_EVENT_COMPARE1:
                  nrf_drv_gpiote_out_set(PIN_06);
         //nrf_drv_timer_compare_int_disable(&TIMER, NRF_TIMER_CC_CHANNEL0);


            break;
        
        default:
            //Do nothing.
            break;
    }    
}


main : 

                    time_us = 5000; //Time(in us) between consecutive compare events.
                    nrf_drv_timer_clear(&TIMER);
                    time_ticks = nrf_drv_timer_us_to_ticks(&TIMER, time_us);
                    nrf_drv_timer_compare(&TIMER_LED, NRF_TIMER_CC_CHANNEL1, time_ticks, true);
                    nrf_drv_timer_enable(&TIMER);

I want to configure my Timer1 between 1us and 10000us. I have seen that Timer 0 is BIT_WIDTH 16 bits so the maximum value can be theorically 65535 ?

But my timer restart at the value of 4097. Is it normal ? How can I configure it to set the value from 0-10000 us ?

Thank you very much

Parents
  • Yes, on the NRF52 all TIMERs can be 32-bit.

    How does your nrf_drv_config.h file look like?

    Try to config it like this:

        #define TIMER1_ENABLED 1
    
        #if (TIMER1_ENABLED == 1)
        #define TIMER1_CONFIG_FREQUENCY    NRF_TIMER_FREQ_16MHz
        #define TIMER1_CONFIG_MODE         TIMER_MODE_MODE_Timer
        #define TIMER1_CONFIG_BIT_WIDTH    TIMER_BITMODE_BITMODE_32Bit
        #define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
        
        #define TIMER1_INSTANCE_INDEX      (TIMER0_ENABLED)
        #endif
    
Reply
  • Yes, on the NRF52 all TIMERs can be 32-bit.

    How does your nrf_drv_config.h file look like?

    Try to config it like this:

        #define TIMER1_ENABLED 1
    
        #if (TIMER1_ENABLED == 1)
        #define TIMER1_CONFIG_FREQUENCY    NRF_TIMER_FREQ_16MHz
        #define TIMER1_CONFIG_MODE         TIMER_MODE_MODE_Timer
        #define TIMER1_CONFIG_BIT_WIDTH    TIMER_BITMODE_BITMODE_32Bit
        #define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
        
        #define TIMER1_INSTANCE_INDEX      (TIMER0_ENABLED)
        #endif
    
Children
No Data
Related