Compiling error with Modbus/PIC32MX550 project

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

Moderator: Benj

Post Reply
patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi,

I get this compiling error trying compiling a Modbus project into a PIC32MX550.
It seems thare is a variable definition problem within the matrix code.


Target folder: D:\PROJEC~1
Source name: D:\Projecten\PIC32MX550_Modbus.fcfx
Title:
Description:
Device: PIC32.32MX.32MX550F256H
Generated by: Flowcode v7.2.1.4
Date: Sunday, June 11, 2017 14:59:53
Users: 1
Registered to: ps
Licence key: Y
http://www.matrixtsl.com
De compiler wordt gestart...
C:\Program Files (x86)\Flowcode 7\compilers\pic32\bin\xc32-gcc.exe -mprocessor=32MX550F256H -O1 -o "D:\PROJEC~1\PIC32MX550_Modbus.elf" "D:\PROJEC~1\PIC32MX550_Modbus.c"
In file included from C:\Program Files (x86)\Flowcode 7\CAL\includes.c:884:0,
from D:\PROJEC~1\PIC32MX550_Modbus.c:249:
D:\PROJEC~1\PIC32MX550_Modbus.c: In function '_IntHandlerDrvUsartReceiveInstance0':
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_UART.c:188:41: error: '__IFS0bits_t' has no member named 'U1RXIF'
#define MX_UART_INT_CH1_DET IFS0bits.U1RXIF && IEC0bits.U1RXIE
^
D:\PROJEC~1\PIC32MX550_Modbus.c:2706:6: note: in expansion of macro 'MX_UART_INT_CH1_DET'
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_UART.c:188:60: error: '__IEC0bits_t' has no member named 'U1RXIE'
#define MX_UART_INT_CH1_DET IFS0bits.U1RXIF && IEC0bits.U1RXIE
^
D:\PROJEC~1\PIC32MX550_Modbus.c:2706:6: note: in expansion of macro 'MX_UART_INT_CH1_DET'

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



KLAAR



It's not the project while it is working on other PIC mcu's.

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

Many thanks for letting us know.

I believe I have now found and fixed the problem.

Simply copy the attached file to your "Flowcode 7/CAL/PIC32" folder and then the compilation should complete successfully.
PIC32BIT_CAL_UART.c
(22.73 KiB) Downloaded 170 times
Let us know how you get on.

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi Ben,

Sorry, this is not working.

I tested my setup just with an UART and that is working. So no hardware issues.

This example is tested on my e-block (pic18F4580) and is working fine.
When compiled to PIC32MX the communication is dead.
ModBus_Slave.fcfx
Example Modbus Slave
(16.09 KiB) Downloaded 205 times

Please check.

Regards,

Patrick

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1193
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by QMESAR »

patrick schoon wrote: I tested my setup just with an UART and that is working. So no hardware issues.

This example is tested on my e-block (pic18F4580) and is working fine.
When compiled to PIC32MX the communication is dead.
ModBus_Slave.fcfx
Hi Patrick can you please confirm if the UART(component) work on your PIC32MX ,can you please give the full device number ,I would like to know this as I am experiencing issues with the UART and interrupts on PIC32MC534F064H in my opinion the UART component and Interrupts affect each other ,I have no UART Tx from my device

Thanks a million :D

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi,

I use the PIC32MX550F256H controler.

I tested Uart1 wih UART interupt and FIFO, Seems this works well.
PIC32MX Uart Test.fcfx
(14.02 KiB) Downloaded 205 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1193
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by QMESAR »

patrick schoon wrote: I use the PIC32MX550F256H controler.

I tested Uart1 wih UART interupt and FIFO, Seems this works well.
Hi Patrick
Thank's a million for confirming this ,I appreciate your feedback :D

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

Hello,

Sorry for the delay.
Sorry, this is not working.
I tested my setup just with an UART and that is working. So no hardware issues.
I have had a think about this and have had a thought, the Modbus slave uses the CAL UART to enable the interrupt, however we do not set the interrupt priority which defaults as 0 or disabled. So I now set the priority to 3 when the automated CAL interrupt is active and hopefully that should allow the slave to spring into life.

Simply copy the attached file into your "Flowcode 7\CAL\PIC32BIT" folder and hopefully this will fix the problem for you.
PIC32BIT_CAL_UART.c
(26.35 KiB) Downloaded 161 times
Let me know how you get on.

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi Ben,

Sorry, no results on this.

I tried to be sure UART 1-3 but none of them is working.

I also have put an indication to the modbus checkforincomming macro. No reaction here, so receiving data from the Uart Rx is not workig.

Hope you wil put some effort in this for me.

Keep in mind that when compiling the same project to a PIC18, all is working...

Regards,

Patrick
ModBus_Slave.fcfx
(17.33 KiB) Downloaded 161 times

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

Hi Patrick,

These PIC32 devices are being a bit funny. I have reports that any priority level other than 1 doesn't work so here is another version of the updated CAL but this time with priority set to 1. Fingers crossed...
PIC32BIT_CAL_UART.c
(26.33 KiB) Downloaded 156 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1193
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by QMESAR »

Benj wrote:Hi Patrick,
I have reports that any priority level other than 1 doesn't work
Hi all
Just to remove some misunderstandings when the Priorities are set in MPLAB Projects and also in mikroC PIC32 they work from level one to 7 as expected :D
in my humble opinion we are still missing something in FC ,I might be wrong

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

