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: 286
  • ST7789_240X240.bas
    15 KB · Views: 254
  • _SPI_Library.bas
    6 KB · Views: 264
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 248
  • _SetUpAmicus18.bas
    2.9 KB · Views: 243
That sounds a very strange thing to do?, the problem is almost certainly something you're doing wrong.

First off, have you disabled slew rate control? (SLRCON registers), the default is ON, and this cripples SPI speed - it 'might' work at 8MHz, it might not, or it might work 'sometimes' - it's something you absolutely need to turn OFF. However, if it's not working at 2MHz, that's unlikely to be the issue - but it still wants turning OFF (it's up there with ANSEL, the defaults are stupid).
Hi N,
SLRCON =0.
C
 
Hi Nigel, The power supply will need to be concreate for this device to work on a 3V3 supply
I have had issues before running these chinesium LCD's, as have you. On the Fantastic "Geoff's projects" pages, they used the same screen on Pico's and Micromites (Pic32) but they supply 5V for the screen's power.

When I tested this on my breadboard, it works with a pic18f46k22, but not a pic18f46k20. the latter is 3v3 only... I think this is the problem The PSU on the breadboard is a 3V3 switch mode 7803 replacement.
Hi I,
I use 12V batteries, then 7805, then 3.3v LDO to get the 3.3v.
I've put the Regs that you suggest in the Farnell Basket.
C.
 
Hi,
Today, I took the PIC off one of the working boards, and swapped it with the PIC on the none working board, and 'in this case' with PICs swapped, the boards gave the same result, in the the previously working board still works.

So in this case it is the board that causes faults, so whether it's the Voltage regulation or capacitance something is happening beyond my understanding.

I've changed all of the other components on this board previously.
C.
 
Hi I,
I use 12V batteries, then 7805, then 3.3v LDO to get the 3.3v.
I've put the Regs that you suggest in the Farnell Basket.
C.

Are they cheaper at Farnell than at RS?, often things are - but not always, and sometimes they are more expensive?. It's also worth checking CPC (a division of Farnell) as they are often considerably cheaper.

For example, last week I was re-ordering some LED mounting clips, which we normally source from Farnell, they were £6.50 odd for 25, but out of stock, expected delivery date 10 weeks.

So I checked RS, in stock, but similar price for only FIVE!! - so I googled the manufacturers (Kingbright) part number, and up popped CPC, in stock, and only £4 for 25 - happy days!:D

On a similar theme, we use a LOT of four core cable, originally from RS, but it was always out of stock, then the P/N changed, more out of stock, and going from the number in stock when it was, we were the only people buying it :D Eventually they discontinued it entirely, and we ended up using a slightly inferior American cable from Farnell.

It's available on 100ft or 1000ft drums (because it's American), and rather bizarrely it was considerably cheaper to buy 10x100ft drums, than one 1000 foot drum (no problem, because we cut it into short lengths) - which made no sense. Anyway, we've been happily buying the little drums. But the other week I had to order more, so (as always) I checked the 1000ft drums - it was now cheaper than ten 100ft drums - so I ordered five drums, as there's a price break at five, they only had three in stock, but you get the price break anyway, and the other two will arrive later (they haven't yet).

It's often an adventure ordering parts! :D
 
Are they cheaper at Farnell than at RS?, often things are - but not always, and sometimes they are more expensive?. It's also worth checking CPC (a division of Farnell) as they are often considerably cheaper.

For example, last week I was re-ordering some LED mounting clips, which we normally source from Farnell, they were £6.50 odd for 25, but out of stock, expected delivery date 10 weeks.

So I checked RS, in stock, but similar price for only FIVE!! - so I googled the manufacturers (Kingbright) part number, and up popped CPC, in stock, and only £4 for 25 - happy days!:D

On a similar theme, we use a LOT of four core cable, originally from RS, but it was always out of stock, then the P/N changed, more out of stock, and going from the number in stock when it was, we were the only people buying it :D Eventually they discontinued it entirely, and we ended up using a slightly inferior American cable from Farnell.

It's available on 100ft or 1000ft drums (because it's American), and rather bizarrely it was considerably cheaper to buy 10x100ft drums, than one 1000 foot drum (no problem, because we cut it into short lengths) - which made no sense. Anyway, we've been happily buying the little drums. But the other week I had to order more, so (as always) I checked the 1000ft drums - it was now cheaper than ten 100ft drums - so I ordered five drums, as there's a price break at five, they only had three in stock, but you get the price break anyway, and the other two will arrive later (they haven't yet).

It's often an adventure ordering parts! :D
Hi N,
I don't buy much stuff really, and I do shop around.

Sometimes when I need something sooner, I compare baskets, and with 'no postage' one is cheaper, although other times, it's just easier to pay more than shop for hours.
Also I check the basket and have changed my mind as I may have 'gone off' a project. Retirement ay :)
C
 
Last edited:
Hi,
Ian suggested that the power supply could be a problem!

The PIC is normally powered by a 12V battery, though a 7805, then through a 3.3V LDO.
I tried a 5V battery before the LDO and a 3V cell after the LDO, and the PIC works powered by 3V after the LDO, and sometimes can be jumped to work 5V before the LDO.
There are capacitors, all around!
The crystal always works, but in this case, not working means a TFT screen using SPI.
It doesn't work when the 3.3V comes from my rework station.

So my PCB is affecting the 18F46K20! and in this case the weakest link is the 3.3V LDO
This problem is so intermittent, that it's difficult to figure out exactly how to proceed.
C
 
That sounds a very strange thing to do?, the problem is almost certainly something you're doing wrong.

First off, have you disabled slew rate control? (SLRCON registers), the default is ON, and this cripples SPI speed - it 'might' work at 8MHz, it might not, or it might work 'sometimes' - it's something you absolutely need to turn OFF. However, if it's not working at 2MHz, that's unlikely to be the issue - but it still wants turning OFF (it's up there with ANSEL, the defaults are stupid).
I have verified that the Oshonsoft compiler leaves it at 1 by default, in my case as I am using the Pic18F46K22 the value is SLRCON = %11111.

In my case, since all my projects work just fine, I keep it enabled. I still build a few that get installed in places with loads of electronics around. Honestly, I had totally forgotten about this register — I checked once that it was enabled by default and haven’t thought about it since.
 
@ Nigel post #380.. But That's good.. As most devices run up to 3.6V with no issue I use those batteries on a lil wireless unit we supply. The board gets up to 4.2V and I lick it down to 3.3V THEN kick a small bit up to 12v and a bit to 5v... Those screens will run at 3.6v I have tried it.
 
I have verified that the Oshonsoft compiler leaves it at 1 by default, in my case as I am using the Pic18F46K22 the value is SLRCON = %11111.

In my case, since all my projects work just fine, I keep it enabled. I still build a few that get installed in places with loads of electronics around. Honestly, I had totally forgotten about this register — I checked once that it was enabled by default and haven’t thought about it since.
Hi D,
All of my projects worked ok, until they didn't!
On the REMOTE CONTROL project I worked on for years, all of the peripherals worked, then started mysteriously not working as I consolidated them into the final units.

This project soon highlighted the problems.
C
 
Hi,
I've been looking at the 18F46K20 ERRATA D/Ss, and many are related to SPI.
The previous project using these boards, had 5 or 6 peripherals, all using SPI, and set to a particular SPI MODE. I haven't found yet a definitive setting for these ST7789 TFT screens yet, or whether they need to be set to 'my' settings, but suspect they are slightly different than my settings perhaps the CKL at REST setting causing these misfires?

These misfires, could of course be triggered by Voltage regulators or capacitance etc
C.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top