Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Display TFT ST7789 (OshonSoft Basic).

DogFlu66

Member
I leave the library to use ST7789 TFT display, I have translated one that is in C language. But unfortunately I have not been able to get it to work yet. I leave the files in case someone with more experience with these displays can review it.
 

Attachments

  • Main_ST7789.bas
    1.5 KB · Views: 189
  • ST7789_240X240.bas
    15 KB · Views: 171
  • _SPI_Library.bas
    6 KB · Views: 185
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 174
  • _SetUpAmicus18.bas
    2.9 KB · Views: 161
They even work using software SPI, but the speed is appalling :D

It is useful though for testing purposes, or when you inadvertently allocated the PCB SPI pins to non-SPI pins on the PIC, while you can allocate most peripheral pins to various of the physical pins it's not universal, and varies from PIC to PIC.
Hi N,
The PCBs I'll use, have the same SPI setup as 'D's CODE, nice :)
C
 
The SPI speed setting is 4Mhz with the system clock working as internal and at 64Mhz.
'Internal clock 64Mhz.
Call _Setup_Oscillator(_OSC_16MHz_HF)
Call _SET_PLL4(_PLL_ON)
Call _Interrupts_Mode(_DISABLE_PRIORITY)
'*********************************************
Call _SPI1_Init(_SPI_MODE2, _SPI_MASTER_SPEED1 | _SPI_ENABLE) 'CLK 4Mhz (64Mhz)

I have also been able to verify a basic error in the configuration of the SPI pins, I have used the following one, which is incorrect:
' Define MSSP module pins in SPI mode
Symbol _SPI_RST = PORTC.0 ' RST RESET pin
Symbol _SPI_DC = PORTC.1 ' DC (SS) Data/Command pin
Symbol _SPI_CS = PORTC.2 ' CS Chip Select pin
Symbol _SPI_SCK = PORTC.3 ' SCK as output
Symbol _SPI_SDI = PORTC .4 ' SDI as input -> SDO
Symbol _SPI_SDO = PORTC.5 ' SDO as output -> SDI

And you have to use the following:
' Define MSSP module pins in SPI mode
Symbol _SPI_RST = LATC.0 ' RST RESET pin
Symbol _SPI_DC = LATC.1 ' DC (SS) Data/Command pin
Symbol _SPI_CS = LATC.2 ' CS Chip Select pin
Symbol _SPI_SCK = LATC.3 ' SCK as output
Symbol _SPI_SDI = PORTC.4 ' SDI as input -> SDO
Symbol _SPI_SDO = LATC.5 ' SDO as output -> SDI
 
The SPI speed setting is 4Mhz with the system clock working as internal and at 64Mhz.
'Internal clock 64Mhz.
Call _Setup_Oscillator(_OSC_16MHz_HF)
Call _SET_PLL4(_PLL_ON)
Call _Interrupts_Mode(_DISABLE_PRIORITY)
'*********************************************
Call _SPI1_Init(_SPI_MODE2, _SPI_MASTER_SPEED1 | _SPI_ENABLE) 'CLK 4Mhz (64Mhz)

I have also been able to verify a basic error in the configuration of the SPI pins, I have used the following one, which is incorrect:
' Define MSSP module pins in SPI mode
Symbol _SPI_RST = PORTC.0 ' RST RESET pin
Symbol _SPI_DC = PORTC.1 ' DC (SS) Data/Command pin
Symbol _SPI_CS = PORTC.2 ' CS Chip Select pin
Symbol _SPI_SCK = PORTC.3 ' SCK as output
Symbol _SPI_SDI = PORTC .4 ' SDI as input -> SDO
Symbol _SPI_SDO = PORTC.5 ' SDO as output -> SDI

And you have to use the following:
' Define MSSP module pins in SPI mode
Symbol _SPI_RST = LATC.0 ' RST RESET pin
Symbol _SPI_DC = LATC.1 ' DC (SS) Data/Command pin
Symbol _SPI_CS = LATC.2 ' CS Chip Select pin
Symbol _SPI_SCK = LATC.3 ' SCK as output
Symbol _SPI_SDI = PORTC.4 ' SDI as input -> SDO
Symbol _SPI_SDO = LATC.5 ' SDO as output -> SDI
Hi D,
Here is the SPI set-up on my PCBs:

