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.
Dear All,
I am working my project of led Blinking.The controller used is arm7 LPC2214.Crystal is 11.0592mhz. Which works fine but only one problem is, to make it working i have to touch one of my Oscilloscope probe to crystal of controller.Then it start working.Also works well in keil debugger(internal) and on proteus.So please help me to solve this problem. The source code is as follows,
#include <lpc22xx.h> #include <stdio.h> #define VREF 3 #define Beep 0x00001000 #define LED1 0x00000800 #define LED2 0x00000400 #define LED3 0x00000200 #define LED4 0x00000100 #define CE 0x00000001 #define OE 0x00000002 #define WE 0x08000000 #define low IO0CLR = LED1 ; \ IO0CLR = LED2 ; \ IO0CLR = Beep ; #define hig IO0SET = LED1 ; \ IO0SET = LED2 ; \ IO0SET = Beep ; unsigned int val; unsigned long Fosc = 11059200; unsigned long Fcclk = 0; unsigned long Fcco = 0; unsigned long Fpclk = 0 ; void TargetResetInit(void) { Fcclk = Fosc * 4; Fcco = Fcclk * 4; Fpclk = (Fcclk / 4) * 1 ; MEMMAP = 0x2; //remap PLLCON = 3; if ((Fpclk / (Fcclk / 4)) == 1) VPBDIV = 0x10; else if ((Fpclk / (Fcclk / 4))== 2) VPBDIV = 0x11; else if ((Fpclk / (Fcclk / 4)) == 4) VPBDIV = 1; if ((Fcco / Fcclk) == 2) PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5); else if ((Fcco / Fcclk) == 4) PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5); else if ((Fcco / Fcclk) == 8) PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5); else if ((Fcco / Fcclk) == 16) PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5); PLLFEED = 0xaa; PLLFEED = 0x55; while((PLLSTAT & (1 << 10)) == 0); PLLCON = 3; PLLFEED = 0xaa; PLLFEED = 0x55; MAMCR = 0; if( Fcclk < 20000000) MAMTIM = 1; else if ( Fcclk < 40000000) MAMTIM = 2; else MAMTIM = 3; MAMCR = 2; VICIntEnClr = 0xffffffff; VICVectAddr = 0; VICIntSelect = 0; } void Delay (unsigned long a) { while (--a!=0); } void ledInit(void) { IO2DIR = 0xFFFFFFFF; IO2SET = 0; IO1PIN = 0x00000000; IO1DIR |= CE; IO1DIR |= OE; IODIR1 |= CE; IODIR1 |= OE; IO1SET |= CE; IO1SET |= OE; IO3DIR = 0xFFFFFFFF; IO3SET = WE; IO0DIR = LED1; IO0SET |= LED1; } static void ledOn(int led){ IO0CLR = led; } static void ledOff(int led){ IO0SET = led; } void delay(int d){ for(; d; --d); } int main(void) { ledInit(); TargetResetInit(); ledOn(LED2); ledInit(); while(1) { ledOn(LED1); delay(20000*8); delay(20000*8); delay(20000*8); delay(20000*8); delay(20000*8); ledOff(LED1); delay(20000*8); delay(20000*8); delay(20000*8); delay(20000*8); delay(20000*8); } }
Thanks & regards, Girish
Dear sir,
enable main Oscillator
#ifdef __DEBUG _WDWORD(0xE01FC080, 0x00000001); // PLLCON _WDWORD(0xE01FC08C, 0x000000AA); // PLLFEED _WDWORD(0xE01FC08C, 0x00000055); // PLLFEED // Disable PLL _WDWORD(0xE01FC080, 0x00000000); // PLLCON _WDWORD(0xE01FC08C, 0x000000AA); // PLLFEED _WDWORD(0xE01FC08C, 0x00000055); // PLLFEED _sleep_ (100); // Wait for PLL disable _WDWORD(0xE01FC10C, 0x00000001); // CLKSRCSEL: main osc _WDWORD(0xE01FC1A0, 0x00000020); // SCS: Enable main osc _sleep_ (100); // Wait for osc to stabilize //_WDWORD(0xE01FC084, 0x0000000E); // PLLCFG for 12mhz->60mhz _sleep_ (1000); // Wait #endif .
"Changed Crystal, Change Capacitor across it (used 33pf ,old was 20p) , Resistor of 1 Mega Ohm used across crystal, Grounded Body of crystal by wire,"
User manual for LPC2214 does not specify any resistor if a fundamental crystal is used. Do you use a fundamental crystal, or overtone crystal?
Requirement for a fundamental crystal is also that Cp is <= 7pF - does your crystal fulfill this?
You mention old capacitors was 20p and now is 30p - but without mentioning crystal load capacitance or series reistance. So are the capacitors correct according to the table in the processor user manual, for the given frequency range and load capacitance?
It isn't clear from your posts if your reset signal is asserted for at least 10ms after power-on.
Your posted code contains:
_WDWORD(0xE01FC10C, 0x00000001); // CLKSRCSEL: main osc _WDWORD(0xE01FC1A0, 0x00000020); // SCS: Enable main osc
1 - Why magic numbers instead of labeling the registers. Is it funny to read code containing 0xE01FC10C?
2 - You say you have LPC2214 - but it doesn't seem to have any CLKSRCSEL register or any register at address 0xE01FC10C. It is available on LPC23xx (and maybe other families).
3 - You say you have LPC2214, and sets bit 0x20 in SCS. But that bit doesn't seem to be defined. It is OSCEN on LPC23xx (and maybe other families).
Are you doing cut-and-paste programming from whatever sources you find all over the net? Or does the following sentence not only mix up milli/Mega for crystal frequency, but also used processor: "The controller used is arm7 LPC2214.Crystal is 11.0592mhz."
Hi,
As i said in my last post, yes i used numbers because the lpc 2214 controller doesn’t have register like CLKSRCSEL like you have in 23x or 21x series, also not have the definition for it in lpc2214.h header file and in startup’s file. As you said to enable the main oscillator i used code which is given in keil website. Which is not explained in detailed in user manual . So it was not clear for me also about Enabling the main oscillator. And about sentence "The controller used is arm7 LPC2214.Crystal is 11.0592mhz." it is for explanation in short for my controller and peripheral. And about me i worked on lpc2148 also working on embedded systems from last 4 years. But first time i faced such situation where not much choice for major change in hardware as old code is well running & proven. So write post for my difficulties and problem. It is clear that there is issue initialization code for oscillator. But struggling to sort it out. So i request you to Please help me to sort it out,
Thanks in advance,
Girish