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: 227
  • ST7789_240X240.bas
    15 KB · Views: 198
  • _SPI_Library.bas
    6 KB · Views: 206
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 195
  • _SetUpAmicus18.bas
    2.9 KB · Views: 187
Hi D,
OK.
Ian and I have 18F46K20 PICs.

I see that your CONFIGS (Are these fuses?) are different from the CODE you posted, so you are a bit more advanced that I am.

If I can suggest that you use as few lines as possible so us slow ones can keep up, please.

I also noticed that the CONSTANTS names were identical ,so I changed them, and here they are, to save you typing
C.
Code:
Const LCD_NOP = 0x00
Const LCD_SWRESET = 0x01
Const LCD_RDDID = 0x04
Const LCD_RDDST = 0x09

Const LCD_SLPIN = 0x10
Const LCD_SLPOUT = 0x11
Const LCD_PTLON = 0x12
Const LCD_NORON = 0x13

Const LCD_INVOFF = 0x20
Const LCD_INVON = 0x21
Const LCD_DISPOFF = 0x28
Const LCD_DISPON = 0x29
Const LCD_CASET = 0x2a
Const LCD_RASET = 0x2b
Const LCD_RAMWR = 0x2c
Const LCD_RAMRD = 0x2e

Const LCD_PTLAR = 0x30
Const LCD_COLMOD = 0x3a
Const LCD_MADCTL = 0x36
Const LCD_DISP_FUNC = 0xB6


Const LCD_MADCTL_MY = 0x80
Const LCD_MADCTL_MX = 0x40
Const LCD_MADCTL_MV = 0x60'20
Const LCD_MADCTL_ML = 0x10
Const LCD_MADCTL_RGB = 0x00

Const LCD_RDID1 = 0xda
Const LCD_RDID2 = 0xdb
Const LCD_RDID3 = 0xdc
Const LCD_RDID4 = 0xdd


Const LCD_BLACK = 0x0000
Const LCD_RED = 0x001f
Const LCD_BLUE = 0xf800
Const LCD_GREEN = 0x07E0
Const LCD_YELLOW = 0x07ff
Const LCD_MAGENTA = 0xf81f
Const LCD_CYAN = 0xffe0
Const LCD_WHITE = 0xffff
 
After MANY attempts I cannot get this LCD working on this board.

I fear the pic18f46k20 isn't good.. I have ordered one and I'll make a little circuit to mimick yours.

I'll let you know how I get on.
 
After MANY attempts I cannot get this LCD working on this board.

I fear the pic18f46k20 isn't good.. I have ordered one and I'll make a little circuit to mimick yours.

I'll let you know how I get on.
Hi I,
I can't remember if I tested it or not, but I'd be surprised if I didn't!

Anyway:
Is the screen lighting up?
Is the LED flashing, at the beginning, and in the LOOP?
Have you tried removing the PICKIT3?

If all these fail, then send it back, and I'll swap the PIC. I'll PM my address.

EDIT: Lastly, try RESET by shorting the MCLR pin to GND.
C.
 
Last edited:
Trust me.. I can not see a clean clock on the SPI.. I am going to build a dummy, USING THE SAME CODE and if it works the chip on the lil board has been hammered by some spurious electrical goul!
 
I have tested the TFT with a 10 MHz SPI clock and the PIC18F46K20 running with an external 10 MHz crystal and a 4x PLL, and everything works perfectly. It’s worth mentioning that I’m using an HL-K18 prototype board, which usually has extra-long traces. Even though the clock signal is more sinusoidal than square, it still works without issues.
 
Trust me.. I can not see a clean clock on the SPI.. I am going to build a dummy, USING THE SAME CODE and if it works the chip on the lil board has been hammered by some spurious electrical goul!
Hi I,
Of course I trust you, I remember your Oscilloscope image. I wanted to test if there are differences between your PCB and mine. I've had none working programs that start after a RESET, and I wanted to exoperiment with yours.
C.
 
Hi D,
I'm interested in the differences between our 3x set-ups, starting with Ian's, and mine.
C.
 
Hi C; I have already left the configuration several times but I leave it again for the PIC18F46K20 with the oscillator using an external crystal.

View attachment 148466
Hi D,
Yes, thanks, but for some reason I have difficulty with reading this, and the combinations that make up a CONFIG.

e,g, for my PCB with on board programming, I need the MCLR PIN enabled, so if I simply switch to your settings, without reading all of the changes, I can get problems, so I need to know accurately if the changes apply to me.
C.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…