View previous topic :: View next topic |
Author |
Message |
richi-d
Joined: 28 Aug 2007 Posts: 106
|
PIC24 A/D don´t work |
Posted: Wed Apr 15, 2009 11:23 am |
|
|
This is my code:
Code: | int16 LED_SPG;
SETUP_ADC_PORTS(VSS_VDD | sAN3 );
SET_ADC_CHANNEL(3);
SETUP_ADC(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
delay_us(100);
LED_SPG = READ_ADC(); |
All registers seems to be right from CCS, but READ_ADC brings: 0xFFC0 in the watch window. In the ADC1BUF0 the value is 0x1023 (also incorrect!)
Whats wrong? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Apr 15, 2009 12:15 pm |
|
|
On some PIC24 devices, some JTAG configurations are incompatible with ADC operation, read the respective device errata sheet. There may be also problems with PCD built-in functions. Generally, PIC24 ADC operation is more complex than with other PIC devices, offering many options for misunderstandings and programming faults. |
|
|
Tom B Guest
|
Re: PIC24 A/D don´t work |
Posted: Wed Apr 15, 2009 9:12 pm |
|
|
richi-d wrote: | This is my code:
Code: | int16 LED_SPG;
SETUP_ADC_PORTS(VSS_VDD | sAN3 );
SET_ADC_CHANNEL(3);
SETUP_ADC(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
delay_us(100);
LED_SPG = READ_ADC(); |
All registers seems to be right from CCS, but READ_ADC brings: 0xFFC0 in the watch window. In the ADC1BUF0 the value is 0x1023 (also incorrect!)
Whats wrong? |
Add the following to you your .h file
#device ADC=10 |
|
|
richi-d
Joined: 28 Aug 2007 Posts: 106
|
|
Posted: Sun Jul 05, 2009 4:17 am |
|
|
It works if I use programming port 2. See erata.
Thanks |
|
|
|