LPC1768 ADC malfuntioning

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

LPC1768 ADC malfuntioning

1,177 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sreynoso on Mon Nov 29 11:03:51 MST 2010
I am programing LCPXpresso 1768 board to make ADC conversion on Timer 0 MATCH events. I tried with MAT0.1 or MAT0.3, but the AD converter don´t start the conversion.
I tested the ADC by configuring it to start conversion on external pin EINT0 event and manual mode too, and the ADC start conversions succesfully.

Is this a problem into the LPC1768 microcontroller or wrong configuration in my software ?
I send you my code into the atachment.
0 Kudos
8 Replies

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Nov 30 15:23:23 MST 2010
@KTownsend:

Wow, LPCXpresso MVP !!! Dreaming of this since 20 years Embedded Systems.
Does it include a certificate, a cup or a ring? Or some power of order?
Is this MVP allowed to command a platoon of LPCXpresso recruits, shout at them and let them... hmmm... solder a LQFP200 with an old 300W soldering gun?
All my dreams come true, someone somewhere names me somehow.

@sreynoso:

If you use a breakpoint in your timer interrupt and also in your adc interrupt you can control if your timer and adc is working as expected.
If you don't config the right external match bit, you'll just see your timer interrupt working and no adc interrupt (believe me, I've tried it).
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by waynemcl on Tue Nov 30 14:36:02 MST 2010

Quote: sreynoso
Zero, I going to add external match bit configuration to the program and will test again.
I see that the NXP´s LPC17xx user manual is incomplete. They never mentions that is required to configure interrupts nor external match bits for the timers.
Could you recomend us more detailed manuals ?

Best regards



Hi

The LPC1768 data sheet is at
http://www.nxp.com/documents/data_sheet/LPC1769_68_67_66_65_64_63.pdf

A more complete user manual is at:
http://www.nxp.com/documents/user_manual/UM10360.pdf

Cheers
W
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Tue Nov 30 12:33:11 MST 2010

Quote: Zero
It's all there:
Unfortunately not. That's all I have. But perhaps I'll write a book next year :)



Oh, now you're just showing off.  I suppose you're going to want to be named lpcxpresso MVP soon as well. :D

I actually find the documentation from NXP is usually pretty good, especially combined with SW examples that they've been good about putting out for all their new chips.  They're not always perfect, but 90% is way better than starting from nothing in my books.  It's the main reason I tend to stick with them.  Maybe it's just a familiarity thing since I got started in ARM with NXP and the format hasn't changed since, but I've generally found them on the upper end of the spectrum as far as silicon vendors go for technical documentation.  TI is another company that has some decent documentation such as their appnotes for RF, but what are people comparing the NXP MCU user manuals and datasheets to implying they're subpar, etc.?  (It's an honest question ... maybe I'm missing something having never been terribly disappointed so far.)
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Nov 30 12:25:18 MST 2010

Quote:
I see that the NXP´s LPC17xx user manual is incomplete. They never mentions that is required to configure interrupts nor external match bits for the timers.



It's all there:

Quote:
UM10360 LPC17xx User manual
Chapter 29: LPC17xx Analog-to-Digital Converter (ADC)
29.5.1 A/D Control Register (AD0CR - 0x4003 4000)
Bit 26:24 START: 100 Start conversion when the edge selected by bit 27 occurs on MAT0.1.
Note that this does not require that the MAT0.1 function appear on a device pin.




Quote:
Could you recommend us more detailed manuals ?



Unfortunately not. That's all I have. But perhaps I'll write a book next year :)
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sreynoso on Tue Nov 30 09:29:18 MST 2010

Quote: Zero
And last not least you have to set/reset the external match bit, even if you don't use it as output bit :eek:

LPC_TIM0 -> EMR = (1<<1)|(3<<6);
LPC_PINCON->PINSEL3 =(0x03<<26);

[LEFT]is toggling external match bit with timer0 match1 and switching it to PIO1.29.[/LEFT]

[LEFT]
LPC_TIM0 -> EMR = (3<<6);


without output :)[/LEFT]



Zero, I going to add external match bit configuration to the program and will test again.
I see that the NXP´s LPC17xx user manual is incomplete. They never mentions that is required to configure interrupts nor external match bits for the timers.
Could you recomend us more detailed manuals ?

Best regards
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sreynoso on Tue Nov 30 08:57:34 MST 2010

Quote: Zero
It's wrong Code

 
LPC_TIM0 -> MCR = (0x03); // Interrupt on MR0, Reset on MR0

MR0 can't start ADC (as you know!)

Use:
LPC_TIM0 -> MCR = (0x03 <<3); // Interrupt on MR1, Reset on MR1


LPC_ADC -> ADCR |= (5 << 24); // Start conversion on MAT0.3

was waiting for MR3 interrupt, probably forever....

Use:
LPC_ADC -> ADCR |= (4 << 24); // Start conversion on MAT0.1



Zero, thanks for your response
I already configured Timer 0 with "Interrupt on MR1, Reset on MR1" and "Start ADC conversion on MAT0.1" and still not converting. I also tried

 
LPC_TIM0 -> MCR = (0x03 <<9 ); // Interrupt on MR3, Reset on MR3

and
 
LPC_ADC -> ADCR |= (5 << 24); // Start conversion on MAT0.3


with no success.

Then I tried Timer 1 with "Interrupt on MR0, Reset on MR0" and
ADC "Start ADC conversion on MAT1.0"

 
LPC_TIM1 -> MCR = 0x03; // Interrupt on MR0, Reset on MR0
LPC_ADC -> ADCR |= (6 << 24); // Start conversion on MAT1.0

This code did not work too.
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Nov 29 16:49:58 MST 2010
And last not least you have to set/reset the external match bit, even if you don't use it as output bit :eek:

LPC_TIM0 -> EMR = (1<<1)|(3<<6);
LPC_PINCON->PINSEL3 =(0x03<<26);

[LEFT]is toggling external match bit with timer0 match1 and switching it to PIO1.29.[/LEFT]

[LEFT]
LPC_TIM0 -> EMR = (3<<6);

without output :)[/LEFT]
0 Kudos

731 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Nov 29 15:19:37 MST 2010
It's wrong Code

 
LPC_TIM0 -> MCR = (0x03); // Interrupt on MR0, Reset on MR0

MR0 can't start ADC (as you know!)

Use:
LPC_TIM0 -> MCR = (0x03 <<3); // Interrupt on MR1, Reset on MR1


LPC_ADC -> ADCR |= (5 << 24); // Start conversion on MAT0.3

was waiting for MR3 interrupt, probably forever....

Use:
LPC_ADC -> ADCR |= (4 << 24); // Start conversion on MAT0.1
0 Kudos