AnsweredAssumed Answered

KE02Z SPI Slave (strange behavior)

Question asked by CitRam on Jun 26, 2014
Latest reply on Jul 7, 2014 by CitRam

Hello

 

I'm trying to figure out how SPI Slave (FRDM-KE02Z) works. Two boards are connected only by GND and CLK  (Slave is FRDM-KE02Z and Master is MCU board(not Freescale)) .

Master sent only CLK to Slave. Slave is configured: Clock polarity: Low, Clock phase: Change on leading edge. Immediately after power-up, Slave work correctly, it sends out data accurately by master clock, bit by bit on clock period. But when I reset Master board, data is shifted relative to clock, as on on figures below. Could somebody enplane me , how to get rid of shifting

Normal

scope_34.png

Shifted

scope_33.png

scope_32.png

 

there is my code:

#include "Cpu.h"
#include "Events.h"
#include "SS1.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"


#define BLOCK_SIZE 1


uint8_t OutData[BLOCK_SIZE];
uint8_t InpData[BLOCK_SIZE];
volatile LDD_SPISLAVE_TError ComError = 0U;
LDD_TError Error;
LDD_TDeviceData *MySPIPtr;


int main(void)
{

  PE_low_level_init();
  MySPIPtr = SS1_Init(NULL);                              

  while(1){ 
  //Error = SS1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); 
  OutData[0]=15;
  Error = SS1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE);    /* Start transmission/reception */
  while (!SS1_GetBlockSentStatus(MySPIPtr)) {          /* Wait until data block is transmitted/received */
      SS1_Main(MySPIPtr);
    }
  //SS1_Disable(NULL);
  //SS1_Enable(NULL);


}

  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif

  for(;;){} 
}

Outcomes