You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
when setting prescaler of a (nRF52840) RTC to a value greater than 256, the value overflows. therefore, it is not possible to use all the 12bit of the prescaler as mentioned in the nRF52840 datasheet.
To Reproduce
Steps to reproduce the behavior:
set prescaler to a value >256 (e.g., RTC2 to 4096)
Expected behavior
the value of tick should be 8, however it is 128. the counter is 16 times faster because of the overflow: 256 * 16 = 4096).
Screenshots or console output
warning indicating the overflow:
zephyr/drivers/counter/counter_nrfx_rtc.c: In function 'counter_2_init':
zephyr/include/generated/generated_dts_board_unfixed.h:661:53: warning: unsigned conversion from 'int' to 'u8_t' {aka 'unsigned char'} changes value from '4095' to '255' [-Woverflow]
#define DT_NORDIC_NRF_RTC_40024000_PRESCALER 4096
zephyr/include/generated/generated_dts_board_unfixed.h:663:53: note: in expansion of macro 'DT_NORDIC_NRF_RTC_40024000_PRESCALER'
#define DT_NORDIC_NRF_RTC_RTC_2_PRESCALER DT_NORDIC_NRF_RTC_40024000_PRESCALER
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/chirsch/workspace/zephyrproject/zephyr/drivers/counter/counter_nrfx_rtc.c:662:5: note: in expansion of macro 'DT_NORDIC_NRF_RTC_RTC_2_PRESCALER'
DT_NORDIC_NRF_RTC_RTC_##idx##_PRESCALER - 1); \
^~~~~~~~~~~~~~~~~~~~~~
/home/chirsch/workspace/zephyrproject/zephyr/drivers/counter/counter_nrfx_rtc.c:702:1: note: in expansion of macro 'COUNTER_NRF_RTC_DEVICE'
COUNTER_NRF_RTC_DEVICE(2);
Environment (please complete the following information):
Additional context
the effected function is static int init_rtc(struct device *dev, u8_t prescaler) in zephyr/drivers/counter/counter_nrfx_rtc.c. I already tried to change u8_t prescaler to u16_t prescaler wich eliminates the warning, but zephyr crashes..
The text was updated successfully, but these errors were encountered:
I just realized that I had some settings in the prj.conf file which caused the zephyr crashes. changing u8_t prescaler to u16_t prescaler actually fixed the problem.
use u32_t in init_rtc to be able to use the full 12 bit prescaler values
fixeszephyrproject-rtos#22014
Signed-off-by: Christian Hirsch <christian.hirsch@tuwien.ac.at>
Describe the bug
when setting prescaler of a (nRF52840) RTC to a value greater than 256, the value overflows. therefore, it is not possible to use all the 12bit of the prescaler as mentioned in the nRF52840 datasheet.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
the value of
tick
should be8
, however it is128
. the counter is 16 times faster because of the overflow: 256 * 16 = 4096).Screenshots or console output
warning indicating the overflow:
Environment (please complete the following information):
Additional context
the effected function is
static int init_rtc(struct device *dev, u8_t prescaler)
inzephyr/drivers/counter/counter_nrfx_rtc.c
. I already tried to changeu8_t prescaler
tou16_t prescaler
wich eliminates the warning, but zephyr crashes..The text was updated successfully, but these errors were encountered: