Skip to content

Commit 81445a0

Browse files
Edmund Hsuadbridge
authored andcommitted
Fix EV_COG_AD3029LZ us_ticker_fire_interrupt() minimal time interval
- ensure us_ticker_irq_handler() is called only when GP2 timer expires - set us_ticker_set_interrupt() time interval to be 9.846 us - set us_ticker_fire_interrupt() time interval to be 0.03846 us
1 parent 9bc9f2f commit 81445a0

File tree

1 file changed

+14
-4
lines changed
  • targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api

1 file changed

+14
-4
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/us_ticker.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010-2017 Analog Devices, Inc.
2+
* Copyright (c) 2010-2018 Analog Devices, Inc.
33
*
44
* All rights reserved.
55
*
@@ -206,7 +206,10 @@ static void event_timer()
206206
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, &tmr2Config);
207207
adi_tmr_Enable(ADI_TMR_DEVICE_GP2, true);
208208
} else {
209-
us_ticker_irq_handler();
209+
tmr2Config.nLoad = 65535u;
210+
tmr2Config.nAsyncLoad = 65535u;
211+
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, &tmr2Config);
212+
adi_tmr_Enable(ADI_TMR_DEVICE_GP2, true);
210213
}
211214
}
212215

@@ -231,7 +234,11 @@ static void GP2CallbackFunction(void *pCBParam, uint32_t Event, void * pArg)
231234

232235
if (largecnt < 65536u) {
233236
adi_tmr_Enable(ADI_TMR_DEVICE_GP2, false);
234-
event_timer();
237+
if (largecnt) {
238+
event_timer();
239+
} else {
240+
us_ticker_irq_handler();
241+
}
235242
}
236243
}
237244

@@ -328,6 +335,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
328335
*
329336
*/
330337
calc_event_counts(timestamp); // use timestamp to calculate largecnt to control number of timer interrupts
338+
tmr2Config.ePrescaler = ADI_TMR_PRESCALER_256; // TMR2 at 26MHz/256
331339
event_timer(); // uses largecnt to initiate timer interrupts
332340
}
333341

@@ -339,7 +347,9 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
339347
*/
340348
void us_ticker_fire_interrupt(void)
341349
{
342-
NVIC_SetPendingIRQ(TMR2_EVT_IRQn);
350+
largecnt = 1; // set a minimal interval so interrupt fire immediately
351+
tmr2Config.ePrescaler = ADI_TMR_PRESCALER_1; // TMR2 at 26MHz/1
352+
event_timer(); // enable the timer and interrupt
343353
}
344354

345355

0 commit comments

Comments
 (0)