lpcware

timer16 counts

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by tbelo on Fri Jan 03 00:56:28 MST 2014
Hi all,

I have used the "selfwakeup" example which uses the TIMER16B0_MAT0.
For my application I need 86400 counts but timer16 can only count 2^16=65536.

Will the PC (prescale counter) do that job or should I use the TIMER32B0_MATx ?

Best regards,
Theodore


Below is the code for Timer16 Driver for the self wake up example.

/* Turn on 16-bit Timer 0 and IOCON, in case it hasn't already been turned on */
LPC_SYSCON->SYSAHBCLKCTRL|=(1<<7) | (1<<16);

/* Disable and Reset Timer */
LPC_TMR16B0->TCR = (1<<1);

/* Setup Timer prescaler */
LPC_TMR16B0->PR=prescaler;

/* Match Reg 0: Interrupt Disabled, Reset Enabled, Do not Stop */
LPC_TMR16B0->MCR =(1<<1);

/* Match Reg 0 value */
LPC_TMR16B0->MR0 =match;

/* External Match; Clear output and set on match */
LPC_TMR16B0->EMR =(0x2<<4);

/* Enable MAT0 onto IOCON: CT16BO_MAT0: PIO0_8 */
LPC_IOCON->PIO0_8 = (2<<0);

Outcomes