Help with LPC1769 ADC

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

Help with LPC1769 ADC

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

I am currently trying to read audio signals to the ADC of lpc1769 however am still to coding this , could anyone enlighten me ? Totally do not understand all the downloaded examples =/

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;
}

This is how I initialized it ,after which I tried to use the read function but tough luck , could any kind soul enlighten me how to

1. Initialize an ADC port
2. Read the ADC port
3. Use the data read and place it into an 8bit value for eg.
4. Probably print out so I can see whats in the digitized value

Thanks and god bless to the kind souls that can enlighten me !
Labels (1)
0 Kudos
2 Replies

337 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Tue Sep 03 11:57:37 MST 2013
You should really get a copy of the User Manual and read at least the section about the ADC.

The "Read the ADC port" part should still set the "START" field in ADCR to some meaningful value (e.g. 001). Now you either should wait for an interrupt (if enabled) or check the ADSTAT register to check if the conversion is done. After this you can read the data from the ADDR0 or ADGDR register.

The examples don't explain what is going on that well - you need the user manual in order to understand how the ADC functions and how to handle this in software. Unfortunately the ADC is one of the blocks that does not have very good documentation.
If I remember correctly, all you need to do is to set the START field to 001 (start conversion now) and then wait for the conversion to be done.

When you ever do things from scratch, pay attention to the "Basic Configuration" section in the chapter of the interface you are using. It is too easy to miss out one of the bits you need to set in the PCON, PCLKSEL or PINSEL registers when initializing a device.

Rob
0 Kudos

337 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Fri Aug 30 17:47:40 MST 2013
Unfortunately I can't be of much help, as I haven't been looking into how to use the ADC yet.
However, this is what I'd do...

1: Get UM10360 if you don't have it already.
2: Download the drivers and examples from http://sw.lpcware.com/ (I prefer using 'git clone http://git.lpcware.com/lpc175x_6x.git')
3: Try building the code from Examples/ADC/Polling and see if it works. If it does, modify it. ;)
4: If you don't like using the NXP drivers, you can always go and 'simplify' the code after you've ensured that it works.

Things you could check...
  The UM10360 (29.3) says "Max 13MHz" - Check that you're not clocking the ADC too fast.
  Did you connect VDDA and VSSA ? (see section 29.4)
  Did you connect VREFP and VREFN ? (see section 29.4)
  Did you set up the ADC before trying to read it; eg the control registers like AD0CR (table 531) ?

I'm not sure if I can come up with more ideas you can check. I hope one of these things can get you unstuck. :)
0 Kudos