EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

LPC2138 ADC

Started by stiffsoft June 2, 2005
Hello,
Does anyone have any C code that actually reads the MCB2130
hardware ADC on AIN1 (the potentiometer tied to P0.28) they would be
willing to share? I have tried the Keil code, the Hitex example
code, manipulating bit values, etc., for most of 2 days and cannot
get ADC to return a value that I can display via COM1 on the
MCB2130. The code I have been exploring uses hardware continuous
conversions rather that software interrupt driven conversions. I
really thought the hardware conversion would be easier to implement
than the software.
I verified that the voltage varies at P0.28 with a DMM when I
adjust the pot, but I get nothing but 0 from AD0DR.
I contacted Keil via telephone and didn't get much help (other
than suggesting I run it in the simulator -- more stuff to learn).
I also sent my source code to their support center, but have not
received a response.
Any suggestions (or simple code hints) will be greatly
appreciated.

Steve Stiff


An Engineer's Guide to the LPC2100 Series

--- In lpc2000@lpc2..., "stiffsoft" <stiffsoft@s...> wrote:
> Hello,
> Does anyone have any C code that actually reads the MCB2130
> hardware ADC on AIN1 (the potentiometer tied to P0.28) they would be
> willing to share? I have tried the Keil code, the Hitex example
> code, manipulating bit values, etc., for most of 2 days and cannot
> get ADC to return a value that I can display via COM1 on the
> MCB2130. The code I have been exploring uses hardware continuous
> conversions rather that software interrupt driven conversions. I
> really thought the hardware conversion would be easier to implement
> than the software.
> I verified that the voltage varies at P0.28 with a DMM when I
> adjust the pot, but I get nothing but 0 from AD0DR.
> I contacted Keil via telephone and didn't get much help (other
> than suggesting I run it in the simulator -- more stuff to learn).
> I also sent my source code to their support center, but have not
> received a response.
> Any suggestions (or simple code hints) will be greatly
> appreciated.
>
> Steve Stiff

Have you made sure that the J2 jumper is set? Also make sure that you
use the lpc213x.h instead of the lpc21xx.h
I'm using the following code as a small example:

AD0CR |= 0x01200000; /* Start A/D Conversion */
do {
val = AD0DR; /* Read A/D Data Register */
} while ((val & 0x80000000) == 0); /* Wait for end of A/D
Conversion */
AD0CR &= ~0x01000000; /* Stop A/D Conversion */

Is this the same as you have?

Best Regards
Sen Hansen



There will be two jumpesr J11 and J2 to make the internal ADC to
get the input VIN in MCB2130.

regards
bala

On Thu, 02 Jun 2005 soren_t_hansen wrote :
>--- In lpc2000@lpc2..., "stiffsoft" <stiffsoft@s...> wrote:
>> Hello,
>> Does anyone have any C code that actually reads the MCB2130
>> hardware ADC on AIN1 (the potentiometer tied to P0.28) they would be
>> willing to share? I have tried the Keil code, the Hitex example
>> code, manipulating bit values, etc., for most of 2 days and cannot
>> get ADC to return a value that I can display via COM1 on the
>> MCB2130. The code I have been exploring uses hardware continuous
>> conversions rather that software interrupt driven conversions. I
>> really thought the hardware conversion would be easier to implement
>> than the software.
>> I verified that the voltage varies at P0.28 with a DMM when I
>> adjust the pot, but I get nothing but 0 from AD0DR.
>> I contacted Keil via telephone and didn't get much help (other
>> than suggesting I run it in the simulator -- more stuff to learn).
>> I also sent my source code to their support center, but have not
>> received a response.
>> Any suggestions (or simple code hints) will be greatly
>> appreciated.
>>
>> Steve Stiff
>Have you made sure that the J2 jumper is set? Also make sure that you
>use the lpc213x.h instead of the lpc21xx.h
>I'm using the following code as a small example:
>AD0CR |= 0x01200000; /* Start A/D Conversion */
> do {
> val = AD0DR; /* Read A/D Data Register */
> } while ((val & 0x80000000) == 0); /* Wait for end of A/D
>Conversion */
> AD0CR &= ~0x01000000; /* Stop A/D Conversion */
>Is this the same as you have?
>Best Regards
>Sen Hansen
>Yahoo! Groups Links
>To br> >.
>




