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: 287
  • ST7789_240X240.bas
    15 KB · Views: 255
  • _SPI_Library.bas
    6 KB · Views: 265
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 249
  • _SetUpAmicus18.bas
    2.9 KB · Views: 244
Hi,
I have some 18F4620 PICs, I can try on of these.
What do you think?
C
 

Attachments

  • 18F46_K_20 comparison.jpg
    18F46_K_20 comparison.jpg
    196 KB · Views: 54
Okay.. More news.... The pic18f46k20. is now working but at 3.8v and!! with your code AND!! at 8Mhz.

3.6v isn't enough.. The pic needs at least 3.8v to gey a good SPI clock at that speed. The LCD is messing the clock and data up as it needs that tiny bit extra.
https://youtube.com/shorts/Kmqh_jAUoOA?feature=share
 
Okay.. More news.... The pic18f46k20. is now working but at 3.8v and!! with your code AND!! at 8Mhz.

3.6v isn't enough.. The pic needs at least 3.8v to gey a good SPI clock at that speed. The LCD is messing the clock and data up as it needs that tiny bit extra.
https://youtube.com/shorts/Kmqh_jAUoOA?feature=share
Hi I,
Stop the press!! I was just about to swap the 46K20 to 4620 on my board.

I notice that you and, I think D are both using TTH PICs, where mine is surface mount, I wonder if there's a difference. Something to remember!
Have you tried the same CODE on my board?

I was going to change the voltage regulator on my board, but the 18F46K20 only goes to 3.6V. Where the 18F4620 goes to 5.5V

I've been searching for other clues and see lots of SPI pull up resistors and caps mentioned.

C.
 
No.. The max on the pic18f46k20 is 4.2V Max! So I can run it from a 18650 3.7v battery ( which is 4.2v really) and I paralleled two diodes to bring it down to 3.8v (ish)..

Pullups do nothing and caps will increase the already bad slew... The shortest wires ever and that increased voltage seems to work.
 
No.. The max on the pic18f46k20 is 4.2V Max! So I can run it from a 18650 3.7v battery ( which is 4.2v really) and I paralleled two diodes to bring it down to 3.8v (ish)..

Pullups do nothing and caps will increase the already bad slew... The shortest wires ever and that increased voltage seems to work.
Hi I,
I checked the comparison in #362 and the D/S and both say 3.6V.
C
 
Hi I and D,
I had a little break from electronics/programming, and today, my brain cell got out of it's hammock and I switched on the PCB.

I tried a few of the failing programs, then tried an older very similar PCB, and this works??
Comparing the two PCBs, shows odd results, as one almost works with many of the test programs and one doesn't.

I'm now going to get both working as best as they can and try some tests with voltages and oscilloscope.

Are there any suggestions what to focus on?
Cheers, C.
 
When you have a PCB to make, grounding is key. On the little board I have here, you have good grounding and a decent power plane but the grounding traces from the MCU's have to travel a small way to get to a BIG ground. When I design I use a 40mil track and just connect to the pins with a really small length 15mil spur. That board had the ability to track straight through from the pin to the power plane on the other side.

If you observed ground bounce, your circuits would have more caps and bigger power rails to stop it.
 
When you have a PCB to make, grounding is key. On the little board I have here, you have good grounding and a decent power plane but the grounding traces from the MCU's have to travel a small way to get to a BIG ground. When I design I use a 40mil track and just connect to the pins with a really small length 15mil spur. That board had the ability to track straight through from the pin to the power plane on the other side.

If you observed ground bounce, your circuits would have more caps and bigger power rails to stop it.
Hi I,
I had not thought of the GND track and the GND plane, before, but now it's obvious.
I'll try connecting through the board.

I've not observed ground bounce, and don't know what it is, or how to test for it.
C
 
Basically a track has an amount of resistance (hence the bigger the better)

lets say we had 1 ohm, its less than that but it'll get the point across, then you imagine LATC changing from 3v to zero v at 16 Mhz.. Also! visualize a spring board and a normal child jumping up and down on the end. Then! a fat child bouncing up and down.. the child is the current and the board movement id the voltage.

1 ohm and thin child (5mA ish) I x r is 5mV, then a fat child (10mA) = 10mV.. seems fine. BUT you will have more than 10 children as the micro can drive 16 IO's at a time.. if you have 100mV of bounce things stop working well.

I was trying to run an SD card at 3V3 and a noise of 100mV played havoc... I know I'm at extremes here but It helps to reduce noise from pins.. Obviously internally you have address, control and data busses all running super fast.
 
Basically a track has an amount of resistance (hence the bigger the better)

lets say we had 1 ohm, its less than that but it'll get the point across, then you imagine LATC changing from 3v to zero v at 16 Mhz.. Also! visualize a spring board and a normal child jumping up and down on the end. Then! a fat child bouncing up and down.. the child is the current and the board movement id the voltage.

1 ohm and thin child (5mA ish) I x r is 5mV, then a fat child (10mA) = 10mV.. seems fine. BUT you will have more than 10 children as the micro can drive 16 IO's at a time.. if you have 100mV of bounce things stop working well.

I was trying to run an SD card at 3V3 and a noise of 100mV played havoc... I know I'm at extremes here but It helps to reduce noise from pins.. Obviously internally you have address, control and data busses all running super fast.
Hi I,
OK, good explanation.

I have 3x of those PCBs, 2x are working ok (??) and 1x doesn't. Yesterday, I swapped the crystal/caps then the PIC on 1x of them, and it started working. There have been similar mysteries like this, and you may recall that I had similar problems with the project they were designed for also.

I just tried 'jumping' the 3.3v and GND tracks in various places, but it still doesn't work. I tried comparing power lines with the oscilloscope, but I don't see ripples or anything. I'll drill some holes and connect through the board.
Did you ever get the one I sent you working reliably?

EDIT: Here's your earlier post. which gives us a clue. I'll write to Microchip https://www.electro-tech-online.com/threads/display-tft-st7789-oshonsoft-basic.166219/post-1459615
C
 
Last edited:
Hi C.. no I never got it working... I even slowed the SPI down to 2Mhz but nada..

I can put the pic1846K22 on breadboard and using the internal crystal and I can get 8Mhz spi working
using YOUR code.
 
Hi C.. no I never got it working... I even slowed the SPI down to 2Mhz but nada..

I can put the pic1846K22 on breadboard and using the internal crystal and I can get 8Mhz spi working
using YOUR code.
Hi I,
Ok, I wonder if the 18F46K22 are the same, but you got good ones?
I'll write to Microchip.
Cheers, C.
 
I have been using this chip ( and it's little brother, pic26k22) for ages.. I have never seen a problem
Always run with a 20Mhz xtal and 22pf's to stabilize... However!!! I HATE linear regs. A good switched supply seems to keep me sane.

If I really need to, I swap out the lil 7805 for these little beauty's..

These are 1 amp and for the extra pennies are worth it.. I repair speccy's with them.
 
Hi I,
Ok, I wonder if the 18F46K22 are the same, but you got good ones?
I'll write to Microchip.
Cheers, 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).
 
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 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.
That's why I've chosen the UC1609 for our latest project, as it's 3.3V - because I want to run from a single Li-Ion cell (or a couple in parallel). As it needs to run a LONG time, with the processor in sleep, and the LCD shutdown, it would be messy to try and use 5V devices.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top