PIC32 watchdog related compilation error

A forums to allow resolved bugs and problems with Flowcode v7 to be stored and marked as resolved.

Moderator: Benj

Post Reply
pladnows
Posts: 11
Joined: Thu Sep 08, 2016 1:27 pm
Contact:

PIC32 watchdog related compilation error

Post by pladnows »

Hi,
another bug report I'm afraid. While attempting to compile a project for a 32MZ2048EFG144 PIC I've noticed a lot of watchdog related errors in the compiler output. The attached example illustrates the problem, a literally empty project fails to compile. Any help would be appreciated. Thanks!
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_Delay.c: In function 'Wdt_Delay_Ms':
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:211:49: error: '_WDTCON_WDTCLRKEY0_MASK' undeclared (first use in this function)
#define MX_CLEAR_WATCHDOG WDTCONSET = _WDTCON_WDTCLRKEY0_MASK
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_Delay.c:108:9: note: in expansion of macro 'MX_CLEAR_WATCHDOG'
MX_CLEAR_WATCHDOG; //Clear Watchdog Timer
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:211:49: note: each undeclared identifier is reported only once for each function it appears in
#define MX_CLEAR_WATCHDOG WDTCONSET = _WDTCON_WDTCLRKEY0_MASK
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_Delay.c:108:9: note: in expansion of macro 'MX_CLEAR_WATCHDOG'
MX_CLEAR_WATCHDOG; //Clear Watchdog Timer
^

C:\Program Files (x86)\Flowcode 7\compilers\pic32\bin\xc32-gcc.exe reported error code 255
Attachments
example.fcfx
(4.48 KiB) Downloaded 176 times

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC32 watchdog related compilation error

Post by Benj »

Thanks for letting us know. I have now found and fixed the bug.

To solve the problem simply copy the attached file into your "Flowcode 7/CAL" directory and the project should then compile correctly.
internals.c
(13.27 KiB) Downloaded 182 times
Let me know how you get on.

pladnows
Posts: 11
Joined: Thu Sep 08, 2016 1:27 pm
Contact:

Re: PIC32 watchdog related compilation error

Post by pladnows »

