help using DAC in LPC925

Started by kaitelas, March 20, 2007, 11:19:35 AM

Previous topic - Next topic

kaitelas

Hello,
I'm trying to use the DAC as well as the AD in the LPC925 at the same time but I'm having some trouble initializing both of them at the same time. I can get AD1 working fine, but i can't get the DAC to work. I tried using Code Architect but it gives me some strange variables that Keil does not know what it is.
This is what code architect gives me:
void adc_init (void)
{

  // set dac1 pin to input only (disables digital output)
  P2M1 |= 0x01;
  P2M2 &= ~0x01;
  // init dac1 value to zero
  AD0DAT3 = 0x00;
  // enable dac1 output
  ADMODB |= 0x04;
  // enable adc1 (also enables dac1)
  ADCON0 |= 0x04;

}

First there is no P2 in the LPC925, so I'm guessing it meant to say P0 instead. Also, there is no AD0DAT3, i think it meant to say AD1DAT3. It also calls for ADCON0 but there is no ADCON0 in the LPC925, there is a ADCON1.
So here is my code Init code for the first two A/Ds (ADC10/P0.1 and ADC11/P0.2) and the DAC1/P.04 active at the same time. Can anyone tell me if this is correct.

void ADC_Init(void)
{
   // configure clock divider
   ADMODB |= 0x40;
   
   // set adc1 channel pin to input only (disables digital output)
   // channel 0
   P0M1 |= 0x02;
   P0M2 &= ~0x02;
   
   P0M1 |= 0x04;
   P0M2 &= ~0x04;

   P0M1 |= 0x10;
   P0M2 &= ~0x10;

   // init dac1 value to zero
   AD1DAT3 = 0x00;
   // enable dac1 output
   ADMODB |= 0x04;
   // configure adc1 and enable (also enables dac1)
   ADCON1 |= 0x44;
   
   // set isr priority to 0
   IP1 &= 0x7F;
   IP1H &= 0x7F;
   
   // enable adc interrupt
   EAD = 1;
}

Or at least where i'm making a mistake since it doesn't work. Also, if need it, i'm using the internal RC clock.
Any helps is greatly appreciated.


erikm

repost at 8052.com, that is where it belongs

Erik
erik