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.

  • 2
    \$\begingroup\$ This is what happens when you try to port code containing bit-fields. Seems like some genius has managed to design a non-portable protocol stack - applause is in order... I'd definitely not try to squeeze TCP/IP into an 8-bitter though. Come on, you have 1kb RAM... it's like trying to squeeze an elephant into a bottle of coca cola. Use the right tool for the task instead, some Cortex M. \$\endgroup\$
    – Lundin
    Jul 10, 2020 at 13:19
  • \$\begingroup\$ @Lundin, I think he should have a go! Getting stuff to work one woefully inadequate hardware is truly in the tradition of the electrical engineer. \$\endgroup\$
    – RJR
    Jul 10, 2020 at 14:58

1 Answer 1


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.

seem to mention similar 'solutions'.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.