We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
i have proble with generating 1Sec delay..coe is below ..i have used 12Mhz crystal
#include "LPC21xx.H" void delay(void); void init_clock() { PLLCON=0x0; // the PLL is nt connected as the clock source for the processor PLLFEED=0xAA; PLLFEED=0x55; VPBDIV=0x00;//Pclk =12Mhz MAMCR = 0x00; // Any MAM function is disabled..i.e } /* the prescaler register is set to have the value 9999(=0x270f),so that the TC register is incremented after every 10000 clock cycles.So it should count upto 1200(=0x4B0) for 1sec delay with 12MHz supply as the Pclk. */ void delay() { T0PR = 0x0000270F; T0MR0 =0x000004B0 ; T0TCR =0x00000002; // the timer0 is activated T0TCR =0x00000001; // 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 it is again activated while the next delay is called } // with 12MHZ clock supply the time delay is cmng as 1sec if the delay value is 250000 // in this void main(void) { unsigned long dword=0xffffffff; unsigned char min_hand=0; init_clock(); PINSEL0 &= 0x00000000; // all the pins of port1 are selected as GPIO IODIR0 = 0xFFFFFFFF; // the pin 16 to 23 are configuered as the o/p pins. // IOCLR1 = 0xFFFFFFFF; while(1) { IO0CLR=dword; delay(); IO0SET=dword ; delay(); } }
www.8052.com/.../120313 (not specific to 8052)