2007-03-25 11:49 PM
2011-05-17 12:40 AM
Hi
has anyone solved the loop back problem in SSP? when the ssp is used in the master mode and data is transmitted on the mosi pin and received on miso pin. transmitted data is correct but the received data is just the copy of transmitted data. The nss pin is directly connected to the LRC (left right clock) of codec without any pull up resistor. when data that comes on the miso pin is seen in an oscilloscope it is not the transmitted data. the loop back happens inside the microcontroller. Connecting the nss pin to vcc is not an option for me as the ssp is configured in SSI mode to communicate with a codec. the code is as follow: void SSPCodec_Init(void) { SSP_InitTypeDef SSP_InitStructure; // SSP1 configuration SSP_DeInit(SSP1); SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_TI; SSP_InitStructure.SSP_Mode = SSP_Mode_Master; SSP_InitStructure.SSP_CPOL = SSP_CPOL_High; SSP_InitStructure.SSP_CPHA = SSP_CPHA_1Edge; SSP_InitStructure.SSP_DataSize = SSP_DataSize_8b; SSP_InitStructure.SSP_ClockRate = 0; //5- for slave; 0-for master SSP_InitStructure.SSP_ClockPrescaler = 24; SSP_Init(SSP1, &SSP_InitStructure); // Disable the Loop back mode for the SSP1 peripheral SSP_LoopBackConfig(SSP1, DISABLE); // SSP1 enable SSP_Cmd(SSP1, ENABLE); } int main(void) { u8 cnt=0; ......... while(1) { if(send_ready==1)//wait for 1/48kHz duration, flag is set in tim2 ISR { send_ready=0; //reset flag SSP_SendData(SSP1, sin_data[cnt]); //wait to receive data while(SSP_GetFlagStatus(SSP1, SSP_FLAG_RxFifoNotEmpty) == RESET); mic_data[cnt] = SSP_ReceiveData(SSP1); //Receive the output of mic cnt++; if (cnt == NbrOfSamples) { cnt = 0; } } } } Please, help me out. Thanks in advance, vik2011-05-17 12:40 AM
Hi tvikram,
I didn't test your code but as I see: -In TI mode you can't program CPHA and CPOL bits since bit phase and polarity are applicable to Motorola SPI format only. -To enable or disable loop back mode, use SSP_LoopBackMode()function and not SSP_LoopBackConfig(). Please find attached an SSP loop back mode example. I hope this will help you. Best regards mirou2011-05-17 12:40 AM
thank u for the reply
i got the solution it has been posted in the thread - spi slave to master