/* This program drives the speaker on the EduPad board * at 440 Hz using WTIMER0A in PWM mode. * * Built and tested with Keil MDK-ARM v5.24a and TM4C_DFP v1.1.0 */ #include "TM4C123.h" int main(void) { SYSCTL->RCGCGPIO |= 0x04; // enable clock to GPIOC SYSCTL->RCGCWTIMER |= 0x01; // enable clock to Timer Block 0 // enable PORTC 4 as output GPIOC->AMSEL &= ~0x10; // disable analog function of PORTC 4 GPIOC->DIR |= 0x10; // set PORTC 4 as output pins GPIOC->DEN |= 0x10; // set PORTC 4 as digital pins GPIOC->AFSEL |= 0x10; // enable alternate function GPIOC->PCTL &= ~0x000F0000; // clear alternate function for PORTC 4 GPIOC->PCTL |= 0x00070000; // set PORTC 4 alternate function to WTIMER WTIMER0->CTL &= ~1; // disable WTIMER0A during setup WTIMER0->CFG = 4; // configure as 32-bit timer mode WTIMER0->TAMR = 0x0A; // down-count, PWM-periodic mode WTIMER0->TAILR = 113635; // set frequency to 440 Hz WTIMER0->TAMATCHR = 56818; // set duty cycle to 50% WTIMER0->CTL |= 1; // enable WTIMER0A while(1) { } }