cancel
Showing results for 
Search instead for 
Did you mean: 

SPI problems

ico74
Associate II
Posted on July 04, 2008 at 07:37

SPI problems

4 REPLIES 4
daniel8
Associate II
Posted on May 17, 2011 at 09:54

Did you enable the clock to it?

SCU_APBPeriphClockConfig(__SSP0 ,ENABLE);

What is your GPIO setup?

You need to enable the SPI before sending it data, ie,

SSP_Cmd(SSP0,ENABLE) must come before

SSP_SendData

ico74
Associate II
Posted on May 17, 2011 at 09:54

Hi to All!

I'm trying to make a communication with SPI Flash memory.

For this porpose I'm using Keil's MCB-STR9 ver.3 demo board.

CPU - STR912FW44X6.

- SPI0 inits: Motorola SPI Frame format, 8bits data format, Master, ...

Firstly I still can not succeed to make SPI0 to send the byte I write in SSP0->DR register.(for example: I write 0xAA it sends 0x00);

To make SPI0 to send what I expect I make some workaround:

> SSP_Cmd(SSP0, DISABLE);

> SSP_SendData(SSP0, Dat);

> SSP_Cmd(SSP0, ENABLE);

After this it sends what I expect, but I think it is not the right way.

Does anyone have such problem? Where is my mistake?

Thanks a lot in advance!!

ico74
Associate II
Posted on May 17, 2011 at 09:54

Everybody be careful with setting of SPI clock ratios.

In Master mode PCLK must be at least twice higher than fSCLK.

In my case it was not like that i.e. PCLK=3MHz and fSCLK=2MHz -> it was wrong!!!

ico74
Associate II
Posted on May 17, 2011 at 09:54

also if you have Rx problems be sure that you make

pin initializations like this:

/*Gonfigure SSP0_CLK, SSP0_MOSI, SSP0_nSS pins */

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;//to make Rx working!!!

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;

GPIO_Init (GPIO5, &GPIO_InitStructure);