Thanks, that helped. However, there seems to be more. Initializing an ADC_base component results in a following plethora of errors. Below I've added an example that illustrates the issue.
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:147:18: error: 'AD1CAL1' undeclared (first use in this function)
_SFR_WRITE(&AD1CAL1,0xB3341210);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:147:18: note: each undeclared identifier is reported only once for each function it appears in
_SFR_WRITE(&AD1CAL1,0xB3341210);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:148:18: error: 'AD1CAL2' undeclared (first use in this function)
_SFR_WRITE(&AD1CAL2,0x01FFA769);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:149:18: error: 'AD1CAL3' undeclared (first use in this function)
_SFR_WRITE(&AD1CAL3,0x0BBBBBB8);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:150:18: error: 'AD1CAL4' undeclared (first use in this function)
_SFR_WRITE(&AD1CAL4,0x000004AC);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:151:18: error: 'AD1CAL5' undeclared (first use in this function)
_SFR_WRITE(&AD1CAL5,0x02028002);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:153:18: error: 'AD1CON1' undeclared (first use in this function)
_SFR_WRITE(&AD1CON1,0); // No AD1CON1 features are enabled including: Stop-in-Idle, early
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:157:18: error: 'AD1CON2' undeclared (first use in this function)
_SFR_WRITE(&AD1CON2,0); // Boost, Low-power mode off, SAMC set to min, set up the ADC Clock
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:168:18: error: 'AD1CON3' undeclared (first use in this function)
_SFR_WRITE(&AD1CON3,0); // ADINSEL is not configured for this example. VREFSEL of ?0?
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:177:18: error: 'AD1IMOD' undeclared (first use in this function)
_SFR_WRITE(&AD1IMOD,0); // All channels configured for default input and single-ended
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:180:18: error: 'AD1GIRQEN1' undeclared (first use in this function)
_SFR_WRITE(&AD1GIRQEN1,0); // No global interrupts are used.
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:181:18: error: 'AD1GIRQEN2' undeclared (first use in this function)
_SFR_WRITE(&AD1GIRQEN2,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:184:18: error: 'AD1CSS1' undeclared (first use in this function)
_SFR_WRITE(&AD1CSS1,0); // No channel scanning is used.
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:185:18: error: 'AD1CSS2' undeclared (first use in this function)
_SFR_WRITE(&AD1CSS2,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:187:18: error: 'AD1CMPCON1' undeclared (first use in this function)
_SFR_WRITE(&AD1CMPCON1,0); // No digital comparators are used. Setting the AD1CMPCONx
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:188:18: error: 'AD1CMPCON2' undeclared (first use in this function)
_SFR_WRITE(&AD1CMPCON2,0); // register to ?0? ensures that the comparator is disabled. Other
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:189:18: error: 'AD1CMPCON3' undeclared (first use in this function)
_SFR_WRITE(&AD1CMPCON3,0); // registers are ?don?t care?.
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:190:18: error: 'AD1CMPCON4' undeclared (first use in this function)
_SFR_WRITE(&AD1CMPCON4,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:191:18: error: 'AD1CMPCON5' undeclared (first use in this function)
_SFR_WRITE(&AD1CMPCON5,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:192:18: error: 'AD1CMPCON6' undeclared (first use in this function)
_SFR_WRITE(&AD1CMPCON6,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:194:18: error: 'AD1FLTR1' undeclared (first use in this function)
_SFR_WRITE(&AD1FLTR1,0); // No oversampling filters are used.
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:195:18: error: 'AD1FLTR2' undeclared (first use in this function)
_SFR_WRITE(&AD1FLTR2,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:196:18: error: 'AD1FLTR3' undeclared (first use in this function)
_SFR_WRITE(&AD1FLTR3,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:197:18: error: 'AD1FLTR4' undeclared (first use in this function)
_SFR_WRITE(&AD1FLTR4,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:198:18: error: 'AD1FLTR5' undeclared (first use in this function)
_SFR_WRITE(&AD1FLTR5,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:199:18: error: 'AD1FLTR6' undeclared (first use in this function)
_SFR_WRITE(&AD1FLTR6,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:202:18: error: 'AD1TRG1' undeclared (first use in this function)
_SFR_WRITE(&AD1TRG1+(Channel/4),((_SFR_READ(&AD1TRG1)&((0x1F<<((Channel%4)*8))^0xFFFFFFFF))|(1<<((Channel%4)*8)))); // Set AN0 to trigger from software
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c: In function 'FC_CAL_ADC_Sample':
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:216:15: error: 'AD1CON3' undeclared (first use in this function)
_SFR_WRITE(&AD1CON3,((_SFR_READ(&AD1CON3)&0xBFFFFFFF)|0x40000000));
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:219:31: error: 'AD1DSTAT1' undeclared (first use in this function)
while (_SFR_BIT_READ(&AD1DSTAT1,MX_Current_Channel) == 0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:227:61: note: in definition of macro '_SFR_BIT_READ'
#define _SFR_BIT_READ(reg,pos) ( ( ( *((SFR_TYPE *)(reg)) )&(1<<(pos)) ) ? 1 : 0 )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:224:25: error: 'AD1DATA0' undeclared (first use in this function)
iRetVal = _SFR_READ(&AD1DATA0 + MX_Current_Channel);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:226:51: note: in definition of macro '_SFR_READ'
#define _SFR_READ(reg) ( *((SFR_TYPE *)(reg)) )
^
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:237:15: error: 'AD1TRG1' undeclared (first use in this function)
_SFR_WRITE(&AD1TRG1,0); // Initialize all sources to no trigger.
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:238:18: error: 'AD1TRG2' undeclared (first use in this function)
_SFR_WRITE(&AD1TRG2,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:239:18: error: 'AD1TRG3' undeclared (first use in this function)
_SFR_WRITE(&AD1TRG3,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:240:15: error: 'AD1CSS1' undeclared (first use in this function)
_SFR_WRITE(&AD1CSS1,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:241:15: error: 'AD1CSS2' undeclared (first use in this function)
_SFR_WRITE(&AD1CSS2,0);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:225:51: note: in definition of macro '_SFR_WRITE'
#define _SFR_WRITE(reg,val) ( *((SFR_TYPE *)(reg)) = (val) )
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c:242:19: error: 'AD1CON1' undeclared (first use in this function)
_SFR_BIT_CLEAR(&AD1CON1,15);
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:229: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\compilers\pic32\bin\xc32-gcc.exe reported error code 255
Attachments
example_2.fcfx
(5.37 KiB) Downloaded 180 times

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC32 watchdog related compilation error

Post by Benj »

Thanks for letting us know.

It looks like this is going to take more time to solve, the ADC on this device looks very different to the other MZ ADC devices which explains the compilation errors being generated.

Hopefully I'll have a fix for you soon.

pladnows
Posts: 11
Joined: Thu Sep 08, 2016 1:27 pm
Contact:

Re: PIC32 watchdog related compilation error

Post by pladnows »

Looking forward to that, thank you.

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC32 watchdog related compilation error

Post by Benj »

Hello,

Right this is now compiling correctly. I don't currently have one of these devices to hand to actually test if the code works so please let me know how you get on.

Firstly you have to copy this file to your "Flowcode 7/CAL/PIC32BIT" folder.
PIC32BIT_CAL_ADC.c
(14.83 KiB) Downloaded 170 times
Next you have to copy this file to your "Flowcode 7/FCD/PIC32" folder.
32MZ2048EFG144.fcdx
(61.1 KiB) Downloaded 175 times
Then restart Flowcode and the code for the ADC should now compile correctly.

Brendan
Posts: 227
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Contact:

Re: PIC32 watchdog related compilation error

Post by Brendan »

Hi Ben.

Many thanks for the timely fix, and happy to confirm that the project now compiles without error :D


Best regards,

Brendan

pladnows
Posts: 11
Joined: Thu Sep 08, 2016 1:27 pm
Contact:

Re: PIC32 watchdog related compilation error

Post by pladnows »

Thanks Benj, your help is greatly appreciated.

Post Reply