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

initialiazation of arm

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

Parents
  • Dear Sir,

    As early stated i didn't went so deeply for testing crystal.
    I checked voltage across crystal and waveform of crystal.It was OK.
    If Agreed the crystal is faulty then the issue is if i program the hex file of old programmer in same IC it works successfully.
    Only if i program the same ic with hex file of my program then i have to touch the probe of oscilloscope to one of crystal pin then it starts working.
    How i can convinced to my senior on this issue?

    I also grounded body of crystal.
    will you please help for sorting out this,

    Thanks in advance,

    Girish

Reply
  • Dear Sir,

    As early stated i didn't went so deeply for testing crystal.
    I checked voltage across crystal and waveform of crystal.It was OK.
    If Agreed the crystal is faulty then the issue is if i program the hex file of old programmer in same IC it works successfully.
    Only if i program the same ic with hex file of my program then i have to touch the probe of oscilloscope to one of crystal pin then it starts working.
    How i can convinced to my senior on this issue?

    I also grounded body of crystal.
    will you please help for sorting out this,

    Thanks in advance,

    Girish

Children
  • I checked voltage across crystal and waveform of crystal.It was OK.
    yes, you said that already, to have "checked voltage across crystal" you have touched it with a scope probe

    With Proper grounding and power traces as this board is of commercial product.
    that is no guarantee there are many shoddy "commercial products" how long are the traces to xtal and burden caps? how long traces to and what are the Vdd decoupling caps?

    Erik

  • Another thing - does your processor always make use of an external oscillator, or does it boot with an internal RC oscillator like 23xx does? In that case - what code do you have that turns on the external oscillator and waits for it to stabilize before it may be connected for use by the core?

    You post code for the PLL (seems to be different PLL settings for the two codes) but the PLL needs input. Is the oscillator spun up correcly before connected?

  • Just show him/her!

    Get him/her to help you: he/she knows you, knows your project, can see your hardware, can probe it him/herself, can see your software, etc, etc - nobody on a forum has any of those advantages!