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

Can' t configure ADC of LPC935!

Hi,

I'm using LPC935 and I want to set the built in AD converter.
I have to use P0.0 pin, so I have written the following code (The pin is configured as input only):

void InitADC()
{

ADCON0 = 0x45; //Enable ADC0 and Interrupt on conversion done
//Single mode
ADMODA = 0x01;
//Freq div
ADMODB = 0x40; //CCLK/3

//Select P00
ADINS = 0x01; //Enable P00 input

EAD = EA = 1; //Enable IRQ


}

The matter is that even I run this piece of code the ADC settings are still the same.
Even if I play step by step, every line of this routine can't make any modificatione in ADC registers.
What's the matter?

Thanx in advance

Parents
  • I've followed your suggestion but the problem stand still: I've created code with "CodeArchitect" but the fact is that every changes in AD registers are not allowed...

    void InizADC(void)
    {
    // configure clock divider
    ADMODB |= 0x40;

    // set adc0 channel pins to input only (disables digital output)
    // channel 1 (P00)
    P0M1 |= 0x01;
    P0M2 &= ~0x01;
    // disable dac0
    ADMODB &= ~0x04;
    // set boundaries
    AD0BH = 0xFF;
    AD0BL = 0x00;
    // use boundary limits for all channels
    ADMODB |= 0x01;
    // configure adc0 and enable (also enables dac0)
    ADCON0 |= 0xC4;

    // set adc1 channel pins to input only (disables digital output)
    // channel 0 P01
    P0M1 |= 0x02;
    P0M2 &= ~0x02;
    // channel 1 p02
    P0M1 |= 0x04;
    P0M2 &= ~0x04;
    // disable dac1
    ADMODB &= ~0x08;
    // set boundaries
    AD1BH = 0xFF;
    AD1BL = 0x00;
    // use boundary limits for all channels
    ADMODB |= 0x02;
    // configure adc1 and enable (also enables dac1)
    ADCON1 |= 0xC4;

    // set isr priority to 0
    IP1 &= 0x7F;
    IP1H &= 0x7F;

    // enable adc interrupt
    EAD = 1;
    }


    Is there something else tha I can do to fix it?

    Thank you

Reply
  • I've followed your suggestion but the problem stand still: I've created code with "CodeArchitect" but the fact is that every changes in AD registers are not allowed...

    void InizADC(void)
    {
    // configure clock divider
    ADMODB |= 0x40;

    // set adc0 channel pins to input only (disables digital output)
    // channel 1 (P00)
    P0M1 |= 0x01;
    P0M2 &= ~0x01;
    // disable dac0
    ADMODB &= ~0x04;
    // set boundaries
    AD0BH = 0xFF;
    AD0BL = 0x00;
    // use boundary limits for all channels
    ADMODB |= 0x01;
    // configure adc0 and enable (also enables dac0)
    ADCON0 |= 0xC4;

    // set adc1 channel pins to input only (disables digital output)
    // channel 0 P01
    P0M1 |= 0x02;
    P0M2 &= ~0x02;
    // channel 1 p02
    P0M1 |= 0x04;
    P0M2 &= ~0x04;
    // disable dac1
    ADMODB &= ~0x08;
    // set boundaries
    AD1BH = 0xFF;
    AD1BL = 0x00;
    // use boundary limits for all channels
    ADMODB |= 0x02;
    // configure adc1 and enable (also enables dac1)
    ADCON1 |= 0xC4;

    // set isr priority to 0
    IP1 &= 0x7F;
    IP1H &= 0x7F;

    // enable adc interrupt
    EAD = 1;
    }


    Is there something else tha I can do to fix it?

    Thank you

Children