Page 1 of 2

Pic 24FJ128GB202 no compile to hex

Posted: Mon Jan 25, 2021 12:07 am
by andrewneal123
Hi,

Its the first time i have tried to use this chip. (24FJ128GB202), usually i have used the 24HJ128GP502.

I created an empty project and attempted to build to Hex file.

I get a compile error as below

Obviously its connected to the 'AD1PCFG'

//------------------------------------------
int main()
{
AD1PCFG = 0xffff;

mainendloop: goto mainendloop;
return 0;
}
//------------------------------------------


NOT FOR COMMERCIAL USE
https://www.flowcode.co.uk
Launching the compiler...
C:\Program Files (x86)\Flowcode\Compilers\pic16\batchfiles\pic16_C30_comp.bat "no build project" "C:\Users\andos\Documents\Flowcode\" "24FJ128GB202"

C:\Users\andos\Documents\Flowcode>xc16-gcc -c -mcpu="24FJ128GB202" -omf=coff -funsigned-char -fno-short-double -Os -I"C:\PROGRA~2\Flowcode\COMPIL~1\pic16\BATCHF~1\..\support\h" -I"C:\PROGRA~2\Flowcode\COMPIL~1\pic16\BATCHF~1\" -std=gnu99 "no build project".c -o "no build project".o
Options have been disabled due to restricted license
Visit http://www.microchip.com/ to purchase a new key.
no build project.c: In function 'main':
no build project.c:72:1: error: 'AD1PCFG' undeclared (first use in this function)
no build project.c:72:1: note: each undeclared identifier is reported only once for each function it appears in

Error returned from [xc16-gcc.exe]

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

Autoclose turned off


FINISHED


Thanks in advance

Andy

Re: Pic 24FJ128GB202 no compile to hex

Posted: Mon Jan 25, 2021 7:27 am
by p.erasmus
Hi

Did you check the datasheet for this device, it is possible that the register name has changed / or it does not have this register,
you need to check this ! :D These are the things you need to do if the register exist exactly the same as in the old chip then it is possible that the definition file in FC has an error ,Then you report a bug . :D

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 9:49 am
by andrewneal123
Hi,

i appreciate and respect your comments but this is a licence issue.

Andy

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 10:05 am
by LeighM
Hi Andy,

As p.erasmus says, looks like we have a register name issue
please try the attached FCD, to go into directory
C:\ProgramData\MatrixTSL\FlowcodeV9\FCD\PIC16

nb. please first rename the 24FJ128GB202.txt file to 24FJ128GB202.fcdx

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 2:16 pm
by andrewneal123
Hi,

I tried the new file but the result is the same.

Options have been disabled due to restricted license
Visit http://www.microchip.com/ to purchase a new key.
no build project 1 .c: In function 'main':
no build project 1 .c:72:1: error: 'AD1PCFGL' undeclared (first use in this function)
no build project 1 .c:72:1: note: each undeclared identifier is reported only once for each function it appears in


Andy

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 2:30 pm
by andrewneal123
Hi

the register is ADxPCFG

Andy

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 2:40 pm
by Steve-Matrix
The line in question is part of the initialisation and puts the port pins into digital mode as a default.

Looking at the header file in the toolchain, it looks like registers ANSA and ANSB control the a/d nature of the pins, and so the line in the FCDX file near the bottom should be changed from this:

Code: Select all

        <init code='AD1PCFGL = 0xffff;\n' />
to this:

Code: Select all

        <init code='\tANSA = 0xffff;\n\tANSB = 0xffff;\n' />
There may be some other edits required to ensure ADC inputs are configured correctly when used.

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 3:02 pm
by LeighM
Doh! Just beat me to it :)
Having read through two datasheets ...
And it looks like ANSA etc needs to be set to 0 for digital mode.
So the edit needs to be
ANSA = 0; ... etc

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 3:15 pm
by Steve-Matrix
Thanks for the correction, Leigh. In my haste to beat you, I misread the datasheet! :oops:

Re: Pic 24FJ128GB202 no compile to hex

Posted: Tue Jan 26, 2021 3:56 pm
by LeighM
Updated attached