ateneo
Posts: 2
Joined: Thu Feb 22, 2018 3:51 am

Bare Metal GPIO programming

Fri Feb 23, 2018 11:44 am

Hi, i have a Reaspberry PI 3 B. I have been reading BCM2835 datasheet.

This is my situation: i have a TFT 3.5 inch connected to GPIO which is WaveShare compatible with https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A). The loaded dtbt driver is waveshare35a. And i say "compatible" becouse is a clone one.The resolution is 320x480 and it seems insufficient for GPIO to drive this screen smooth with RetroPie emulated games. The maximum i have reached in speed with this TFT is 20MHZ (config.txt) since when you ask it more the pixels starts to look bad and different colours.

Taking into account this project at https://github.com/juj/fbcp-ili9341 he says that he bypass the LINUX OS to develope to a screen like this. He makes another tricks too, like having buffers of what pixels need to be updated, so this way he reachs the ~60 FPS.

The thing is that the code is only functional for ili9341, but i have an ili9486 controller. I would like to "port" or make something like this for my TFT.
The FrameBuffers projects which copy from /dev/fb0 to /dev/fb1 are insufficient.

Maybe i'm asking myself too much. All i have done is a NES emulator for Win32 in C and DirectX and that is all my knowladge.

My question is where should i start to programming at a Bare Metal level the GPIO?

Sorry im kinda lost.

LdB
Posts: 826
Joined: Wed Dec 07, 2016 2:29 pm

Re: Bare Metal GPIO programming

Fri Feb 23, 2018 12:08 pm

You are dealing with different things

https://github.com/juj/fbcp-ili9341
Is an SPI connected screen ... he gives you all the details but this is the key one
the theoretical SPI bandwidth comes out to 66.666 MiBits/second, giving a ceiling of 54.25fps.
That is the upper speed of the Pi SPI.

Now your screen uses the GPIO outputs raw and here comes the problem, the GPIO has a relatively slow bus connection and it has maximum speeds and they are

Pi1 .. 22Mhz
Pi2 .. 48Mhz
Pi3 .. 68Mhz

The fact your signal degraded at 20Mhz tells me you are on a Pi1.

The short answer is there is nothing you can do about it the PI GPIO can go no faster even in baremetal.

If you really want the speed and resolution get an SPI screen, use the HDMI output or buy one of the hundreds of HDMI to LCD adapter boards that exist and work on the Pi.

If you want some terms to google "Lontium LT8619B" and "TFP401" will give you a start for manufacturers of adapter boards.

juj
Posts: 26
Joined: Sat Nov 18, 2017 10:51 pm

Re: Bare Metal GPIO programming

Tue Jun 12, 2018 10:30 am

LdB wrote:
Fri Feb 23, 2018 12:08 pm
That is the upper speed of the Pi SPI.

Now your screen uses the GPIO outputs raw and here comes the problem, the GPIO has a relatively slow bus connection and it has maximum speeds and they are

Pi1 .. 22Mhz
Pi2 .. 48Mhz
Pi3 .. 68Mhz

The fact your signal degraded at 20Mhz tells me you are on a Pi1.

The short answer is there is nothing you can do about it the PI GPIO can go no faster even in baremetal.
When working on the fbcp-ili9341, I don't think the SPI bandwidth limitations I found were limits of the Pi hardware itself, but rather limits of the individual display controller chips. The maximum SPI speed I have been able to obtain is 140MHz with a Pi 3B and a MZ61581 controller based display, and also there I think there the limit might not be signal degradation, but rather just the inability of the MZ61581 controller to keep up at higher speeds.

The table at https://github.com/juj/fbcp-ili9341#whi ... cp-ili9341 lists maximum bus speeds of different displays I have been experimenting with, under the "Obtained Bus Speed" column.

ILI9486 is definitely the black sheep of all of the SPI display controllers (or at least WaveShare's realization of ILI9486 is, not sure if the limit is actually vendor or controller or just manufacturing variance specific). It is by far the slowest controller that I have with respect to its resolution, all others are able to keep up moderately with respect to their size, and get up to decent frame rates.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 7 guests