CC13xx Driver Library
[aux_timer.h] AUX Timer

Functions

void AUXTimerConfigure (uint32_t ui32Timer, uint32_t ui32Config)
 Configure AUX timer. More...
 
void AUXTimerStart (uint32_t ui32Timer)
 Start AUX timer(s). More...
 
void AUXTimerStop (uint32_t ui32Timer)
 Stop AUX timer(s). More...
 
static void AUXTimerTargetValSet (uint32_t ui32Timer, uint32_t ui32Target)
 Set AUX timer target value. More...
 
static uint32_t AUXTimerTargetValGet (uint32_t ui32Timer)
 Get AUX timer target value. More...
 
void AUXTimerPrescaleSet (uint32_t ui32Timer, uint32_t ui32PrescaleDiv)
 Set AUX timer prescale value. More...
 
uint32_t AUXTimerPrescaleGet (uint32_t ui32Timer)
 Get AUX timer prescale value. More...
 

Detailed Description

Function Documentation

void AUXTimerConfigure ( uint32_t  ui32Timer,
uint32_t  ui32Config 
)

Configure AUX timer.

This call configures the AUX timer selected by the ui32Timer. The timer module is disabled before being configured and is left in the disabled state.

The configuration is specified in ui32Config as one of the following values:

When configured as timer, the counter is incremented based on the AUX clock after the prescaler. The prescale division ratio is set using AUXTimerPrescaleSet().

When configured as an edge counter the counter is incremented only on edges of the selected event. The polarity of the event is selected by:

The event source is selected as one of the following defines:

The mode, event polarity and event source are configured by setting the ui32Config parameter as the bitwise OR of the various settings. Example: (AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT | AUX_TIMER_CFG_RISING_EDGE | AUX_TIMER_CFG_TICK_SRC_RTC_EVENT).

Note
When used as an edge counter the prescaler should be set to AUX_TIMER_PRESCALE_DIV_1.
A timer can not trigger itself thus timer 0 can not use AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT and timer 1 can not use AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT.
Parameters
ui32Timeris the timer to configure.
ui32Configis the timer configuration.
Returns
None
See also
AUXTimerPrescaleSet()
67 {
68  uint32_t ui32Val;
69 
70  // Check the arguments.
71  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1) ||
72  (ui32Timer == AUX_TIMER_BOTH));
73 
74  // Configure Timer 0.
75  if(ui32Timer & AUX_TIMER_0)
76  {
77  // Stop timer 0.
78  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CTL) = 0;
79 
80  // Set mode.
81  ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG);
83  ui32Val |= (ui32Config & (AUX_TIMER_T0CFG_MODE_M |
85  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG) = ui32Val;
86 
87  // If edge counter, set rising/falling edge and tick source.
88  if(ui32Config & AUX_TIMER_T0CFG_MODE_M)
89  {
90  ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG);
91  ui32Val &= ~(AUX_TIMER_T0CFG_TICK_SRC_POL_M |
93 
94  // Set edge polarity.
95  if(ui32Config & AUX_TIMER_CFG_FALLING_EDGE)
96  {
98  }
99 
100  // Set tick source.
101  ui32Val |= (ui32Config & AUX_TIMER_T0CFG_TICK_SRC_M);
102  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG) = ui32Val;
103  }
104  }
105 
106  // Configure Timer 1.
107  if(ui32Timer & AUX_TIMER_1)
108  {
109  // Stop timer 1.
110  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CTL) = 0;
111 
112  // Set mode.
113  ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG);
115  ui32Val |= ((ui32Config) & (AUX_TIMER_T1CFG_MODE_M |
117  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG) = ui32Val;
118 
119  // If edge counter, set rising/falling edge and tick source.
120  if(ui32Config & AUX_TIMER_T1CFG_MODE)
121  {
122  ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG);
123  ui32Val &= ~(AUX_TIMER_T1CFG_TICK_SRC_POL_M |
125 
126  // Set edge polarity.
127  if(ui32Config & AUX_TIMER_CFG_FALLING_EDGE)
128  {
129  ui32Val |= AUX_TIMER_T1CFG_TICK_SRC_POL;
130  }
131 
132  // Set tick source.
133  ui32Val |= (ui32Config & AUX_TIMER_T1CFG_TICK_SRC_M);
134  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG) = ui32Val;
135  }
136  }
137 }
#define AUX_TIMER_BOTH
Definition: aux_timer.h:145
#define AUX_TIMER_CFG_FALLING_EDGE
Definition: aux_timer.h:102
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144
uint32_t AUXTimerPrescaleGet ( uint32_t  ui32Timer)

