I use sdk 15.3.0 / nrf52832 / SD_132.
How to use the prescaler of a timer for an event every 24 hours ?
An example will be very explicit.
Best regards, Jiemde
I use sdk 15.3.0 / nrf52832 / SD_132.
How to use the prescaler of a timer for an event every 24 hours ?
An example will be very explicit.
Best regards, Jiemde
Hi,
Have you seen the Timer documentation regarding prescaler options?
As you see from the prescaler register, you may at most set the timer prescaler to 2^9, which gives you 16M / 512 = 31250 ticks per second.
So, then we need to establish the size of our TIMER. We see that the different BITMODES available ranges from 8 to 32 bit.
Setting it to 32 bit gives us 4294967296 ticks til overflow, which with the 512 prescaler gives us ~36 hours till overflow.
Thus, you may set the timer to compare for the value 2700000000 - which is ticks per second times seconds in 24h.
You will now receive a COMPARE event every 24h. When this happens, you should remember to also CLEAR your timer - to avoid counting all the way to 36h before restarting at 0.
Is this what you were looking for?
Best regards,
Karl
Hi Karl, Thanks for fast reply.
I'm not yet "comfortable" with sdk.config, so for the "BITMODES", I suppose you speak about:
// <o> TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation
// <0=> Timer
// <1=> Counter
#ifndef TIMER_DEFAULT_CONFIG_MODE
#define TIMER_DEFAULT_CONFIG_MODE 0
#endif
// <o> TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width
// <0=> 16 bit
// <1=> 8 bit
// <2=> 24 bit
// <3=> 32 bit
#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH
#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 3
#endif
Question: where can I set the timer prescaler ?
Is there an example for references ?
Best regards
Jiemde
Hello Jiemde,
Jean-marie said:I'm not yet "comfortable" with sdk.config
I completely understand, no problem at all.
Have you seen the TIMER API Reference? Particularly, bit_width is set during initialization - see the input parameters to the nrfx_timer_init function.
I think this is what you are looking for, rather than the sdk_config.h. The lines you are referring to in the sdk_config is the DEFAULT_CONFIG parameters.
Is this what you were looking for?
Please let me know if you should have more questions or encounter any other issues! :)
Best regards,
Karl