Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | LPC2000 | LPC2148 Delay Timing

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

LPC2148 Delay Timing - kaushikraja1986 - Nov 3 12:33:44 2009

Hi all I'm a newbie in LPC2148 programming.I'm doing a simple blink and wait programming with the waiting phase between each blink to be 1sec.But inspite of my all efforts the result is not coming as expected.I'm posting below my code.Plz help me someone.The code is well documented..i hope there will be no problem in understanding it.Thanks in advance---

/* My primary aim is to blink the LEDs connected to pin1.16-pin1.23 in a pattern 00000000,00000001,00000010...
and so on with an interval of 1sec between each blinking.Thus measuring 60seconds i.e, 1min.*/
#include "LPC214x.H"
/* Fosc = external supplied crystal frequency
Fcclk = Processor clock or o/p of PLL0
Pclk = The VPB clock frquency.The o/p of the VPB driver
Fcco = the frequency of the PLL current controlled oscillator */
void init_clock()
{

PLL0CON=0x0; // the PLL is nt connected as the clock source for the processor
PLL0FEED=0xAA;
PLL0FEED=0x55;
VPBDIV=0x01; // the VPB clock is same as that of the processor clock.
MAMCR = 0x00; // Any MAM function is disabled.
}

/* This is the delay block where the timer0 register are configuered to count upto a certain
value so that 1sec delay is produced.After each such case the timer block is deactivated
and agin when the delay() function will be called 0it will be activated and configuered to
produce 1sec delay.

the prescaler register is set to have the value 9999(=0x270F),so that the TC register is
increased after every 10000 clock cycles.So it should count upto 1200(=0x4B0) for
1sec delay since the supply is 12MHz i.e., 12,000,000 clocks per second.Hence I have put
the value 1200MHz(=0x4B0) in MR0,which is compared with the TC and as soon as the match
happens the Timer counter is being reset..and along with the timer block is deactivated.
*/
void delay()
{
unsigned long check_value = 0x000004B0;
T0PR = 0x0000270F;
T0MR0 = 0x000004B0 ;
T0TCR = 0x01; // the timer0 is activated
while(T0TC != T0MR0);
T0MCR = 0x00000002; // Timer Counter will be in reset condition if the match between the MR0 and TC happens.

T0TCR = 0x02; /* when the match happens the Timer0 is resetted and deactivated and it is
again activated while the next delay is called */

}

void main(void)
{
unsigned long count,dword=0x00000000;
unsigned char min_hand=0;
init_clock();
PINSEL1 &= 0x00000000; // all the pins of port1 are selected as GPIO
IODIR1 = 0x00FF0000; // the pin 16 to 23 are configuered as the output pins.
IOCLR1 = 0xFFFFFFFF;
while(1)
{
min_hand++;
dword++;
count = dword;
IOSET1 |= (dword<<16);
dword = count;
delay();
if(min_hand > 60)
{
min_hand=0;
delay();
}
IOCLR1 = 0xFFFFFFFF;
delay();
}
}

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )


Re: LPC2148 Delay Timing - rtstofer - Nov 3 13:09:58 2009



--- In l...@yahoogroups.com, "kaushikraja1986" wrote:
>
> Hi all I'm a newbie in LPC2148 programming.I'm doing a simple blink and wait programming with the waiting phase between each blink to be 1sec.But inspite of my all efforts the result is not coming as expected.I'm posting below my code.Plz help me someone.The code is well documented..i hope there will be no problem in understanding it.Thanks in advance---
The corrected code I sent you last week is known to work.

On the off chance you can't receive attachments, I have posted it to the Files folder as ARM2148Timer.zip. I'll delete it in a couple of days.

One thing that isn't clear to me is what toolchain you are using and whether you have a startup file. You originally posted to the Keil forums and I have no capability to work in that environment.

However, the code as previously emailed will work. I tested it with a LPC-P2148 prototype board http://www.sparkfun.com/commerce/product_info.php?products_id=545

Richard

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )