Hi guys...I'm a newbie in ARM7 programming.I have a readymade hardware board of LPC2148.I'm doing a simple blinking action on it.I'm supplying the processor with 12MHz frequency as its processor clock.And i hve read in net somewhere tht each for loop [for(x=0;x<1;x++)] takes 12-13 cycles to execute.So by rough calculation the value of the delay counter should be 1000000 for 1sec delay.But my delay turns out to be 4-5sec. I have deactivated the MAM block and also PLL0 i.e., I'm using the external supplied oscillator as the clock source for the processor. I havn't used the timer module to get the desired delay till now..as i need to brush up the theories behind it first.But whether it is absolutely necessary to use the timer block to produce the 1sec delay?? plz answer my post some one..thanks in advance.My code is given below --
#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 = 0x03; // PLL0 is enabled & connected as the clock source of the microcontroller PLL0CFG = 0x24; // The i/p crystal oscillator frequency is multiplied in the PLL0 block by a fator of 5(=4+1) PLL0FEED == 0xAA; // 0xAA and 0x55 should be feed into this register for the PLL0FEED == 0x55; // changes in PLL0CON and PLL0CFG to take place actively VPBDIV = 0x01; // The Pclk frequency = Fcclk frequecy..not necessary. // by default the GPIO are selacted as legacy ports */ PLL0CON=0x0; // these 4 lins are as given by blink.c.Though the result is nt coming as expected.the above commented out result are my first try to supply the processor with 60MHz clock supply // the PLL is nt connected as the clock source for the processor PLL0FEED=0xAA; PLL0FEED=0x55; VPBDIV=0x00; MAMCR = 0x00; // Any MAM function is disabled..i.e } void delay() { unsigned long int i; for(i=0;i<250000;i++); } // with 12MHZ clock supply the time delay is cmng as 1sec if the delay value is 250000 but it should be 1000000 according to my calculation // in this void main(void) { unsigned long 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 o/p pins. IOCLR1 = 0xFFFFFFFF; while(1) { min_hand++; dword = dword>>16; dword++; dword = dword <<16; IOSET1 |= dword; // IOPIN1 = IOSET1; delay(); if(min_hand /60 == 0) { min_hand=0; delay(); } IOCLR1 = 0xFFFFFFFF; delay(); } }
First of all thank you sir for pointing the right way of posting a query and documenting it.I have done it clearly this time and hope that there will be no problem of understanding.I want to produce a simple blink and wait program where the waiting phase is for 1sec between each blink. I didn't want to use the timer block initially but later after seeing much postings in net i assume that it's impossible to create a 1sec delay without the timer0 block taking into action.So i rewritten the code and posted here..but the problem is after the first LED blinks..i.e., after 00000001,the state remains in that condition for 34 sec(almost) and as soon as the TC is matched with the MR0 value the next state it shows is 00001111 and the TC is resetted and the counting starts again.I havnt waited to see the next state..and i aborted the simulator.Now this is my problem...Plz help me thanx in advance. I'm posting the code again below....