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

LPC2148 Delay

Hii all.This time I'm struck with the ADC problem.My code is running successfully.I'm using a ready-made board of LPC2148 which has a potentiometer connected with its pin 13 of the MCU i.e., AD0.1.The potentiometer is used to supply various analog voltage to the pin 13.
Now the problems are --
1:->the result of the ADC conversion of a predefined voltage is not coming in the AD0DR1 register..but its coming in the global result register i.e., in the AD0GDR.
I dont know why this is happening
2:->I'm sending the result of ADC conversion to P1.16 to P1.23 which has LED connection to it..and the pattern of LED blinking is rightfully going with the ADC result.If i power up the development board with a predefined analog volatage(say 2V) the result is coming accordingly..but now if i change the value of the potentiometer(say to 3V) then the new result isn't coming..and the result of 2V continues to blink at the LEDs.If I reset the board or switch on the board after switching it off then the right value of 3V is showing up..what should i do

  • I'm posting the part of my code which handles the above functions.the GPIOInit() function below makes the LEDs to blink as well as checks for any new data in the Global Data Register.As well as the ADC_initialization code is also given below
    Pclk -> 60MHz
    VPBCLK -> 60MHz
    ADCCLK -> 4MHz.
    ADC initializaion code--

    void init_ADC_mod()
    {
                            // Initial ADC8 (ADCR=0x01210601)
    
            PINSEL0 |= 0x01000000;               // Select AD0.1 Pin Connect to pin13
            AD0CR   &= 0x00000000;           // Clear All Bit Control
            AD0CR   |= 0x00000002;           // Select ADC = AD0.1 rest all are treated as simple GPIO
            AD0CR   |= 0x00000E00;           // ADC Clock = VBP(PCLK) / 15(=14+1) = 4MHz
            AD0CR   |= 0x00000000;           // No Busrt..i.e., Burst=0...soft-ware controlled
            AD0CR   &= 0xFFF1FFFF;           // CLKS = 000 = 10Bit : 11 Cycle Clock Conversion
            AD0CR   |= 0x00200000;           // PDN = 1 = Active ADC Module
            AD0CR   &= 0xFF3FFFFF;           // TEST[1:0] = 00 = Normal Mode
            AD0CR   &= 0xF7FFFFFF;           // EDGE = 0 = Conversion on Falling Edge
            AD0CR   |= 0x01000000;           // START = 001 = Start Conversion Now
    
    }
    

    GPIOInit() function --

    void GPIOInit( DWORD PortType,DWORD ADC_DATA)
    {
            DWORD DATA;
            PortType=0;
    
                    SCS = 0;                        /* set GPIOx to use regular I/O */
                    IODIR1 = 0x00FF0000;    /* P1.16..23 defined as Outputs..while the rest are input */
                    //      IOSET1 = ADC_DATA;              // the first byte of the data is sent to the o/p
                    while(1)
                    {
                            IOPIN1 = 0x00000000;
                            IOCLR1 = 0x00FF0000;            /* turn off LEDs */
                            delay();
                            DATA = ADC_DATA;                //      ADC_DATA_LAST = (ADC_DATA>>8) & 0x00030000;
                            DATA = (DATA<<16) & 0x03FF0000; // only the 10 result bit remains
                            IOSET1 = DATA;
                            delay();
                            IOCLR1 = 0x00FF0000;
                            delay();
                            DATA = (DATA>>8) & 0x00FF0000;
                            IOSET1 = DATA;
                            delay();
                            value1=AD0GDR;  // the next value of ADC(if the i/p has changed already) is stored in value1
                            if(value1!=ADC_DATA) // this is checked with the previous value stored in ADC_DATA
                            {
                                    //      if(value1 & 0x0000FFC0)
                                            ADC_DATA=value1;        // if they are unequal ADC_DATA gets the new value.
                            }
        }
        return;
    }
    

  • TO EVERYBODY
    I HAVE MISTAKENLY NAMED THIS THREAD AS LPC2148 DELAY..WHILE IT IS RELATED TO THE ADC PROBLEM.I HAVE STARTED A NEW THREAD BY THE NAME LPC2148 ADC.PLZ REPLY TO THAT THREAD NOT THIS ONE.I'M EXTREAMLY SORRY FOR THIS NEGLIGENCY FROM MY PART.