AnsweredAssumed Answered

STR912 SSP -> NSS-Pin Connection

Question asked by Heiko on Jun 15, 2012
Problem: Can't read out the received SSP0 Signal.
[ADC_VALUE = SSP_ReceiveData(SSP0)]

Is it necessary to connect the NSS-Pin to high ? The uC is in Master Mode, MOSI, MISO and CLK Pins are connected. The NSS Pin is used and configured actually as output to start the /CONV Signal at the external SSP - ADC. Also the measured signals on MOSI, MISO and CLK are o.k. In Loop-Mode the received Signal is the SendData 0x800. So Loop-Mode is also o.k.

Read SSP-Sequenz in main:
 SSP_SendData(SSP0, 0x800);  // Read Signal channel0 -> 0x800
 while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty)==RESET);
 ADC_VALUE = SSP_ReceiveData(SSP0);

Setup:

GPIO_InitTypeDef GPIO_InitStructure;
SSP_InitTypeDef SSP_InitStructure;

SCU_APBPeriphClockConfig(__GPIO2 ,ENABLE);
SCU_APBPeriphClockConfig(__SSP0, ENABLE);

   // GPIO2 Configuration
   // SPP0 clk bus, GPIO2.4
   GPIO_DeInit(GPIO2);
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
   GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
   GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
   GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;
   GPIO_Init (GPIO2,&GPIO_InitStructure);

   // SSP0 MOSI bus, GPIO2.5 
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
   GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
   GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
   GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;
   GPIO_Init (GPIO2,&GPIO_InitStructure);
  
   // SSP0 MISO bus, GPIO2.6
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 ;
   GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
   GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
   GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;
   GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
   GPIO_Init (GPIO2, &GPIO_InitStructure);

   // SSP0 CONV, GPIO2.7 -> LTC1861, ADC
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ;
   GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
   GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
   GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
   GPIO_Init (GPIO2, &GPIO_InitStructure);


  SCU_APBPeriphReset(__SSP0,ENABLE);
  SCU_APBPeriphReset(__SSP0,DISABLE);

  SSP_StructInit(&SSP_InitStructure);

  SSP_DeInit(SSP0);
  SSP_Cmd(SSP0, ENABLE);

  SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola;
  SSP_InitStructure.SSP_Mode = SSP_Mode_Master;
  SSP_InitStructure.SSP_CPOL = SSP_CPOL_High;
  SSP_InitStructure.SSP_CPHA = SSP_CPHA_2Edge;
  SSP_InitStructure.SSP_DataSize = SSP_DataSize_12b;
  SSP_InitStructure.SSP_ClockRate = 20;  
  SSP_InitStructure.SSP_ClockPrescaler = 10;
  SSP_Init(SSP0, &SSP_InitStructure);

  SSP_LoopBackConfig(SSP0, DISABLE);


Heiko

Outcomes