Help with LPC1769 ADC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with LPC1769 ADC

1,826 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nelling on Mon Aug 26 09:17:24 MST 2013
Hi all,

Could any kind souls show me the way to

1. Properly initalise an ADC port
2. Read the ADC port
3. Transfer the digitse singal to a 8bit value for eg
4. print the value

Thanks and god bless !
0 Kudos
Reply
8 Replies

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Getdan35 on Mon Nov 04 10:36:10 MST 2013
How did you get it working Nelling?

Dan
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nelling on Thu Aug 29 08:46:16 MST 2013
Thanks guys , I found a better way already  :)
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by usb10185 on Mon Aug 26 13:08:59 MST 2013
Hi,

There is also a detailed AN with code for the LPC176x ADC - http://www.lpcware.com/content/nxpfile/an10974-lpc176x175x-12-bit-adc-design-guidelines

Thanks,
Ken
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nelling on Mon Aug 26 09:56:21 MST 2013
Yup it is from some samples , I am planning to use this to read an audio input and then do some processing if possible then output it via DAC. Will continue again tomorrow , its 1AM here thanks  :bigsmile:
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nelling on Mon Aug 26 09:53:44 MST 2013
Yup it is from some samples , ran around the net and they end up to about the same so I extracted these to slowly build it up. I am totally new to ADC so its confusing compared to just using GPIOs. I am planning to use it to read audio input and perhaps output it via the DAC. I guess I will look into this again tomorrow, its 1am here and there is school tomorrow got to sleep, thanks  :bigsmile:
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Mon Aug 26 09:41:38 MST 2013
Have you had a look into user manual of LPC1769?
Chapter 29.5.2 (page 578).
There your find the bit DONE (=ADC_DONE) and a description, what it is doing/meaning.
ADC_DONE itself is perhaps defined in some header file, which you have not included.
Is your code from one of the code sample bundles?
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nelling on Mon Aug 26 09:34:32 MST 2013
Hi Martin,

Thanks for the prompt reply, I have tried to initialize the ADC port by using:

void ADCInit( uint32_t ADC_Clk )
{
  /* Enable CLOCK into ADC controller */
  LPC_SC->PCONP |= (1 << 12);
  LPC_PINCON->PINSEL1 |= (1<<14); //P0.23 is connected to AD0.0
  LPC_PINCON->PINMODE1 |= (1<<15); //No pullups/downs

  /* By default, the PCLKSELx value is zero, thus, the PCLK for
  all the peripherals is 1/4 of the SystemFrequency. */
  /* Bit 24~25 is for ADC */

  LPC_ADC->ADCR = (1<<21)|(0<<8); //Turn on ADC

  return;
}




Then I am stuck to :

uint32_t ADCRead( uint8_t channelNum )
{

uint32_t regVal, ADC_Data;

  /* channel number is 0 through 7 */

  LPC_ADC->ADCR &= 0xFFFFFF00;
  LPC_ADC->ADCR |= (1 << 24) | (1 << channelNum);
                /* switch channel,start A/D convert */

  while ( 1 )            /* wait until end of A/D convert */
  {
    regVal = LPC_ADC->ADGDR;
    /* read result of A/D conversion */
    if ( regVal & [color=#f00]ADC_DONE[/color] )
    {
      break;
    }
  }

  LPC_ADC->ADCR &= 0xF8FFFFFF;    /* stop ADC now */
  if ( regVal & [color=#f00]ADC_OVERRUN[/color] )    /* save data when it's not overrun, otherwise, return zero */
  {
    return ( 0 );
  }
  ADC_Data = ( regVal >> 4 ) & 0xFFF;
  return ( ADC_Data );    /* return A/D conversion value */

}



The red part were not found , or do I need to initalise interrupts too ?

am so confuse  :~
0 Kudos
Reply

1,774 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Mon Aug 26 09:23:39 MST 2013
Hello Nelling,

have you already had a look into the User Manual of LPC1769 into chapter for ADC?
(http://www.lpcware.com/content/nxpfile/lpc17xx-user-manual)
Have you had a look into one of the various Sample Code Bundles for ADC example source code?
(http://www.lpcware.com/node/11538/129 under "Software")

Best regards,

Martin
0 Kudos
Reply