2020-07-28 04:16 AM
I have STM32F407 that is communicating with TFT lcd over SPI. What I am seeing with Logic Analyzer doesnt match what I am sending. I cant see the pattern, but data is consistent, so its probably some setting that is off. I tried all combinations of CPOL/CPHA on LA. No luck. (framing error or same data)
I am sending: 0xEF 0x03 0x80 0x02
What logic analyzers sees is: 0xF7 0x80 0xF0 0x00
Also, my SPI doesnt output anything if Frame format of SPI_CR2 is set to SPI motorola. I am kind of suspecting there is a problem around there..
SPI clock speed doesnt affect the output as well. Tried 3Mhz and 1Mhz but with the same result.
Any ideas ?
Edit:
I noticed that when I change Logic analyzer to 9bit, and ignoring the first bit, that I actually get proper data.
when I send 0xEF, 0x03, 0x80, 0x02
I receive 0x1EF, 0x003, 0x180, 0x002.
2020-07-28 04:38 AM
what you see on logic analyzer may be reversed, it depends on that you send MSB(most significant bit) first or LSB(least significant bit) first. Be careful when parsing serial line data
2020-07-28 05:53 AM
Probably a bug in your code. What does your code look like?
2020-07-28 06:09 AM
Probably a bug in your code. How does the registers content look like?
JW
2020-07-28 06:16 AM
2020-07-28 06:44 AM
It was bug in my code obviously. TI mode seems to use 9clock cycles for 8bits of data. Switching to Motorola mode fixed this issue.
Problem with setting the motorola mode in the first place was order of the commands that were sent to the CR register.
setting master was just bellow enabling of the SPI peripheral. But setting of the frame mode for some reason was enabling the master mode ?!
Anyway, moving enable command fixed the setting of Motorola mode.