Electronic – PIC Microchip TCP IP Lite Stack on 8bit Microcontroller

ethernetmicrochipmicrocontrollertcp/ipxc8

I'm trying to learn about ethernet communication on a PIC micro following application note AN1921 however I'm getting compilation errors which seem to imply that the Microchip TCP/IP Lite Stack implementation isn't compatible with 8bit microcontrollers, despite the advice note specifically being for that use case.

Examples of errors:

mcc_generated_files/TCPIPLibrary/tcpip_types.h:58:22: error: bit-field 'vlanId' too large (12 bits)
    unsigned int vlanId:12; // not PIC compatible
                 ^
mcc_generated_files/TCPIPLibrary/tcpip_types.h:280:14: error: bit-field 'version' has bad bitfield type 'uint16_t' (aka 'unsigned short')
    uint16_t version:4;
         ^
mcc_generated_files/TCPIPLibrary/tcpip_types.h:281:14: error: bit-field 'trafficClass' has bad bitfield type 'uint16_t' (aka 'unsigned short')
    uint16_t trafficClass:8;// this is a problem
         ^
mcc_generated_files/TCPIPLibrary/tcpip_types.h:282:14: error: bit-field 'flowLabel1stNibble' has bad bitfield type 'uint16_t' (aka 'unsigned short')
    uint16_t flowLabel1stNibble:4;

The confuguration I'm using is a Curiosity HPC dev board + PIC16F18875 + ETH Click, and using XC8 compiler with TCP/IP Lite Stack versions 2.1.1, 2.2.8 and 2.2.12 (all of which have the same errors).

Any suggestions? I could understand if the TCP/IP Lite Stack library contained errors, but to have a appilication note specifically describe how to use it with 8bit micros it really makes me think I've got something wrong? I am fairly new to this and starting to doubt that the thing that's meant to be helping me learn is actually making things harder.

Best Answer

This issue was raised on the Microchip support forums in January 2019: https://www.microchip.com/forums/m1078511.aspx

From a brief skim through the thread there it looks like the fix for the vlanId error on line 58 is to simply comment out the entire union, since it's not used.
It also appears that you need to configure the compiler to use the 'C90' standard instead of the apparently default 'C99' setting, and this will probably resolve the errors with the other bit-fields.

Also:
https://www.microchip.com/forums/m1112846.aspx
https://www.microchip.com/forums/m1064359.aspx
seem to mention similar 'solutions'.