This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1343 Timer

Hi dears ,

I want to write a program to blink an LED each 1 second. I've wrote below code but after loading into the MCU, it does not work at all. Would you let me know how can I do it, please ?
<
#include "LPC13xx.h"
#define PRESCALE 60000 ;

void delayMS(unsigned int milliseconds);
void initTimer0();

int main()
{

LPC_SYSCON->SYSAHBCLKCTRL = (1<<7); initTimer0(); LPC_GPIO0->DIR |= (1<<3) |(1<<4); LPC_GPIO0->DATA = 0x0;

while(1) { LPC_GPIO0->DATA |= (1<<3);

LPC_GPIO0->DATA |= (1<<3); delayMS(500); LPC_GPIO0->DATA &= ~(1<<3); delayMS(500); LPC_TMR16B0->TCR = 0x0; //disable counter }
}

void initTimer0()
{ //LPC_TMR16B0->CTCR = 0x0; LPC_TMR16B0->PR = PRESCALE-1; LPC_TMR16B0->TCR = 0x02;//reset timer

}

void delayMS(unsigned int milliseconds)
{ LPC_TMR16B0->TCR = 0x02;//reset timer LPC_TMR16B0->TCR = 0x01;//set timer while(LPC_TMR16B0->TC < milliseconds); LPC_TMR16B0->TCR = 0; //disable counter

}>

Parents
  • The documentation for the processor has a clear description of how to configure the PLL, and the PCLK. It's way better if you ask specific questions based on specific problems you have to understand that text.

    Next thing - you have not made any reference to what doesn't work for you. What you think should happen. What actually happens. What you have tried to do to figure out the difference between expectation and reality.

Reply
  • The documentation for the processor has a clear description of how to configure the PLL, and the PCLK. It's way better if you ask specific questions based on specific problems you have to understand that text.

    Next thing - you have not made any reference to what doesn't work for you. What you think should happen. What actually happens. What you have tried to do to figure out the difference between expectation and reality.

Children