Beginner question for timer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Beginner question for timer

527 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MCU on Tue Apr 02 02:53:08 MST 2013
Hi,
I'm beginner for LPC,
I using LPCxpresso LPC1200 Rev B

I want to do a simple program, enable the 32bit timer counter and output the high low in port

So, I need to know how to set up the CT32B0,
I already enable the counter, but I don;t know the system clock speed.
If I not change the CMISS, did the system clock 24MHZ?
So the timer counter will update every 1/24MHZ?

1) Any sample code for it?
If I use the Blinky sample code as a base.
2) did I need to disable all the interrupt?
3) did I need to reset the watch dog?
Labels (1)
0 Kudos
1 Reply

468 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Wed Jul 17 11:34:41 MST 2013
Hi,
I'm beginner for LPC,
I using LPCxpresso LPC1200 Rev B

I want to do a simple program, enable the 32bit timer counter and output the high low in port

So, I need to know how to set up the CT32B0,
I already enable the counter, but I don;t know the system clock speed.


PLACE THIS INSTRUCTION IN YOUR main() FUNCTION, AND THE SET A BREAKPOINT ON IT AND CHECK THE SystemCoreClock VALUE:

SysTick_Config(SystemCoreClock / (uint32_t)1000);



YOU MIGHT ALSO WANT TO LOOK AT THIS SMALL TUTORIAL

http://fjrg76.wordpress.com/2012/11/02/configuring-the-clock-options-for-the-lpc1227/




If I not change the CMISS, did the system clock 24MHZ?
So the timer counter will update every 1/24MHZ?

1) Any sample code for it?

void timer16_Init(void)
{
/* gpio -> timer pins */
LPC_SYSCON->SYSAHBCLKCTRL |= BIT(8);

LPC_IOCON->PIO2_3=(3);

LPC_CT16B1->TCR  = BIT(1);
LPC_CT16B1->CTCR = 0;
LPC_CT16B1->PR   = 45;
LPC_CT16B1->MCR |= BIT(10);  /* reset on MR3 */
LPC_CT16B1->MR3  = 125; /* frecuency */
LPC_CT16B1->MR1  = 50; /*  duty cycle */
LPC_CT16B1->EMR  = (3<<0x06); /* toggle */
LPC_CT16B1->PWMC = BIT(1);

LPC_CT16B1->TCR  = 1;
LPC_CT16B1->EMR  &=~(3<<0x06);
}




If I use the Blinky sample code as a base.
2) did I need to disable all the interrupt?

NO


3) did I need to reset the watch dog?

No, if you set the disable the watchdog when you create your project in LPCXpresso IDE.



0 Kudos