cancel
Showing results for 
Search instead for 
Did you mean: 

Read out external device with ssp0

dani1
Associate II
Posted on January 24, 2007 at 15:03

Read out external device with ssp0

3 REPLIES 3
dani1
Associate II
Posted on May 17, 2011 at 09:35

Dear all

I would like to read out a LM95071 by SSP0. (see attachment)

I connected the device on

p2.4 (SC)

p2.6 (MISO)

p9.6(!CS) //2.7 is already used by USB_CLK

and tried the following code on my Keil MCBSTR9 Evaluation Board. If I observe the pins with the scope I see no action on SC and MISO while reading. The CS(p9.6) is tied to 0 in the beginning, and always kept low.

The programm is hanging in the while()-Loop on the second last line and waiting for data to come in.

If I try to send data (SSP_SendData(...)) then I get a clock signal on the SC-Pin.

Do you have any suggestions?

Kind Regards

------------------C O D E--------------------------------

/* SCU configuration */

SCU_Configuration();

/* GPIO pins configuration */

GPIO_Configuration();

GPIO_Write(GPIO9, 0x00); //!CS = 0

/* SSP0 configuration */

SSP_DeInit(SSP0);

SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Microwire;

//SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola;

SSP_InitStructure.SSP_Mode = SSP_Mode_Master;

//SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low;

//SSP_InitStructure.SSP_CPHA = SSP_CPHA_1Edge;

SSP_InitStructure.SSP_DataSize = SSP_DataSize_16b;

SSP_InitStructure.SSP_ClockRate = 5;

SSP_InitStructure.SSP_ClockPrescaler = 254;

SSP0->CR1 &= 0xFFFE; //switch off loopback mode

SSP_Init(SSP0, &SSP_InitStructure);

SSP_Cmd(SSP0, ENABLE);

/* Clear SSP0 receive Fifo */

SSP0_Buffer_Rx = SSP_ReceiveData(SSP0);

while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty)==RESET); //here it is hanging

SSP0_Buffer_Rx = SSP_ReceiveData(SSP0);

------------------------------------------------------

Posted on May 17, 2011 at 09:35

Dear hazzzard,

If you configure the SPI in master mode you must send

a dummy code in order to receive something from the

peripheral.

The SPI is a couple ''parallel to serial shift register''

The following istruction

SSP0_Buffer_Rx = SSP_ReceiveData(SSP0);

read the content of the shift register.

try this:

SPP_SendData(SSP0, 0xAA55)

while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoEmpty)==SET);

SSP0_Buffer_Rx = SSP_ReceiveData(SSP0);

dani1
Associate II
Posted on May 17, 2011 at 09:35

Thanks stevejamal.

I changed your code slightly since the Flag SSP_FLAG_RxFifoEmpty does not exist to:

while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoFull)==RESET);

which should do the same (hopefully). But it still does not work. When i send, I can see the clock on the SC-Line, but there is only crap going on on the MISO Pin.

Thanks anyway!

haz

Attachment did not work last time, hope now its working

Quote:

On 24-01-2007 at 12:43, Anonymous wrote:

Dear hazzzard,

If you configure the SPI in master mode you must send

a dummy code in order to receive something from the

peripheral.

The SPI is a couple ''parallel to serial shift register''

The following istruction

SSP0_Buffer_Rx = SSP_ReceiveData(SSP0);

read the content of the shift register.

try this:

SPP_SendData(SSP0, 0xAA55)

while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoEmpty)==SET);

SSP0_Buffer_Rx = SSP_ReceiveData(SSP0);