Changing from LCD16bpp to LCD8bpp
Hello, I am facing an issue where the rendered frame buffer is printed on the display as gibberish pixels.
I'm using the Nucleo F746ZG and interfacing it (over SPI) with an external display controller that writes to a 240*320 display. I was not able to locate the exact color depth of the display in the datasheet, but the information suggests that each pixel has 2ddot. Given RGB, I assumed 6bpp is the correct format.
Initially I set up touch gfx to render a 16bpp frame buffer. With the 16bpp rendering I used the following code segment to send the rendered gibberish buffer to my display controller and get some random pixels printed.
In TouchGFXGeneratedHAL.cpp:
void TouchGFXGeneratedHAL::flushFrameBuffer(const touchgfx::Rect& rect)
{
uint32_t ibaseaddr = (uint32_t)getClientFrameBuffer();
uint16_t istride = lcd().framebufferStride();
uint16_t HParam = 1;
uint16_t WParam = 1;
uint16_t HScale = 100*HParam;
uint16_t WScale = 100*WParam;
uint16_t rot = 128;//<< rotates 90 degrees
// send frame buffer to display
ImgCpyRotScale( 120, //Destination Window center X coordinate.
160, //Destination Window center Y coordinate.
ibaseaddr, //Source Window base address.
istride, //Source Window stride.
rect.width-1, //Source Window width.
rect.height-1, //Source Window height.
120, //Source Window center of transformation X coordinate.
160, //Source Window center of transformation Y coordinate
0xC0, rot, //Fill color (if FILL is enabled) | Rotation value
HScale, HScale, //left scale % | right scale %
WScale, WScale, &cpyctrl); // top scale % | bottom scale %
WaitGfxDone();
PanelUpdate(0, 320-1);
WaitUpdDone();
}
I have tested the display controller SPI command and its arguments, it works as expected. But I believe the 16bpp frame buffer does not render the correct display buffer. To fix this I made the necessary changes in CubeMX and ported over the changes manually. The main change was inside TouchGFXConfiguration.cpp.
The display object changed from:
static LCD16bpp display;to
static LCD8bpp_RGBA2222 display;
This causes a problem where during touch gfx initialization, hal.initialize() fails 4 instructions after returning from touchgfx GPIO init.

Since the source code for HAL initialize is inside the compiled library, I am not able to debug why zero (0x0) is copied to the r3 register through this instruction.
ldr r3,[r3,#12] // copies zero to r3r3 Memory address at the time of ldr instruction:

resulting in a hard fault when branching the r3 register
blx r3