Hello,

Please could you share your MikroC project source files and I will compare with what Flowcode is generating. It's a totally different compiler so maybe there is a problem here but it might give us some insight?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1193
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by QMESAR »

Benj wrote:Hello,

Please could you share your MikroC project source files and I will compare with what Flowcode is generating. It's a totally different compiler so maybe there is a problem here but it might give us some insight?
Hi Ben
I will PM the files to you as it is a confidential Code would not like to place it in the forum :D

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi Ben,

No results wit this CAL file.

Can i change the priority level in the code to test?

Patrick

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

Hi Patrick,

I cannot replicate the none working UART on the PIC32 devices I have so yes anything you can try to see if you can get it going would be helpful. QMESAR has said that only a specific priority has worked for him but that a C project works well. I have the C project so I'll have a look today and make sure we're not leaving anything specific out for this device.

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

I've knocked together a simple UART test program using an Arduino board as a USB to Serial converter. This is working really well for me on a PIC32MX250F128B at different baud rates however I am having an issue.

Whenever the PIC32 receives a byte via the UART RXINT interrupt it seems to correctly receive the byte and then after that it receives a 0xFF byte. Here you can see I sent the text "helloworld" to the PIC and on echoing back the data it is interleaved with 0xFF values. This in itself would be enough to ensure the Modbus slave component won't work.
SerialOutput.jpg
SerialOutput.jpg (47.38 KiB) Viewed 10866 times
I'll have a dig and see if I can get to the bottom of the problem...

Edit. I've just applied the latest PIC32 FCDs from the link below and this has now fixed the 0xFF byte receive issue for me. The problem must have been related to clearing the RX interrupt flag before reading the Rx Buffer meaning the flag gets reset incorrectly. We now read the buffer and then clear the flag.
viewtopic.php?f=63&t=18760
SerialOutput2.jpg
SerialOutput2.jpg (21.83 KiB) Viewed 10865 times
Here is my Flowcode project if you want to try and replicate my tests.
PIC32UartTests.fcfx
(12.45 KiB) Downloaded 135 times
I'm going to check now to see if the CAL enabled interrupt has a similar issue.

Edit. The CAL enabled interrupt (in the Modbus Slave) doesn't seem to have the same problem. The interrupt flag is cleared after reading the RX buffer.

Code: Select all

void interrupt MX_INTERRUPT_MACRO(void)
{
    MX_UART_INT_CH1_FUNC
    MX_UINT8 FCL_DATA;
    if (MX_UART_INT_CH1_DET)
    {
    FCL_DATA = FC_CAL_UART_Receive_1(0); //Read RX Buffer
    FCD_02b21_CircularBuffer1__PutByte(FCL_DATA);
    MX_UART_INT_CH1_CLR; //Clear Interrupt Flag
    }
    MX_UART_INT_FUNC_END
}

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

I've just compared the UART control registers for the 32MX250 and the 32MX550 and they are identical.

Looking at the errata document for the 32MX550 it lists the following known problems with the silicone.

UART - Receive Overflow
A receive FIFO overflow condition causes the shift register to stop receiving data and lose synchronization with the serial data stream.
64/128 - A0 and A2
256/512 - A0 Only

UART - Auto-baud
Auto-baud does not function to set the baud rate.
64/128 - A0 and A2
256/512 - A0 Only

I don't believe we are specifically using either of these features unless there are knock-ons we are unaware of.

My device 32MX250F128B is revision A1.

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi Ben,

I tested your UART example on my MX550 and that works well.
My 550 is a revision A0.

Now with my modbus slave pgm it is still not working..

I monitored the "check for incoming" and this is not reacting on incomming data.
BenJ_PIC32UartTests.fcfx
(12.46 KiB) Downloaded 125 times
ModBus_Slave_PIC32MX550.fcfx
(19.22 KiB) Downloaded 129 times
As told before, with example from me, the uart function itself is working well. Only in Modbus no results..

Regards,

Patrick

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi Ben,

I was curious if you did put some investigation in the modbus slave isue?

For your information. The main loop holds on the CheckForIncoming macro..

Regards,

Patrick

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

Re: Compiling error with Modbus/PIC32MX550 project

Post by Benj »

Hello Patrick,

Without being able to replicate the problem on hardware it's very hard for me to work out what might be going wrong for you.

Would it be possible for you to send us the hardware that exhibits the problem. This should help me to speed up finding a fix for you.

patrick schoon
Posts: 69
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Post by patrick schoon »

Hi Ben,

Do you own a Microchip Explorer board?
I ordered a MX570 PIM to double check this out on my explorer kit.

I can send you my kit if needed.

About my hardware.
I send the schematics to you by personal mail.

As told earlier on the forum I checked my own designed hardware with the UART component and that is working wel.
So i think my hardware is working. .

To check the Modbus Slave component, til now tested on my E-Blocks, I use Modbus Poll software to emulate a Modbus master.
Also this works well on the E_Blocks testkit.

Now something interesting.
I just hooked up my Explorer board with a PIC24FJ128 MCU.
Exact same reaction as my own designed hardware.
Also here with only the Modbus slave component the CheckForIncomming macro blocks the main loop.
When switched off the loop is working.
ModBus_Slave_PIC24FJ128.fcfx
(19.78 KiB) Downloaded 108 times
Regards,

Patrick

Post Reply