Bala:
My apologies and thanks for your response. Both jumpers are in. I
finally got the ADC to work by doing a complete AD0CR setting with
start, waited for the done, read the value, and I was in business.
Regards,
Steve
--- In lpc2000@lpc2..., "balakumar chinuswamy"
<cbalakumarbe@r...> wrote:
>
> There will be two jumpesr J11 and J2 to make the internal ADC to
> get the input VIN in MCB2130.
>
> regards
> bala
>
> On Thu, 02 Jun 2005 soren_t_hansen wrote :
> >--- In lpc2000@lpc2..., "stiffsoft" <stiffsoft@s...>
wrote:
> >> Hello,
> >> Does anyone have any C code that actually reads the MCB2130
> >> hardware ADC on AIN1 (the potentiometer tied to P0.28) they
would be
> >> willing to share? I have tried the Keil code, the Hitex example
> >> code, manipulating bit values, etc., for most of 2 days and
cannot
> >> get ADC to return a value that I can display via COM1 on the
> >> MCB2130. The code I have been exploring uses hardware
continuous
> >> conversions rather that software interrupt driven conversions.
I
> >> really thought the hardware conversion would be easier to
implement
> >> than the software.
> >> I verified that the voltage varies at P0.28 with a DMM when I
> >> adjust the pot, but I get nothing but 0 from AD0DR.
> >> I contacted Keil via telephone and didn't get much help
(other
> >> than suggesting I run it in the simulator -- more stuff to
learn).
> >> I also sent my source code to their support center, but have not
> >> received a response.
> >> Any suggestions (or simple code hints) will be greatly
> >> appreciated.
> >>
> >> Steve Stiff
> >Have you made sure that the J2 jumper is set? Also make sure that
you
> >use the lpc213x.h instead of the lpc21xx.h
> >I'm using the following code as a small example:
> >AD0CR |= 0x01200000; /* Start A/D Conversion
*/
> > do {
> > val = AD0DR; /* Read A/D Data
Register */
> > } while ((val & 0x80000000) == 0); /* Wait for end of A/D
> >Conversion */
> > AD0CR &= ~0x01000000; /* Stop A/D
Conversion */
> >Is this the same as you have?
> >Best Regards
> >Sen Hansen
> >Yahoo! Groups Links
> >To br> > >.
> >


Soren:
My apologies and thanks for your response. I finally got the ADC to
work by doing a complete AD0CR setting with start, waited for the
done, read the value, and I was in business.
Regards,
Steve
--- In lpc2000@lpc2..., "soren_t_hansen"
<soren_t_hansen@y...> wrote:
> --- In lpc2000@lpc2..., "stiffsoft" <stiffsoft@s...> wrote:
> > Hello,
> > Does anyone have any C code that actually reads the MCB2130
> > hardware ADC on AIN1 (the potentiometer tied to P0.28) they
would be
> > willing to share? I have tried the Keil code, the Hitex example
> > code, manipulating bit values, etc., for most of 2 days and
cannot
> > get ADC to return a value that I can display via COM1 on the
> > MCB2130. The code I have been exploring uses hardware
continuous
> > conversions rather that software interrupt driven conversions.
I
> > really thought the hardware conversion would be easier to
implement
> > than the software.
> > I verified that the voltage varies at P0.28 with a DMM when I
> > adjust the pot, but I get nothing but 0 from AD0DR.
> > I contacted Keil via telephone and didn't get much help (other
> > than suggesting I run it in the simulator -- more stuff to
learn).
> > I also sent my source code to their support center, but have not
> > received a response.
> > Any suggestions (or simple code hints) will be greatly
> > appreciated.
> >
> > Steve Stiff
>
> Have you made sure that the J2 jumper is set? Also make sure that
you
> use the lpc213x.h instead of the lpc21xx.h
> I'm using the following code as a small example:
>
> AD0CR |= 0x01200000; /* Start A/D Conversion
*/
> do {
> val = AD0DR; /* Read A/D Data
Register */
> } while ((val & 0x80000000) == 0); /* Wait for end of A/D
> Conversion */
> AD0CR &= ~0x01000000; /* Stop A/D Conversion
*/
>
> Is this the same as you have?
>
> Best Regards
> Sen Hansen




The 2024 Embedded Online Conference