View previous topic :: View next topic |
Author |
Message |
Bingo
Joined: 28 Apr 2011 Posts: 2
|
PIC24 not used VREF |
Posted: Thu Apr 28, 2011 4:14 pm |
|
|
Hi,
I use PIC24HJ64GP206 and CCS compiler version 4.114.
I want to measure ADC modules using Vref (I use 2.5V), but whatever I do ADC module uses Vdd. Here is some code I use.
Thank you in advance if anyone can help.
Code: |
void main(){
setup_adc_ports(AN0_TO_AN1|VSS_VREF);
setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_4);
|
VSS_VREF - for PIC18 work correctly, PIC24 does not work |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Apr 29, 2011 7:40 am |
|
|
Yes, reference voltage selection is among the PIC24 features, that still aren't implemented correctly in PCD, also in most recent V4.120. File a bug report to CCS support and set the respective configuration bits in ADxCON2 directly. |
|
|
Bingo
Joined: 28 Apr 2011 Posts: 2
|
|
Posted: Fri Apr 29, 2011 4:16 pm |
|
|
Problem is solved, if anyone needs an example here:
#bit VCFG_BIT = 0x0322.13 // Define address of VCFG bit
void main()
{
setup_adc_ports(sAN1 | sAN2 | sAN3 | sAN4|VSS_VREF);
setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_4);
VCFG_BIT = 1; // Enable the Vref pin |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Apr 30, 2011 3:55 am |
|
|
Not exactly. You would want to specify VSS_VDD with setup_adc(), othwerwise AN13 is erroneously set to analog mode and RB13 I/O function disabled. |
|
|
|