/* Sound the speaker at 440Hz * * The speaker is connected to P5.6 - TA2.1. * CPU clock 3 MHz. * * Built and tested with MSP432P401R Rev. C, Keil MDK-ARM v5.24a and MSP432P4xx_DFP v3.1.0 */ #include "msp.h" void delayMs(int n); int main(void) { /* initialize Timer_A2.1 to do output compare */ TIMER_A2->CTL = 0x0211; /* SMCLK, ID=/1, up mode, TA clear */ TIMER_A2->EX0 = 0; /* IDEX = /1 */ TIMER_A2->CCTL[1] = 0x0060; /* set/reset mode */ TIMER_A2->CCR[0] = 6817; /* for 440 */ TIMER_A2->CCR[1] = 3408; P5->SEL1 &= ~0x40; /* configure P5.6 as TA2.1 output */ P5->SEL0 |= 0x40; P5->DIR |= 0x40; for (;;) { } }