Compiling error when ADC used

An area to discuss 32-bit PIC specific problems and examples

Moderator: Benj

Post Reply
patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Compiling error when ADC used

Post by patrick schoon »

Hello,

I tried to use ADC in my project but this gives an error when compiling.

De compiler wordt gestart...
C:\Program Files (x86)\Flowcode 7\compilers\pic32\bin\xc32-gcc.exe -mprocessor=32MX550F256H -O1 -o "D:\PROJEC~1\METALT~1\240C\24C789~1\Flowcode\201709~1\ModBus_Slave_PIC32MX550_0926.elf" "D:\PROJEC~1\METALT~1\240C\24C789~1\Flowcode\201709~1\ModBus_Slave_PIC32MX550_0926.c"
In file included from D:\PROJEC~1\METALT~1\240C\24C789~1\Flowcode\201709~1\ModBus_Slave_PIC32MX550_0926.c:69:0:
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c: In function 'FC_CAL_ADC_Enable':
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:71:19: error: 'AD1PCFG' undeclared (first use in this function)
_SFR_BIT_CLEAR(&AD1PCFG,Channel);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:231:57: note: in definition of macro '_SFR_BIT_CLEAR'
#define _SFR_BIT_CLEAR(reg,pos) ( *((SFR_TYPE *)((reg)+(1))) = 1<<(pos) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:71:19: note: each undeclared identifier is reported only once for each function it appears in
_SFR_BIT_CLEAR(&AD1PCFG,Channel);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:231:57: note: in definition of macro '_SFR_BIT_CLEAR'
#define _SFR_BIT_CLEAR(reg,pos) ( *((SFR_TYPE *)((reg)+(1))) = 1<<(pos) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c: In function 'FC_CAL_ADC_Disable':
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:116:15: error: 'AD1PCFG' undeclared (first use in this function)
_SFR_WRITE(&AD1PCFG,0xFFFF);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:227:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^

C:\Program Files (x86)\Flowcode 7\compilers\pic32\bin\xc32-gcc.exe gerapporteerde foutcode 255



KLAAR


Seems undeclared variables in CAL_ADC function is not responding
Any help?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Compiling error when ADC used

Post by Benj »

Hello,

This should solve the problem for you. Simply copy the attached file into your "Flowcode 7/CAL/PIC32BIT" folder.
PIC32BIT_CAL_ADC.c
(14.68 KiB) Downloaded 287 times
Let us know how you get on.

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: Compiling error when ADC used

Post by patrick schoon »

Hi Ben,

Compile errors are solved but i do not get any value from the adc.
I tested several inputs and ADC component settings but no output value.

It also locks my program depending on its settings.


For now i solved it in C code.

//AD1PCFG = 0xFFFB; // all PORTB = Digital; RB2 = analog, NOT PIC32MX
AD1CON1 = 0x0000; // SAMP bit = 0 ends sampling
// and starts converting
AD1CHS = 0x10100000; // Configure input channels,
// CH0+ input is AN16.
// CHO- input is VREFL (AVss) */
AD1CSSL = 0;
AD1CON3 = 0x0004; // Manual Sample, TAD = internal 6 TPB
AD1CON2 = 0;
AD1CON1SET = 0x8000; // turn on the ADC
AD1CON1SET = 0x0002; // start sampling ...
FCI_DELAYBYTE_MS(5); // Delay 5ms
AD1CON1CLR = 0x0002; // start Converting
while (!(AD1CON1 & 0x0001));// conversion done?
FCV_ADC0 = ADC1BUF0; // yes then get ADC value

Regards,

Patrick

Post Reply