Get AUX timer prescale value.

When configured as timer, the counter is incremented based on the AUX clock after the prescaler. This call returns the setting of the prescale divide ratio for the specified timer.

Parameters
ui32Timeris the timer to get the prescale value from.
Returns
Returns the prescaler division ratio as one of the following values:
See also
AUXTimerPrescaleSet()
229 {
230  uint32_t ui32Val;
231  uint32_t ui32PrescaleDiv;
232 
233  // Check the arguments.
234  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
235 
236  ui32Val = (HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG));
237  if(ui32Timer & AUX_TIMER_0)
238  {
239  // Get timer 0 prescale value.
240  ui32PrescaleDiv =
242  }
243  else
244  {
245  // Get timer 1 prescale value.
246  ui32PrescaleDiv =
248  }
249 
250  return(ui32PrescaleDiv);
251 }
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144
void AUXTimerPrescaleSet ( uint32_t  ui32Timer,
uint32_t  ui32PrescaleDiv 
)

Set AUX timer prescale value.

When configured as timer, the counter is incremented based on the AUX clock after the prescaler.

Note
Setting prescale value is not advised when the timer is running.
When timer is used as an edge counter the prescaler should be set to AUX_TIMER_PRESCALE_DIV_1.
Parameters
ui32Timeris the timer to set the prescale on.
ui32PrescaleDivis the prescaler division ratio.
Returns
None
See also
AUXTimerPrescaleGet()
196 {
197  uint32_t ui32Val;
198 
199  // Check the arguments.
200  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1) ||
201  (ui32Timer == AUX_TIMER_BOTH));
202  ASSERT(ui32PrescaleDiv <= AUX_TIMER_PRESCALE_DIV_32768);
203 
204  if(ui32Timer & AUX_TIMER_0)
205  {
206  // Set timer 0 prescale value.
207  ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG);
208  ui32Val &= ~AUX_TIMER_T0CFG_PRE_M;
209  ui32Val |= ui32PrescaleDiv << AUX_TIMER_T0CFG_PRE_S;
210  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG) = ui32Val;
211  }
212  if(ui32Timer & AUX_TIMER_1)
213  {
214  // Set timer 1 prescale value.
215  ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG);
216  ui32Val &= ~AUX_TIMER_T1CFG_PRE_M;
217  ui32Val |= ui32PrescaleDiv << AUX_TIMER_T1CFG_PRE_S;
218  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG) = ui32Val;
219  }
220 }
#define AUX_TIMER_BOTH
Definition: aux_timer.h:145
#define AUX_TIMER_PRESCALE_DIV_32768
Definition: aux_timer.h:168
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144
void AUXTimerStart ( uint32_t  ui32Timer)

Start AUX timer(s).

This call starts the selected AUX timer(s).

Note
The counter will start counting up from zero.
Parameters
ui32Timeris the timer to start.
Returns
None
See also
AUXTimerStop()
146 {
147  // Check the arguments.
148  ASSERT((ui32Timer == AUX_TIMER_0) ||
149  (ui32Timer == AUX_TIMER_1) ||
150  (ui32Timer == AUX_TIMER_BOTH));
151 
152  if(ui32Timer & AUX_TIMER_0)
153  {
154  // Start timer 0.
156  }
157  if(ui32Timer & AUX_TIMER_1)
158  {
159  // Start timer 1.
161  }
162 }
#define AUX_TIMER_BOTH
Definition: aux_timer.h:145
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144
void AUXTimerStop ( uint32_t  ui32Timer)

Stop AUX timer(s).

This call stops the selected AUX timer(s).

