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: 53
  • ST7789_240X240.bas
    15 KB · Views: 53
  • _SPI_Library.bas
    6 KB · Views: 51
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 49
  • _SetUpAmicus18.bas
    2.9 KB · Views: 53
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.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top