2012-02-15 01:33 AM
Hi All,
I try to configure SPI on a STM32 however something goes wrong in the SPI_Init() function.
I remarked that the instuction SPIx->CR1 = Tempreg don't write in the SPI register, the register value stay at 0. We have controlled all the program thoroughly, the adress of the SPI register and the Value of Tempreg and all seems to be OK. Have you already had this problem ? Thanks in advance for your advice.2012-02-15 04:42 AM
I try to configure SPI on a STM32 however something goes wrong in the SPI_Init() function.
I remarked that the instuction SPIx->CR1 = Tempreg don't write in the SPI register, the register value stay at 0.
We have controlled all the program thoroughly, the adress of the SPI register and the Value of Tempreg and all seems to be OK.
Have you already had this problem ?
Forgot to enable the SPI's APB clock perhaps?
2012-02-15 05:13 AM
No, I've already Enabled the SPI clock
Main part of my SPI Initialization are : - Declaration of a new SPI Structure - Declaration of a new GPIO Structure - Enable The SPI Clock (RCC_APB1PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE)) - Enable GPIO Clock ( RCC_AHB1PeriphClockCmd) - I connected Pin (MOSI, MISO, SCK) to AF5 - Initialize each field of GPIO Structure (Speed, etc...) - Configuration of MOSI, MISO and SCK PIN - Configuration of the CS - Set the CS to High - Initialize each field of the SPI Strucutre (CPHA CPOL, etc, ...) - SPI_ Init() - SPI_CMD(SPI1, Enable) I think I must have forgot one step or maybe invert something.2012-02-15 05:47 AM
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE) ?
2012-02-15 06:18 AM
Yes that's it, Thanks very much to all , it haven't seen this little error.
2012-02-15 10:23 AM
Yes that's it, Thanks very much to all , it haven't seen this little error.
Yes, this mixes buses
RCC_APB1PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE)
It always helps to post actual code fragments, or better yet compilable code. Without some context we all just have to guess.2012-02-25 02:11 AM
hi Gilles
can you share your SPI code???? i am working on spi but its not working please post your code or give some instructions.2012-02-25 06:18 AM
can you share your SPI code???? i am working on spi but its not working please post your code or give some instructions.
The firmware libraries have typically contained several working examples.