Lecture 9
Lecture 9
TM4C123GH GPTM
(n = A or B and x = 0 to 5)
Disable the selected timer by clearing the TnEN bit in the
GPTMCTL register (TIMERx CTL R).
Initialize the GPTMCFG register to set up timer(s) as
16/32-bit timers (TIMERx CFG R).
Configure the TnMR field in the GPTMTnMR
(TIMERx TAMR R) register by writing
0x1 for one-shot mode.
0x2 for periodic mode.
Optionally configure the TnSNAPS, TnWOT, TnMTE, and
TnCDIR bits in the GPTMTnMR (TIMERx TAMR R) register
GPIO_PORTF_DIR_R = 0x0E; /* enable the GPIO pins for the LED (PF3, 2 1) as output */
GPIO_PORTF_DEN_R = 0x0E; /* enable the GPIO pins for digital function */
while(1) {
GPIO_PORTF_DATA_R = 2; /* turn on red LED */
timer0A_delayMs(500); /* TimerA 500 msec delay */
GPIO_PORTF_DATA_R = 0; /* turn off red LED */
timer0A_delayMs(500); /* TimerA 500 msec delay */
}
}
/* multiple of millisecond delay using periodic mode */
void timer0A_delayMs(int ttime){
int i;