stm32 SPIの憂鬱
いつものstm32F103CBT6にて。
お題はSPI1。
なんだか、うまく動かない。
データ転送終了前にSRのbusyフラグが戻ってしまうように見える。
busyフラグが当てにならないと困るなあ。色々と。
エラッタシートにもそれらしきもの無し。
とりあえず、最後に時間待ちループを入れてしのぐ。
------
今回使っているのは、使う頻度は低いと思われる、16ビット転送モード。
ふと思い立って、8ビットで2回に分けて送信してみると、こんどはbusyフラグは正気に戻ったようだ。
なんだか、症状からしても、エラッタっぽいなあ...
まあ回避できるのでいいけれど。
| 固定リンク | 0
コメント
I use SPI2 on the STM32 on my mouse and it works well.
I use DMA and use transmit complete flag to tell me that transmission is complete. This way, I only get the interrupt after everything has been sent.
投稿: Harjit Singh | 2010年10月 2日 (土) 03時02分
Perhaps transfer of data have no problem.
but,it seems to be removed busy flag before all bits send.
The SPI1 works at 8 bits mode well, but is no good at 16 bits mode(SPI_CR1.DFF = 1).
I suspect that this will be chip errata.
投稿: watadani | 2010年10月 2日 (土) 09時12分
I made a mistake in my explanation above.
To make sure all bits have been sent, I use the receive interrupt (RXNE) because this will only happen when the current transmit data has been sent. I do this even when I'm only doing transmit.
I don't use busy flag.
投稿: Harjit Singh | 2010年10月 2日 (土) 13時01分
I used only Tx signal in this time.
I couldn't notice the way of use RXEN.
It makes do well in each data length now.
Thanks.
投稿: watadani | 2010年10月 2日 (土) 14時44分