SPI for LCD controller, RS problem maybe
Moderators: RoccoMarco, lbednarz, tfAteba
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
When I had OSPEED set to highest, it did what you saw with CS. Looking at the logic analyzer, things look more correct. I think the problem is my CS through NSS is just not working as expected. I ran the Arduino test code to make sure the LCD worked and looked at its timing as well which is very similar to what I have no minus the CS operation. I'm gonna try and control it by hand first
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
I spent at least 8 hours on this last night and still not working. I've been trying to find ANY source code of someone use SPI with ChibiOS on the STM32F4 and not having any luck. All the examples in the GFX library are for a different processor.
Just to make sure the board worked, I compiled the Ardiuno code from the seller of the LCD and tried the LCD on a MEGA2560 and it worked flawlessly. So I know the board works and the startup routine I ported over should work as well.
What I am not certain about is the voltages. The MEGA is 5V and the LCD documentation says it works at 5V or 3.3V. I applied a 3.3V signal to the MOSI pin of the LCD and checked it at the LCD interface underneath and it looks correct. To me, that should word. That said, I saw there is some control bit stuff about voltage levels and I am not sure what those are specifically for. Are they for the LCD controller to the LCD panel? It would seem to me that this would be the case.
I've also looked through the SPI example in the testhal directory and I cannot see anything obvious that is wrong.
Given I am able to look at the Logic Analyzer output, what I am seeing appears to be sent correctly. I can decode the SPI and it's correct. I hooked the Arduino up to the Logic Analyzer as well and decoded with the same settings (Mode 3, MSB first) and they match.
I am using both divisors so the SCLK frequency I think measured around 300kHz (I might be wrong just going from memory) but nevertheless, pretty slow which is what I wanted just to get it working.
I tried different combinations of spiSend and originally had spiStartSendI from the code example, but the results were the same on the Logic Analyzer.
All I can think is that maybe somehow I am sending somethings in the wrong order and the LCD is getting confused and I need to turn off CS immediately, reset the LCD, and then go from there in the code, but ran out of time. You would think it wouldn't be this difficult! I'm sure it is something simple I am missing.
The one area I am not sure is how spiAquireBus is working so I need to go look at that. I've read ALL the documentation from ST so I understand what is supposed to happen. And spiSelect is just controlling the CS signal so I know that works properly. I'll continue digging.
Just to make sure the board worked, I compiled the Ardiuno code from the seller of the LCD and tried the LCD on a MEGA2560 and it worked flawlessly. So I know the board works and the startup routine I ported over should work as well.
What I am not certain about is the voltages. The MEGA is 5V and the LCD documentation says it works at 5V or 3.3V. I applied a 3.3V signal to the MOSI pin of the LCD and checked it at the LCD interface underneath and it looks correct. To me, that should word. That said, I saw there is some control bit stuff about voltage levels and I am not sure what those are specifically for. Are they for the LCD controller to the LCD panel? It would seem to me that this would be the case.
I've also looked through the SPI example in the testhal directory and I cannot see anything obvious that is wrong.
Given I am able to look at the Logic Analyzer output, what I am seeing appears to be sent correctly. I can decode the SPI and it's correct. I hooked the Arduino up to the Logic Analyzer as well and decoded with the same settings (Mode 3, MSB first) and they match.
I am using both divisors so the SCLK frequency I think measured around 300kHz (I might be wrong just going from memory) but nevertheless, pretty slow which is what I wanted just to get it working.
I tried different combinations of spiSend and originally had spiStartSendI from the code example, but the results were the same on the Logic Analyzer.
All I can think is that maybe somehow I am sending somethings in the wrong order and the LCD is getting confused and I need to turn off CS immediately, reset the LCD, and then go from there in the code, but ran out of time. You would think it wouldn't be this difficult! I'm sure it is something simple I am missing.
The one area I am not sure is how spiAquireBus is working so I need to go look at that. I've read ALL the documentation from ST so I understand what is supposed to happen. And spiSelect is just controlling the CS signal so I know that works properly. I'll continue digging.
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
Also,
I see I have MMC_SPI and SPI stuff in the halconf.h turned on, does this matter? I am going to turn off the mutual exclusion code because only one device will be on this SPI2 port, but I just want to make sure I understand if I need that stuff turned on or if I am making some sort of conflict.
I see I have MMC_SPI and SPI stuff in the halconf.h turned on, does this matter? I am going to turn off the mutual exclusion code because only one device will be on this SPI2 port, but I just want to make sure I understand if I need that stuff turned on or if I am making some sort of conflict.
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
SUCCESS!
The problem ended up being, the person who sold me the display sent a zip file with multiple projects. While they *say* the same LCD controller in all of them, I realized the initialization routines were different between them. So I took the ones out of the Arduino file and sure enough, it works. I can even run at the fastest SPI speed (with default ChibiOS speed settings). Haha, it was SO SLOW to fill the screen. Right now I am optimizing my routines to speed up the code.
Next step....DMA with SPI! Haven't used it before but necessary for this project.
The problem ended up being, the person who sold me the display sent a zip file with multiple projects. While they *say* the same LCD controller in all of them, I realized the initialization routines were different between them. So I took the ones out of the Arduino file and sure enough, it works. I can even run at the fastest SPI speed (with default ChibiOS speed settings). Haha, it was SO SLOW to fill the screen. Right now I am optimizing my routines to speed up the code.
Next step....DMA with SPI! Haven't used it before but necessary for this project.
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
One thing I notice is that between each byte being transmitted there is a gap of about 3uS. Is there any way of shortening that?
In this code all that is happening is multiple spiSends in a row in a for loop, nothing else.
In this code all that is happening is multiple spiSends in a row in a for loop, nothing else.
Re: SPI for LCD controller, RS problem maybe
Good to hear that you got your display finally working!
As I told you, you must take a look into the datasheet. The problem with wrong sample code shipped with the wrong display happens a lot and you're not the first one. There was even a case were a display with a 16-bit parallel interface was shipped by default in 8-bit configuration...
~ Tectu
As I told you, you must take a look into the datasheet. The problem with wrong sample code shipped with the wrong display happens a lot and you're not the first one. There was even a case were a display with a 16-bit parallel interface was shipped by default in 8-bit configuration...
~ Tectu