ATSAM20C adding a display using MPLab Harmony - Page 1
Forum section: electronics / general

author: DLXXV
author_rank: Newbie
timestamp: October 11, 2023, 04:34:19 am
content: Hey guys,Thanks for having me. I’m having an issue that’s making me want to switch MCUs but I don’t really want to.The ATSAMC20N is the only 5v I can find with the power and enough pins. I don’t want to use a bunch of level shifters and io expanders. Anyway, the issue I’m having is adding a display to my project.I want to use a simple and cheap ST7789 SPI display but can’t figure out how to do it. Microchip’s tutorials and examples are all over the place depending on the chip, the family and often thinks you should have a dev board. So I’m having trouble finding how to add this display. I’ve done a lot of trials and searching but not much luck.From what I have gathered it looks as though I am to use the GLCD module from MCC in Harmony but my chip’s core doesn’t include those libraries. Any suggestions? Thanks. I can had that module it appears I would be able to make the driver with Harmony but as I said I don’t have that module listed.

author: ataradov
author_rank: Super Contributor
timestamp: October 11, 2023, 05:24:11 am
content: GLCD is a peripheral for controlling segment LCD displays. SAM C2x don't have that, only SAM L2x devices have that peripheral. But it is also useless for ST7789.There is not support for ST7789 in Harmony, so you would have to either make a driver yourself or use one of many available from various sources. It will not fit exactly into the Harmony ecosystem, so you would just have to use SPI or whatever interface your display supports and bridge that to the actual driver.If you want to use graphical library from Harmony, then your only option is to implement the driver in a way that meets the requirements of the graphics library. There is a generic driver that can be used as a template, but I don't think it will work as is.The only demo application for the SAM C20/C21 (gfx_apps_sam_c20_c21/tree/master/apps/legato_quickstart) uses ILI9488 driver, which should be close to ST7789 in principle. But it is not something you can just drag and drop, some manual programming would be required.Also, keep in mind that ST7789 does not support 5V operation, so you need to make sure you use appropriate level shifters.

author: DLXXV
author_rank: Newbie
timestamp: October 11, 2023, 05:54:28 am
content: I’m not worried about using the gfx tools with harmony. I just want a working display. I’ve never made a display driver though so I’m totally in the dark about where to start. There are some arduino drivers I can look at and rewrite but I don’t really know what to look for when writing it. As far as the ILI9488, what differences should I be looking at between the two? Memory management or clocks or something else?Thanks

author: DLXXV
author_rank: Newbie
timestamp: October 11, 2023, 06:03:48 am
content: Also, where is this generic driver? I couldn’t find anything like that at all. If so I could likely use the template to add 7789 functionality to it. Because when I read some I for from Microchip they said that the GLCD was the generic driver. Which is why I was looking for it

author: ataradov
author_rank: Super Contributor
timestamp: October 11, 2023, 06:06:21 am
content: Read the datasheets for both, I don't know know all the differences. They will have different initialization procedures and register set, for sure. They may be very close. And even if the controllers are close, there may be differences in initialization values for a specific panel. But assuming it is just a random display from AliExpress, some generic values is the best you will get anyway.But if you don't want Harmony gfx, then using Harmony drivers is not the most optimal thing anyway.Take a generic Arduino driver and add the SPI interface from the Harmony driver.I'll also attach my test code for this controller. The code is for SAM D11 and does not use anything Harmony. But the driver itself is universal.

author: ataradov
author_rank: Super Contributor
timestamp: October 11, 2023, 06:09:36 am
content: Quote from: DLXXV on October 11, 2023, 06:03:48 amIt should be somewhere in GFX components. No idea where, I don't have MPLAB or Harmony at home.Look at the demo project I linked, it uses that generic driver.Quote from: DLXXV on October 11, 2023, 06:03:48 amGLCD is generic for segment LCD displays. ST7789 is a TFT display, completely different thing.

author: DLXXV
author_rank: Newbie
timestamp: October 11, 2023, 06:32:06 am
content: Thanks a lot for the help. I’ll have a look at the file and do some tests when I get home. And yeah, it’s a generic AliExpress display but I assume most ST7789 controllers are going to be similar

author: ataradov
author_rank: Super Contributor
timestamp: October 11, 2023, 06:37:05 am
content: Quote from: DLXXV on October 11, 2023, 06:32:06 amAll ST7789 controllers are the same, but they are controlling a panel of pixels, and those are different. In the controller there are settings for all sorts of bias voltages and other things that are specific to the panel. Some generic version of those settings usually works, at worst it will shorten the life time of the panel a bit or will result in a sub-optimal picture quality.

author: DLXXV
author_rank: Newbie
timestamp: October 11, 2023, 07:15:10 am
content: I see. That makes sense. Thanks for the info

author: dietert1
author_rank: Super Contributor
timestamp: October 11, 2023, 12:43:43 pm
content: Usually one finds demo software starting from the display product. The seller can help with a link to a zip archive. There should be ready to compile code to get a start. Of course you need to fit in the SPI transfer using a library for your MCU, but that's fast.Regards, Dieter