Parameters
ui32Timeris the timer to stop.
Returns
None
See also
AUXTimerStart()
171 {
172  // Check the arguments.
173  ASSERT((ui32Timer == AUX_TIMER_0) ||
174  (ui32Timer == AUX_TIMER_1) ||
175  (ui32Timer == AUX_TIMER_BOTH));
176 
177  if(ui32Timer & AUX_TIMER_0)
178  {
179  // Stop timer 0.
180  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CTL) = 0;
181  }
182  if(ui32Timer & AUX_TIMER_1)
183  {
184  // Stop timer 1.
185  HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CTL) = 0;
186  }
187 }
#define AUX_TIMER_BOTH
Definition: aux_timer.h:145
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144
static uint32_t AUXTimerTargetValGet ( uint32_t  ui32Timer)
inlinestatic

Get AUX timer target value.

The timer counts from zero to the target value. When target value is reached an event is generated. This function returns the programmed target value for the specified timer.

Parameters
ui32Timeris the timer to get the target value from.
Returns
Returns target value for the specified timer
See also
AUXTimerTargetValSet()
354 {
355  // Check the arguments.
356  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
357 
358  return(HWREG((ui32Timer & AUX_TIMER_0) ?
361 }
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144
static void AUXTimerTargetValSet ( uint32_t  ui32Timer,
uint32_t  ui32Target 
)
inlinestatic

Set AUX timer target value.

The timer counts from zero to the target value. When target value is reached an event is generated.

Parameters
ui32Timeris the timer to set the target value for.
ui32Targetis the timer target value.
  • For AUX_TIMER_0 the target value must be an integer in the range 0..65535 (16 bit).
  • For AUX_TIMER_1 the target value must be an integer in the range 0..255 (8 bit).
Returns
None
See also
AUXTimerTargetValGet()
320 {
321  uint32_t ui32Addr;
322 
323  // Check the arguments.
324  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
325  ASSERT(((ui32Timer & AUX_TIMER_0) && (ui32Target <= 65535)) ||
326  ((ui32Timer & AUX_TIMER_1) && (ui32Target <= 255)));
327 
328  ui32Addr = (ui32Timer & AUX_TIMER_0) ?
331 
332  HWREG(ui32Addr) = ui32Target;
333 }
#define AUX_TIMER_0
Definition: aux_timer.h:143
#define ASSERT(expr)
Definition: debug.h:73
#define AUX_TIMER_1
Definition: aux_timer.h:144

Macro Definition Documentation

#define AUX_TIMER_BOTH   0x00FFFFFF
#define AUX_TIMER_CFG_FALLING_EDGE   (AUX_TIMER_T0CFG_TICK_SRC_POL_FALL)

Referenced by AUXTimerConfigure().

#define AUX_TIMER_CFG_ONE_SHOT   (AUX_TIMER_T0CFG_RELOAD_MAN)
#define AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT   ((AUX_TIMER_T0CFG_RELOAD_MAN) | (AUX_TIMER_T0CFG_MODE_TICK))
#define AUX_TIMER_CFG_PERIODIC   (AUX_TIMER_T0CFG_RELOAD_CONT)
#define AUX_TIMER_CFG_PERIODIC_EDGE_COUNT   ((AUX_TIMER_T0CFG_RELOAD_CONT) | (AUX_TIMER_T0CFG_MODE_TICK))
#define AUX_TIMER_CFG_RISING_EDGE   (AUX_TIMER_T0CFG_TICK_SRC_POL_RISE)
#define AUX_TIMER_CFG_TICK_SRC_ACLK_REF   (AUX_TIMER_T0CFG_TICK_SRC_ACLK_REF)
#define AUX_TIMER_CFG_TICK_SRC_ADC_DONE   (AUX_TIMER_T0CFG_TICK_SRC_ADC_DONE)
#define AUX_TIMER_CFG_TICK_SRC_ADC_IRQ   (AUX_TIMER_T0CFG_TICK_SRC_ADC_IRQ)
#define AUX_TIMER_CFG_TICK_SRC_AIO0   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO0)
#define AUX_TIMER_CFG_TICK_SRC_AIO1   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO1)
#define AUX_TIMER_CFG_TICK_SRC_AIO10   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO10)
#define AUX_TIMER_CFG_TICK_SRC_AIO11   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO11)
#define AUX_TIMER_CFG_TICK_SRC_AIO12   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO12)
#define AUX_TIMER_CFG_TICK_SRC_AIO13   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO13)
#define AUX_TIMER_CFG_TICK_SRC_AIO14   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO14)
#define AUX_TIMER_CFG_TICK_SRC_AIO15   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO15)
#define AUX_TIMER_CFG_TICK_SRC_AIO2   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO2)
#define AUX_TIMER_CFG_TICK_SRC_AIO3   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO3)
#define AUX_TIMER_CFG_TICK_SRC_AIO4   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO4)
#define AUX_TIMER_CFG_TICK_SRC_AIO5   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO5)
#define AUX_TIMER_CFG_TICK_SRC_AIO6   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO6)
#define AUX_TIMER_CFG_TICK_SRC_AIO7   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO7)
#define AUX_TIMER_CFG_TICK_SRC_AIO8   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO8)
#define AUX_TIMER_CFG_TICK_SRC_AIO9   (AUX_TIMER_T0CFG_TICK_SRC_AUXIO9)
#define AUX_TIMER_CFG_TICK_SRC_AON_PROG_WU   (AUX_TIMER_T0CFG_TICK_SRC_AON_PROG_WU)
#define AUX_TIMER_CFG_TICK_SRC_AON_SW   (AUX_TIMER_T0CFG_TICK_SRC_AON_SW)
#define AUX_TIMER_CFG_TICK_SRC_CMP_A   (AUX_TIMER_T0CFG_TICK_SRC_AUX_COMPA)
#define AUX_TIMER_CFG_TICK_SRC_CMP_B   (AUX_TIMER_T0CFG_TICK_SRC_AUX_COMPB)
#define AUX_TIMER_CFG_TICK_SRC_MCU_EVENT   (AUX_TIMER_T0CFG_TICK_SRC_MCU_EVENT)
#define AUX_TIMER_CFG_TICK_SRC_OBSMUX0   (AUX_TIMER_T0CFG_TICK_SRC_OBSMUX0)
#define AUX_TIMER_CFG_TICK_SRC_OBSMUX1   (AUX_TIMER_T0CFG_TICK_SRC_OBSMUX1)
#define AUX_TIMER_CFG_TICK_SRC_RTC_4KHZ   (AUX_TIMER_T0CFG_TICK_SRC_RTC_4KHZ)
#define AUX_TIMER_CFG_TICK_SRC_RTC_EVENT   (AUX_TIMER_T0CFG_TICK_SRC_RTC_CH2_EV)
#define AUX_TIMER_CFG_TICK_SRC_SMPH_RELEASE   (AUX_TIMER_T0CFG_TICK_SRC_SMPH_AUTOTAKE_DONE)
#define AUX_TIMER_CFG_TICK_SRC_TDCDONE   (AUX_TIMER_T0CFG_TICK_SRC_TDC_DONE)
#define AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT   (AUX_TIMER_T1CFG_TICK_SRC_TIMER0_EV)
#define AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT   (AUX_TIMER_T0CFG_TICK_SRC_TIMER1_EV)
#define AUX_TIMER_PRESCALE_DIV_1   0x00000000
#define AUX_TIMER_PRESCALE_DIV_1028   0x0000000A
#define AUX_TIMER_PRESCALE_DIV_128   0x00000007
#define AUX_TIMER_PRESCALE_DIV_16   0x00000004
#define AUX_TIMER_PRESCALE_DIV_16384   0x0000000E
#define AUX_TIMER_PRESCALE_DIV_2   0x00000001
#define AUX_TIMER_PRESCALE_DIV_2048   0x0000000B
#define AUX_TIMER_PRESCALE_DIV_256   0x00000008
#define AUX_TIMER_PRESCALE_DIV_32   0x00000005
#define AUX_TIMER_PRESCALE_DIV_32768   0x0000000F

Referenced by AUXTimerPrescaleSet().

#define AUX_TIMER_PRESCALE_DIV_4   0x00000002
#define AUX_TIMER_PRESCALE_DIV_4096   0x0000000C
#define AUX_TIMER_PRESCALE_DIV_512   0x00000009
#define AUX_TIMER_PRESCALE_DIV_64   0x00000006
#define AUX_TIMER_PRESCALE_DIV_8   0x00000003
#define AUX_TIMER_PRESCALE_DIV_8192   0x0000000D