PIC16F18877+GLCD ST7796

For general Flowcode discussion that does not belong in the other sections.
Post Reply
peterUA
Posts: 3
http://meble-kuchenne.info.pl
Joined: Sun Nov 10, 2024 4:55 pm

PIC16F18877+GLCD ST7796

Post by peterUA »

Hello Matrix. I want to create a project PIC16F8877 with TFT display GLCD ST7796 SPI. The compilation process ends with an error = test_18877_7796dip.c:3421:: error: (1250) could not find space (120 bytes) for variable _FCL_BUFF
If you select the PIK18F25K50 chip, the compilation completes successfully.
Please note that the memory size of the 16f18877 chip Flash 56 kB, RAM 4 kB is much larger than 18f5k50 Flash 32 KB, RAM 2048 byte. Perhaps I am doing something wrong? Please help me.
Best regards
Petro
Attachments
test18f25k50_7796.fcfx
(11.83 KiB) Downloaded 5 times
test_18877_7796dip.fcfx
(11.72 KiB) Downloaded 5 times

medelec35
Matrix Staff
Posts: 1956
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 626 times
Been thanked: 656 times

Re: PIC16F18877+GLCD ST7796

Post by medelec35 »

Hello.
I get that it can be confusing
Difference in RAM.png
Difference in RAM.png (67.38 KiB) Viewed 106 times
The PIC16F18877 uses banked RAM, meaning large variables like _FCL_BUFF need to fit within a single bank. If the compiler can't find 120 contiguous bytes in one bank, it throws an error. The PIC18F25K50, on the other hand, has a more flexible memory structure, making it easier to allocate large buffers.
So if you want to have even more gLCD data, choose an 18F target that has even more RAM.

You can go to here and sort by RAM:
Sort targets by RAM.png
Sort targets by RAM.png (279.53 KiB) Viewed 98 times
Although we plan to sort this out, you need to make sure that if you want I2C don't use K42.
Best advice would be to make your project with I2C device added compiles to hex before purchasing microcontroller as that will save you lots of time and money.

As this is not a bug, I have moved the topic from the Bugs section to a more suitable place.
Martin

peterUA
Posts: 3
Joined: Sun Nov 10, 2024 4:55 pm

Re: PIC16F18877+GLCD ST7796

Post by peterUA »

Hi Martin! Great answer as always. Thanks. What's really confusing is this quote from the datasheet: - " LINEAR DATA MEMORY. 80-byte blocks. Use of the linear data memory region allows buffers to be larger
than 80 bytes because incrementing the FSR beyond
one bank will go directly to the GPR memory of the next
bank." Okay, let's move on. I get the gist. Please clarify what the long variable " _FCL_BUFF" represents. I have a few projects to do with GLCD 7796 SPI. I don't want to step on the same rake again.
Best regards
Petro

medelec35
Matrix Staff
Posts: 1956
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 626 times
Been thanked: 656 times

Re: PIC16F18877+GLCD ST7796

Post by medelec35 »

Hi Petro.
Rather than getting into what _FCL_BUFF" represents, since you can't change that,
would it be better if you chose a more suitable target device?
For gLCD the best targets are ESP32 then is 18F then AVR, least best are 16F targets.
If I was you I would choose and alternative to the 16F. If you get get stuck with choosing an alternative device, I can help you further.
Martin

peterUA
Posts: 3
Joined: Sun Nov 10, 2024 4:55 pm

Re: PIC16F18877+GLCD ST7796

Post by peterUA »

Hi Martin!
There are many different modules on different chips in my region. I have difficulty choosing
free for makers ESP32.jpg
free for makers ESP32.jpg (86.85 KiB) Viewed 44 times
FC10_choose_ESP32.jpg
FC10_choose_ESP32.jpg (45.15 KiB) Viewed 44 times
Which specific module on which chip is Matrix supposed to be used freely? Everything else is clear. Thank you.
Petro

mnfisher
Valued Contributor
Posts: 1518
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 726 times

Re: PIC16F18877+GLCD ST7796

Post by mnfisher »

Out of interest - I took a look at the component for this - the 'offending' buffer is used in ClearDisplay - and as it is a local variable needs to be allocated on the stack - this has limited space (128 bytes).
So - this gives a couple of options - one is to make the buffer global (which then always uses space - so frowned upon) - the other is to make it smaller. This will make ClearDisplay run slightly slower - I changed it to 60 bytes - so it requires 2 calls to SPITransfer instead of 1 to write 80 or 120 bytes (for 16 / 18 bit mode)
If you'd like to try it - copy the attached file to C:\ProgramData\MatrixTSL\FlowcodeV10\Components (back up the file there first - although it can be replace using the update feature). You'll need to reload the test program into FC afterwards changing this file...

Martin
Attachments
gLCD_ST7796_SPI.fcpx
(19.07 KiB) Downloaded 1 time

mnfisher
Valued Contributor
Posts: 1518
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 726 times

Re: PIC16F18877+GLCD ST7796

Post by mnfisher »

An alternative would be to use the main display buffer - and not use a separate one in ClearDisplay...

Martin

Post Reply