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
I set this is the config:
SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_CPHA | SPI_CR1_CPOL
SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_CPHA | SPI_CR1_CPOL
Re: SPI for LCD controller, RS problem maybe
SPI is defined with different modes which can be set with the CPOL and CPHA bits. Please read this article. Mode 3 means both bits set to one. This settings can be applied in the SPI config structure. It's the CR1 register content.
~ Tectu
~ Tectu
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
It's funny, I had that article up! Will try again later tonight, have some things I have to do. Going to look through the datasheet again to MAKE SURE these are being set right by me.
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
Still nothing, I think it's time to bust out the logic analyzer and check my data compared to what I am expecting.
Re: SPI for LCD controller, RS problem maybe
When you're having a logic analyzer, it should always be one of the frist steps. My oscilloscope as well as my logic analyzer are always plugged in and ready to use not even 20cm away from my keyboard 
When I find some time, I might take a look into your LCD controllers datasheet tonight. Do you happen to have two of these displays?
~ Tectu
When I find some time, I might take a look into your LCD controllers datasheet tonight. Do you happen to have two of these displays?
~ Tectu
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
I do have 2 and will probably order a few more so I can build a few prototypes. Yeah, the oscilloscope is ALWAYS on.
The logic analyzer I am having a bit of trouble with the software, it's the Open Logic version.
Re: SPI for LCD controller, RS problem maybe
Might I ask where you life? I guess it will be like 50 times faster when you'd send me an LCD of yours over instead of me ordering one from ebay 
Shipping would need to go to Switzerland. Standard envelope are quite cheap.
~ Tectu
Shipping would need to go to Switzerland. Standard envelope are quite cheap.
~ Tectu
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
Tonight I'm going to see if I can tackle this once and for all! Then we can talk about porting what I find to the GFX library so everyone can share in this.
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: SPI for LCD controller, RS problem maybe
Getting closer I think. This is the Logic Analyzer output. What I cannot figure out is why the Chip Select line is toggling? This is clearly wrong. I need it to go low. Any clue what could cause this?
Init wise for that pin, this is what I am doing:
The second part is from main(). I don't touch the pin any other way as I assumed it would be handled by the SPI driver.
Init wise for that pin, this is what I am doing:
Code: Select all
static const SPIConfig spi2cfg = {
NULL,
GPIOB,
12,
SPI_CR1_BR | SPI_CR1_CPHA | SPI_CR1_CPOL | SPI_CR1_SSI | SPI_CR1_SSM | SPI_CR1_MSTR
};
spiAcquireBus(&SPID2);
spiStart(&SPID2, &spi2cfg);
palSetPad(GPIOB, 12);
palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL | PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* NSS. */
palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* SCK. */
palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5)); /* MISO. */
palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* MOSI. */
spiSelect(&SPID2);
The second part is from main(). I don't touch the pin any other way as I assumed it would be handled by the SPI driver.
- Attachments
-
- Screen Shot 2013-01-14 at 8.37.34 PM.jpg (60.84 KiB) Viewed 5409 times
Re: SPI for LCD controller, RS problem maybe
I don't now the SPI modes you're setting out of my mind anymore as well as your LCD controller, but I am pretty sure all this is not needed. Please try just setting the prescaler (for trying bit 1 and 0) and nothing else.
Also, you should set the SPI pad modes before you call any SPI routine.
~ Tectu
Also, you should set the SPI pad modes before you call any SPI routine.
~ Tectu