This works with the Nokia screen and all of the other peripherals.

It may not be conventional, but I've got used to it.
The init_SPI is called for in the program.
C
SPI.jpg
 
Hi D,
Here is the SPI set-up on my PCBs:

This works with the Nokia screen and all of the other peripherals.

It may not be conventional, but I've got used to it.
The init_SPI is called for in the program.
C
View attachment 146585
But what's your SPI speed?, the 4MHz setting in post #22 will give pretty slow results - with a 64MHz clock you should be looking at 16MHz.
 
I know, but you didn't (and still haven't) mentioned what SPI speed you're trying to use - and didn't post any relevant code.
Hi N,
I can't remember, and my limited brain can only concentrate on one thing at a time, and at the moment, I'm a bit busy. I'll let you know, when I dig further.
C
 
The SPI speed setting is 4Mhz with the system clock working as internal and at 64Mhz.
'Internal clock 64Mhz.
Call _Setup_Oscillator(_OSC_16MHz_HF)
Call _SET_PLL4(_PLL_ON)
Call _Interrupts_Mode(_DISABLE_PRIORITY)
'*********************************************
Call _SPI1_Init(_SPI_MODE2, _SPI_MASTER_SPEED1 | _SPI_ENABLE) 'CLK 4Mhz (64Mhz)

I have also been able to verify a basic error in the configuration of the SPI pins, I have used the following one, which is incorrect:
' Define MSSP module pins in SPI mode
Symbol _SPI_RST = PORTC.0 ' RST RESET pin
Symbol _SPI_DC = PORTC.1 ' DC (SS) Data/Command pin
Symbol _SPI_CS = PORTC.2 ' CS Chip Select pin
Symbol _SPI_SCK = PORTC.3 ' SCK as output
Symbol _SPI_SDI = PORTC .4 ' SDI as input -> SDO
Symbol _SPI_SDO = PORTC.5 ' SDO as output -> SDI

And you have to use the following:
' Define MSSP module pins in SPI mode
Symbol _SPI_RST = LATC.0 ' RST RESET pin
Symbol _SPI_DC = LATC.1 ' DC (SS) Data/Command pin
Symbol _SPI_CS = LATC.2 ' CS Chip Select pin
Symbol _SPI_SCK = LATC.3 ' SCK as output
Symbol _SPI_SDI = PORTC.4 ' SDI as input -> SDO
Symbol _SPI_SDO = LATC.5 ' SDO as output -> SDI
At the beginning of the thread it indicates the ST7789 TFT display controller. In any case, in a previous message I indicated that there is an error in the port declaration.
 
Last edited:
At the beginning of the thread it indicates the ST7789 TFT display controller. In any case, in a previous message I indicated that there is an error in the port declaration.
Hi D,
Is this meant for me or I?
Hopefully we'll get round the lack of display controller?
As I connect any component, I check each connection, and hopefully, I would spot the correct port declaration?
C
 
Those modules are either 81mm or 86mm the 86mm is the IL9341 if thats the one you bought I have one here and I'll write a driver for you in Oshonsoft.

If its the 81mm then I'll have to try and modify that driver on this post and test it somehow.
 
Those modules are either 81mm or 86mm the 86mm is the IL9341 if thats the one you bought I have one here and I'll write a driver for you in Oshonsoft.

If its the 81mm then I'll have to try and modify that driver on this post and test it somehow.
Hi I and D,
I've got the 81MM.

I don't want to make life difficult for you and D, so if you send a link to a more suitable one, then I'll re-order some.
C
 
Nope.. No more difficult I'll just order one to play with. Dog's code can't be far off.. and as I have the Il9341 code I'll just modify to suit..

Is yours a 240 x 240?
Hi I,
OK, good!
Mine's 2.8" 240X320, and has an SD socket.

Here's a photo (Out of focus!)
C.
 

Attachments

  • TFT screen.jpg
    TFT screen.jpg
    191.3 KB · Views: 84

Latest threads

New Articles From Microcontroller Tips

Back
Top