File tree Expand file tree Collapse file tree 2 files changed +8
-147
lines changed
targets/TARGET_NORDIC/TARGET_NRF5x Expand file tree Collapse file tree 2 files changed +8
-147
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -70,14 +70,18 @@ void us_ticker_init(void)
70
70
71
71
/* Configure timer as follows:
72
72
* - timer mode,
73
- * - timer width 16 bits,
73
+ * - timer width 16 bits for NRF51 and 32 bits for NRF52 ,
74
74
* - timer freq 1 MHz.
75
75
*/
76
76
nrf_timer_mode_set (NRF_TIMER1 , NRF_TIMER_MODE_TIMER );
77
77
78
78
nrf_timer_frequency_set (NRF_TIMER1 , NRF_TIMER_FREQ_1MHz );
79
79
80
+ #ifdef NRF52
81
+ nrf_timer_bit_width_set (NRF_TIMER1 , NRF_TIMER_BIT_WIDTH_32 );
82
+ #else
80
83
nrf_timer_bit_width_set (NRF_TIMER1 , NRF_TIMER_BIT_WIDTH_16 );
84
+ #endif
81
85
82
86
nrf_timer_cc_write (NRF_TIMER1 , NRF_TIMER_CC_CHANNEL0 , 0 );
83
87
@@ -110,7 +114,9 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
110
114
{
111
115
core_util_critical_section_enter ();
112
116
113
- nrf_timer_cc_write (NRF_TIMER1 , NRF_TIMER_CC_CHANNEL0 , timestamp & 0xFFFF );
117
+ const uint32_t counter_mask = ((1 << US_TICKER_COUNTER_BITS ) - 1 );
118
+
119
+ nrf_timer_cc_write (NRF_TIMER1 , NRF_TIMER_CC_CHANNEL0 , timestamp & counter_mask );
114
120
115
121
if (!nrf_timer_int_enable_check (NRF_TIMER1 , nrf_timer_compare_int_get (NRF_TIMER_CC_CHANNEL0 ))) {
116
122
nrf_timer_event_clear (NRF_TIMER1 , NRF_TIMER_EVENT_COMPARE0 );
You can’t perform that action at this time.
0 commit comments