AnsweredAssumed Answered

LPC54102, LPCOPen, LCPXpresso demo code Simple timer

Question asked by Chris ONeill on Mar 6, 2017
Latest reply on Mar 10, 2017 by Chris ONeill

Using OM13077 eval board,  I want to output a square wave using Timer0 match register 0, toggle pin on match.

Anything missing here?

 

       int loop = 1; /* Prevents unreachable statement warning */

       uint32_t timerBaseClock;

 

       SystemCoreClockUpdate();

       Board_Init();

 

       /* Initialize Timer 0 */

       Chip_TIMER_Init(LPC_TIMER0);

 

       /* Setup prescale value on Timer 0 to PCLK */

       Chip_TIMER_PrescaleSet(LPC_TIMER0, 0);

 

       /* Reset timer */

       Chip_TIMER_Reset(LPC_TIMER0);

 

       /* Get rate of timer base clock */

       timerBaseClock = Chip_Clock_GetAsyncSyscon_ClockRate();

 

       /* Setup Timer 0 for a match every 1s */

       Chip_TIMER_SetMatch(LPC_TIMER0, 0, (timerBaseClock / TICKRATE_HZ1));

 

       /* Setup timer to restart when match occurs */

       Chip_TIMER_ResetOnMatchEnable(LPC_TIMER0, 0);

 

       /* Map P1.16 as MAT0 pin */

       Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 16, (IOCON_FUNC3 | IOCON_DIGITAL_EN | IOCON_INPFILT_OFF));

 

       /* Sets external match control (MATn.matchnum) pin control */

       Chip_TIMER_ExtMatchControlSet(LPC_TIMER0, 0, TIMER_EXTMATCH_TOGGLE, 0);

 

       /* Start timer */

       Chip_TIMER_Enable(LPC_TIMER0);

 

       while (loop) {

       }

 

       return 0;

Outcomes