Compiling error with Modbus/PIC32MX550 project

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

Moderator: Benj

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

Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Sun Jun 11, 2017 2:13 pm

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Mon Jun 12, 2017 4:19 pm

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
(23.54 KiB) Downloaded 123 times


Let us know how you get on.

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

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Sun Jun 18, 2017 7:58 pm

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 146 times



Please check.

Regards,

Patrick

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1087
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 334 times
Been thanked: 544 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby QMESAR » Mon Jun 19, 2017 7:04 am

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: 51
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Mon Jun 19, 2017 9:35 pm

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 151 times
These users thanked the author patrick schoon for the post:
Benj (Tue Jun 20, 2017 10:41 am)
Rating: 5.56%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1087
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 334 times
Been thanked: 544 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby QMESAR » Tue Jun 20, 2017 4:06 am

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
These users thanked the author QMESAR for the post:
Benj (Tue Jun 20, 2017 10:40 am)
Rating: 5.56%
 

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

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Tue Jun 20, 2017 10:40 am

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
(27.32 KiB) Downloaded 115 times


Let me know how you get on.

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

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Tue Jun 20, 2017 8:25 pm

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 114 times

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

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Wed Jun 21, 2017 10:22 am

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
(27.3 KiB) Downloaded 114 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1087
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 334 times
Been thanked: 544 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby QMESAR » Wed Jun 21, 2017 3:45 pm

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Wed Jun 21, 2017 4:28 pm

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: 1087
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 334 times
Been thanked: 544 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby QMESAR » Wed Jun 21, 2017 4:31 pm

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: 51
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Wed Jun 21, 2017 7:02 pm

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Tue Jun 27, 2017 9:11 am

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Tue Jun 27, 2017 10:33 am

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 8269 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.
https://www.matrixtsl.com/mmforums/view ... 63&t=18760

SerialOutput2.jpg
SerialOutput2.jpg (21.83 KiB) Viewed 8268 times


Here is my Flowcode project if you want to try and replicate my tests.
PIC32UartTests.fcfx
(12.45 KiB) Downloaded 102 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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Tue Jun 27, 2017 11:41 am

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: 51
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Tue Jun 27, 2017 9:04 pm

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 89 times


ModBus_Slave_PIC32MX550.fcfx
(19.22 KiB) Downloaded 98 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: 51
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Wed Jul 19, 2017 6:22 pm

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby Benj » Tue Jul 25, 2017 5:15 pm

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: 51
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Compiling error with Modbus/PIC32MX550 project

Postby patrick schoon » Wed Jul 26, 2017 9:13 pm

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.79 KiB) Downloaded 71 times


Regards,

Patrick