2020-08-27 11:58 PM
Hello everyone,
I currently have a problem where I am not sure about the implementation. I have to control a driver module, which has a serial interface.
The problem is that it needs a LATCH line in addition to clock and data line. So far so good. But I have to set the LATCH line to high at certain points so that the driver recognizes it as a data stream or command stream.
With a SPI I realized it, but only in so far that I set the clock of the SPI to an external interrupt, count the clocks and then set the LATCH to High/Low accordingly (only works with 180MHz clock and 1MHz SPI clock, but I want a faster SPI clock. Alternatively I clocked it by hand, so set Clock, Data and LATCH for my whole data stream by hand.
Now the question: Is there a nice way to do this as efficiently as possible?
2020-08-28 12:06 AM
Which STM32?
Use timer(s).
Probably the easiest way is to generate both SCK and LATCH from two or three mutually coupled timers, connect SCK (and maybe LATCh too, if it can be used as NSS) externally to SPI and use SPI in slave mode.
JW
2020-08-28 12:28 AM
Sorry, i forgot this. I want to use a STM32F100, alternatively a STM32L151
i don't quite understand how i can generate the LATCH signal with one (or more) timers. Can you explain this in more detail? (I need yes, say 47 bars LATCH Low, then one bar LATCH High, etc.) And if I have a command: 45 bars LATCH Low, then three bars LATCH High, etc.
2020-08-28 01:18 AM
What do you mean by "bar"?
JW
2020-08-28 02:07 AM
bars = tacts = beats
2020-08-28 08:02 AM
You could use a separate SPI peripheral acting in slave mode to generate the LATCH signal. Clock it with the master SPI clock. Set it to put out circular DMA data and change the last byte based on if you're sending a command or data.
2020-08-31 01:58 AM
Thanks for your reply. That sounds promising. I just tried this, but now i have the problem with the SPI clocks. I have the SPI1 as master and the SPI2 as slave. I connect the clocks externally. Unfortunately I have no signal on the clock line after connecting the clocks.
Any idea, what the problem could be?
2020-08-31 02:12 PM
Read out the SPI registers and check they are set as expected i.e. one of them as slave. If yes, read our and check the respective GPIO and AFIO registers.
JW