PIC16f877: MPLAB X error 1250 (Could not find space for variable)

mplabxpicxc8

I am using Pic16f877 microcontroller for my project. I am trying to declare a char Array as

char dataPkt[256] = {0};

While compiling, i received an error

error: (1250) could not find space (256 bytes) for variable dataPkt

Can anyone guide me how to resolve this error ??

Best Answer

There is no substitute for understanding the machine at the low level. Whether using a compiler or not, you have to actually READ THE DATASHEET.

As Figure 2-3 on page 13 clearly shows, there is no way to get 256 contiguous bytes of RAM.

Other observations:

  1. MPLABX is the IDE, so is useless in specifying what compiler or assembler you are using.

  2. Allocating a buffer for a whole packet sounds like big-processor thinking on little processors. There is no OS with canned drivers that is going to read/write whole packets from/to some communication interface. Ultimately, code is going to handle each byte separately anyway. Buffering a packet of bytes, then reading and handling them out of the packet individually anyway makes little sense.