TMS320F28335 Library  1.0
Documentation
CPU-Timer

Usage of 32-Bit CPU-Timer 0/1/2. Timer will be configured in microseconds.

CPU-Timer 0 and CPU-Timer 1 can be used in user applications. CPU-Timer 2 is reserved for DSP/BIOS. If the application is not using DSP/BIOS, then CPU-Timer 2 can be used in the application.


Code example

#include "global_defines.h" //Include global_defines.h
#include "cpu_timer/cpu_timer.h" //Include module of cpu_timer
#include "general_output/general_output.h" //Include module of general_output
#include "system_controls/system_controls.h" //Include module of system controls
__interrupt void isr(void); //Function prototype for interrupt service routine
void main(void){
int result = 0; //Optional: can be used to check return values of functions
setSystemControls(); //Call setSystemControls() function
result = init_generalOutputPin(GPIO22); //Configure GPIO as general output
result = init_CPUTimer(0, &isr); //Configure CPU-Timer 0 to call function isr on interrupt. Returns result of operation
result = CPUTimer_start(0, 1000000); //Starts CPU-Timer 0 with 1000000 microSec <=> 1 sec. Returns result of operation
while(1){
//Endless loop
}
result = CPUTimer_stop(0); //Stops CPU-Timer 0. Returns result of operation
}
__interrupt void isr(void){ //Changes value on GPIO22 on every interrupt (every second)
static int led_on=0;
if(!led_on){
led_on = 1;
}
else{
led_on = 0;
}
CPUTimer_interruptAck(); //Acknowledgement to get more interrupts
}

Documented C-Code of module:

cpu_timer


Detailed description in Technical Reference Manual:

Technical_Reference_Manual

generalOutputPin_setPinHigh
int16 generalOutputPin_setPinHigh(Uint16 pin)
Set output pin high.
Definition: general_output.c:63
cpu_timer.h
Header file for CPU-Timer module.
init_CPUTimer
int16 init_CPUTimer(Uint16 cpu_timer, void *isr)
Init CPU-Timer 0/1/2.
Definition: cpu_timer.c:27
general_output.h
Header file for General Output module.
CPUTimer_interruptAck
void CPUTimer_interruptAck(void)
Set Acknowledge to receive another interrupt from CPU-Timer.
Definition: cpu_timer.c:171
global_defines.h
Header file for global defines.
init_generalOutputPin
int16 init_generalOutputPin(Uint16 pin)
Configuration of GPIO as general output pin.
Definition: general_output.c:15
setSystemControls
void setSystemControls(void)
Configuration of system control register.
Definition: system_controls.c:13
generalOutputPin_setPinLow
int16 generalOutputPin_setPinLow(Uint16 pin)
Set output pin low.
Definition: general_output.c:88
CPUTimer_start
int16 CPUTimer_start(Uint16 cpu_timer, Uint32 Period)
Start CPU-Timer 0/1/2 || make sure CPU-Timer has been initialized.
Definition: cpu_timer.c:89
system_controls.h
Header file for System Controls module.
CPUTimer_stop
int16 CPUTimer_stop(Uint16 cpu_timer)
Stop CPU-Timer 0/1/2 || make sure CPU-Timer has been initialized.
Definition: cpu_timer.c:152