Author Topic: help using DAC in LPC925  (Read 7906 times)

kaitelas

  • Jr. Member
  • **
  • Posts: 1
    • View Profile
help using DAC in LPC925
« on: March 20, 2007, 07:19:35 pm »
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

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Re: help using DAC in LPC925
« Reply #1 on: March 20, 2007, 08:09:10 pm »
repost at 8052.com, that is where it belongs

Erik
erik