2017-05-02 01:53 AM
hi, i am new to community.....
i have a stm32f4 discovery board with sym32f407cg microcontroller i tried to test spi communucation of the microcontroller with onboard accelerometer
but there is one or more problem that i can not hande
the problem is whatever i write on data register of spi1 , the register only shows 0xff when i read it with the help of pointer
how can i solve this problem
thats what i did as settings of spi1..
spi_cr1 |= 0x30; // select speed
spi_cr1 |= 0x03; // select cpha and cpol spi_cr1 |= 0x00; // select dff spi_cr1 |= 0x00; // select msbfirstspi_cr2 |= 0x10; // select frf
spi_cr2 |= 0x04; // set ssoe spi_cr1 |= 0x04; // set mstr spi_cr1 |= 0x40; // enable spi##discovery ##spi #stm32Solved! Go to Solution.
2017-05-03 10:30 AM
You'd want to make sure the correct chip select GPIO pin is being used, and that you can read back the content of the CHIPID or WHOAMI type register.
2017-05-05 12:43 AM
the board exactly the same with the image you upload ... the version is MB997D
2017-05-05 12:44 AM
it the Pin E3 that i am using for chip select for spi1
2017-05-07 10:22 AM
i have solved the problem....
the problem is spi does not communicate correctly because of reasons
***the ti frame format has its own cpha cpol settings which controlled by hardware and can not controlled through cr1 register
***rxne and txe flag should be checked with busy flag . because txe flag set after data transfered to shift register but transmission is not finnished
and also before setting cs pin low the busy flag must be checked
2017-05-07 11:14 AM
Each slave chip manufacturer is free to choose the cpha and cpol settings. Each master manufacturer is free to choose how to express the phase and polarity.
Beware, there is a bunch of documentation problems with this accelerometer.
I wrote a series of articles on SPI in general and the LIS3DSH on the F4Discovery in specific. See
http://embedded.fm/blog/2017/4/26/i-apply-spi-good-vibrations
and the two previous articles.Andrei