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: 142
  • ST7789_240X240.bas
    15 KB · Views: 128
  • _SPI_Library.bas
    6 KB · Views: 141
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 129
  • _SetUpAmicus18.bas
    2.9 KB · Views: 121
Hi Cam.. Looking at your code... a) RASET and CASET have to be set before writes

RASET and CASET are byte only for some reason you have 360 in both?

if you use X1 and Y1 as a word you cam use x1.HB and x1.LB then the RASET will initialise properly
Hi I,
Yes, RASET confused me, in the CODE it's PASET, no RASET?
I have Call SPI_sendcmd(ST77XX_RASET) //Row addr set ? ] commented out, I can't remember if I changed it to get it to compile?
C
 
There is no need to set the column address and row address in the init.

Just remember... RASET and CASET has two WORD parameters... two sets of high and low. ( 4 bytes in total)

if you need to plot a point only x1 and y1 are needed.. If you set a window the pixels are automatically drawn within the window.

I will use window when I draw characters as the will be x pixels wide and y pixels high.
 
Hi I,
I just used your CODE within mine, and much of this didn't compile?

---------------------------------------------
If x >= width Then
x=x0
y = y + size
If(y>=height)Break;//
LCD_ShowChar(x,y,*P,size,1);
x+=size/2;
P++;
Wend
-------------------------
C
 
The post in #81 is working here.. BUT!! I'm on a pic18f46k22 so there will be slight differences..

The video shows that code running.. I almost always show skeletal code. I then beef up with error checking and comments..
 
The post in #81 is working here.. BUT!! I'm on a pic18f46k22 so there will be slight differences..

The video shows that code running.. I almost always show skeletal code. I then beef up with error checking and comments..
Hi I,
Yes, well done.
I'll just keep trying, and look for the differences, or use my OSC and SPI set up.
I'll also recheck my wiring. I could add a digital anayliser to see what the SPI is doing.
C.
 
the SPI init is DEAD simple.... SSPSTAT and SSPCON1...

TRISC = 0x0 // until i do read
SSPSTAT = 0x40 // bit 6 is CKE which is on
SSPCON1 = 0x31 // SPEN on CPK on and fosc /16

I can only get it to read in mode 3.. However! Datasheet said the LCD runs in mode 0..

mode 0 is cke and cpk = 0. sspstat = 0 sspcon1 = 0x11
 
the SPI init is DEAD simple.... SSPSTAT and SSPCON1...

TRISC = 0x0 // until i do read
SSPSTAT = 0x40 // bit 6 is CKE which is on
SSPCON1 = 0x31 // SPEN on CPK on and fosc /16

I can only get it to read in mode 3.. However! Datasheet said the LCD runs in mode 0..

mode 0 is cke and cpk = 0. sspstat = 0 sspcon1 = 0x11
Hi I,
I'll bear this in mind!
Regarding the LED connection on the screen. How do you switch it?
C
 
Mine just has a wire to 3V as there is a current limit resistor on mine... To be safe

the circuit on mine has a 1k into a NPN with a 3R9 to ground.. so a 3v supply will turn it on.

If your screen is white, then its working or you wouldn't see anything.. If it was initializing the screen would have a random mess all over the screen until you clear it.
 
Mine just has a wire to 3V as there is a current limit resistor on mine... To be safe

the circuit on mine has a 1k into a NPN with a 3R9 to ground.. so a 3v supply will turn it on.

If your screen is white, then its working or you wouldn't see anything.. If it was initializing the screen would have a random mess all over the screen until you clear it.
Hi I,
Mine has a 3.3v rack, that I switch on, and it goes white, then it goes messy as you say. This is with my set up, but I'm trying your OSC at the moment.

I always have trouble with SDO and SDI! Is the TFT_SDI MOSI or MISO (Master Out Save In)?

EDIT: I think I've figured out SDO on the screen TFT_SDO = MISO
C
 
Last edited:
SPI... Pin 3 is clk.. Pin 5 is SD0 (data to the LCD ) .. Pin 4 comes later SDI ( data from the LCD )

Micro SDO pin 5 ____ LCD pin6 MOSI (SDI)
Micro SDI pin 4 ____ LCD pin9 MISO (SDO)

One other thing... may be important. Some of these initialize wrong so you may need to try rotation.

the MADCTL does this.... MY up'ends the rows.. MV up'ends the columns MV exchanges them.
ML up'ends the vertical refresh, MH up'ends the Horizontal refresh .. Up'ends is my way of saying it draws the pixels backwards..
_________________________________________
| MY | MX | MV | ML | BGR | MH | X | X | // 0x36

I set mine to 0x8 as the colors are inverted

Swap the 0x8 in my code to 0x48..

if it don't work swap it back... Funnily enough the code I pinched had 0x48 in the init.
 
SPI... Pin 3 is clk.. Pin 5 is SD0 (data to the LCD ) .. Pin 4 comes later SDI ( data from the LCD )

Micro SDO pin 5 ____ LCD pin6 MOSI (SDI)
Micro SDI pin 4 ____ LCD pin9 MISO (SDO)

One other thing... may be important. Some of these initialize wrong so you may need to try rotation.

the MADCTL does this.... MY up'ends the rows.. MV up'ends the columns MV exchanges them.
ML up'ends the vertical refresh, MH up'ends the Horizontal refresh .. Up'ends is my way of saying it draws the pixels backwards..
_________________________________________
| MY | MX | MV | ML | BGR | MH | X | X | // 0x36

I set mine to 0x8 as the colors are inverted

Swap the 0x8 in my code to 0x48..

if it don't work swap it back... Funnily enough the code I pinched had 0x48 in the init.
Hi I,
Thanks.
I have added a digital analyser, and it's showing the CLK is not equal 'ticks'. This is happening even with any of my old 'other' programs too. I'll have to sort this out first.
C
 

Latest threads

New Articles From Microcontroller Tips

Back
Top