cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f3xx 8 bit SPI problem

mesmert
Associate II
Posted on July 12, 2015 at 17:32

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
5 REPLIES 5
Posted on July 12, 2015 at 18:40

Can't help you with HAL stuff, but consider waiting for TXE to assert *before* jamming data out the DR.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mesmert
Associate II
Posted on July 12, 2015 at 19:10

Can you give

me an idea

or

example

code

Posted on July 12, 2015 at 19:43

If you're going to post plots from a logic analyzer, label the signals, and for SPI show MOSI, MISO, CLK and CS pins.

Not a HAL user, but this should be a more thoughtful implementation

GPIOC->BSRRL = GPIO_BSRR_BS_13; // Inverted #CS, Set HIGH?
while((SPI3->SR & SPI_SR_TXE) != SPI_SR_TXE); // Wait for TXE to indicate empty 
ms_data = SPI3->DR; // Dummy Read to clear any stale RXNE
ms_data = 0xAA; // Data you want to send
SPI3->DR = ms_data; // Write data into EMPTY register
while((SPI3->SR & SPI_SR_RXNE) != SPI_SR_RXNE); // Wait for RXNE, last bit sent already
ms_data = SPI3->DR; // Could skip this, clears *this* RXNE
GPIOC->BSRRH = GPIO_BSRR_BS_13; // Inverted #CS, Set LOW?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mesmert
Associate II
Posted on July 12, 2015 at 23:29

I did

use the

SD card

I

use

the program in

PIC processors

I've used

before

is now

trying to

adapt

STM32

.

I tried to

adapt

the

links below

, but came

very confused

me

so

I could

adapt

.

http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/

mesmert
Associate II
Posted on July 12, 2015 at 23:53

This

bug

STM32

series

of

mistakes

by me

or

HAL

library.