PIC24FJ256GA702 component not working query

Moderator: Benj

Post Reply
pmck
Posts: 7
Joined: Wed Aug 07, 2019 1:33 pm
Contact:

PIC24FJ256GA702 component not working query

Post by pmck »

Hello, I need help with this component. My previous projects have been 8 bit PICs so before starting work on a 16 bit program I selected the above and went to do a simple test to set the xtal osc and turn on 1 led. Surprisingly it failed to compile to hex in FC8 (tried FC7 but it doesn't have this component).
I opened a new project and with only "begin end" tried again with the same error as pasted below yet components either side of this family work fine.

https://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\pic16\batchfiles\pic16_C30_comp.bat "Flowcode1" "D:\temp\PIC24FJ256GA702\" "24FJ256GA702"

D:\temp\PIC24FJ256GA702>xc16-gcc -c -mcpu="24FJ256GA702" -omf=coff -funsigned-char -fno-short-double -Os -I"C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic16\BATCHF~1\..\support\h" -I"C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic16\BATCHF~1\" -std=gnu99 "Flowcode1".c -o "Flowcode1".o
Options have been disabled due to restricted license
Visit http://www.microchip.com/ to purchase a new key.
Flowcode1.c: In function 'main':
Flowcode1.c:81:1: error: 'ANSELA' undeclared (first use in this function)
Flowcode1.c:81:1: note: each undeclared identifier is reported only once for each function it appears in
Flowcode1.c:82:1: error: 'ANSELB' undeclared (first use in this function)

Error returned from [xc16-gcc.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic16\batchfiles\pic16_C30_comp.bat reported error code 1



I tried the others in this family PIC24FJ256GA704 & 705 and all fail. I am out of my depth but tried modifying the component to align with others that compile around the ANSEL statements

<start code='int main()\n{\n' />
<end code='\tmainendloop: goto mainendloop;\n\treturn 0;\n}\n\n' />
<init code='ANSELA = 0x0;\nANSELB = 0x0;\n' />

CHANGED to <init code='nANSELA = 0;\nANSELB = 0;\n\n' />

but same error msg so restored original

Is this component working correctly or am I doing something wrong (compiler)?

regards

Paul

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: PIC24FJ256GA702 component not working query

Post by Benj »

Hi Paul,

Hmm this is a strange one. I've found the cause of the problem and it's due to the definition of the ANSEL registers in the supplied version of the compiler.

If you go into Build -> Project options and then enable the supplementary code then add the following to the supplementary code defines section and it should solve the problem for you.

Code: Select all

#define ANSELA ANSA
#define ANSELB ANSB
This should then fix the FCD definition and also the ADC code.

Let us know how you get on.

pmck
Posts: 7
Joined: Wed Aug 07, 2019 1:33 pm
Contact:

Re: PIC24FJ256GA702 component not working query

Post by pmck »

Ben

Thanks very much, that makes sense and it worked. It's better than modifying the component definition file.

FYI I noticed this chip's data sheet used ANSELA/B for the analog port config bits like PIC18's BUT a check in other PIC24 datasheets shows ANSA/B etc is used. I did replace ANSEL with ANS in the component fcpx definition file but I couldn't get it to work.

Paul

Post Reply