2008-07-03 10:37 PM
2011-05-17 12:54 AM
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_SendData2011-05-17 12:54 AM
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!!2011-05-17 12:54 AM
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!!!2011-05-17 12:54 AM
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);