2009-03-01 07:45 PM
2011-05-17 12:32 AM
Hi,
I use IAR start kits STR912-SK to test the SSP-debug in the examples.eww workspace which is in ...\ARM\examples\ST\STR91x\STR91xlibrary\examples\directory. I made a cable to connect the SPI0 connector( Master )and UXT connector( Slave). When the SPI0( Master ) sends data to SPI1 ( slave), SPI1 can receive the correct data. When the SPI1 send data to SPI0, the data SPI0 received is not correct. The difference is the slave only can send out data after the master( SPI0 ) send a dummy bit to generate the clock.The data SPI0( Master) received is just the SPI0 send out. I use scope to monitor the signal SPI1( slave) send out,it's correct,but the contents of SSP0_DR is not correct. I disconnect the wire between SSP0_MISO(P5.6) and SSP1_MISO(P3.5), the SPI0 can still receive the data which is SPI0 send out. Following is part of the code. while(Tx_Idx { SSP_SendData(SSP0, SSP0_Buffer_Tx[Tx_Idx++]); while(SSP_GetFlagStatus(SSP1, SSP_FLAG_RxFifoNotEmpty)==RESET); SSP1_Buffer_Rx[Rx_Idx++] = SSP_ReceiveData(SSP1); } /* Check the received data with the send ones */ TransferStatus1 = Buffercmp(SSP0_Buffer_Tx, SSP1_Buffer_Rx, 32); /* TransferStatus = PASSED, if the data transmitted from SSP0 and received by SSP1 are the same */ /* TransferStatus = FAILED, if the data transmitted from SSP0 and received by SSP1 are different */ /* Clear SSP0 receive Fifo */ for(k=0; k /* Reset counters */ Tx_Idx=Rx_Idx=0; /* Slave to master transfer procedure */ while(Tx_Idx { SSP_SendData(SSP1, SSP1_Buffer_Tx[Tx_Idx]); /* send a dummy bit to generate the clock */ SSP_SendData(SSP0, SSP0_Buffer_Tx[Tx_Idx++]); while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty)==RESET); SSP0_Buffer_Rx[Rx_Idx++] = SSP_ReceiveData(SSP0); } Anyone has the same problem? Cheers2011-05-17 12:32 AM
Hi,
I use the Keil Starter Kit with the Keil MCB-STR9-Board. I have the same Problem with the example for the ST-Library, but I did not receive correct data in SPI1. I tried to set the SPI-Data-In from the master to high or low, but I never get the data 0x00 or 0xFF in the receive-buffer in the Master. I allways have the loopback data from the SPI0-Transmitter. The Control register 1 from SPI0 is set to 0x0002, so the loopback function is not enabled. I tried the SPI0 on Port 2 and 5. It's the same. Regards, T Ruf2011-05-17 12:32 AM
Hi Stevejamal,
The problem has been solved.The reason is the PIN P57/SSP0_NSS is connected to VCC via a Resistor( R118 10K in STR912-SK EVAL Board ). If this pin tired to VCC directly, it works, otherwise you will see a negative pulse on the pin P57/SSP0_NSS starting before SCLK. The master loopback the sending out data to receiving FIFO automatically. Thanks,2011-05-17 12:32 AM
Hi,
I have an IAR starter kit, I test the SPI sample code and the program works Did you check if the jumper are connected in the right position. For default P3x are connected to the leds. Are you working with 4 lines MISO MOSI SCK and NSS?2011-05-17 12:32 AM
Hi,
I have connected the SPI the Pin SSP0_NSS directly to VCC. Now i got the right data on MISO and in the receive Fifo. Thanks for the reply. But I did not understand that i have to connect an Output to VCC. I want to use the Pin SSP0_NSS as chipselect for an external SPI-Slave in Motorola SPI frame format. I want to use the SPI-Bus as described in the reference manual of STR91xF at Figure 65. I want to work with MISO MOSI SCK and NSS to communicate with an external device. Thanks2011-05-17 12:32 AM
I just discovered this ''feature'' yesterday. Is there a reason why NSS has to be driven high? Is this really something that should be in the Errata? It is a waste of a pin!
2011-05-17 12:32 AM
Hi lakata,
Concerning the NSS master, it must be pulled up and not to be driven high. However, if you are using the STR9 library example, you have to configure GPIO 2 and GPIO 3 as follow: GPIO_DeInit(GPIO2); /*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; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; GPIO_Init (GPIO2, &GPIO_InitStructure); GPIO_DeInit(GPIO3); /*Gonfigure SSP1_MISO pin */ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; GPIO_Init (GPIO3, &GPIO_InitStructure); with best regards, mirou2011-05-17 12:32 AM
I meant ''driven high externally'' ie connected to VCC. I configured nSS to be an input, and it worked properly for me. I'm just wondering why this pin has to be wasted (it does nothing). Our design ran out of pins...
2011-05-17 12:32 AM
Hi guys,
I've manage to establish a SPI connection with an external SPI-Slave in Motorola SPI frame format on SSP0. Here are my GPIO setting. GPIO_DeInit(GPIO2); 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; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; GPIO_Init (GPIO2, &GPIO_InitStructure); GPIO_DeInit(GPIO3); GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; GPIO_Init (GPIO3, &GPIO_InitStructure); My SSP0_nSS is connected to Vcc with a 10K pull-up resistor. TRuf, it's working as described in the reference manual of STR91xF at Figure 65. Hope that could help someone. Cofor