AnsweredAssumed Answered

simple SPI checking

Question asked by afda sdfas on Dec 18, 2013
Latest reply on Dec 27, 2013 by changkenta

Hi

I have 2 FRDM Kit ( KL25Z and K20D50M). I try to connect them by SPI ( one is Master, one is Slave, code of them i follow the help in CodeWarrior , see beelow).

When i debug the Salve kit. How can i know ( or see ) the Value which Slave receive in CodeWarrior program  ?

it mean : how can i view that Value of   InpData[BLOCK_SIZE]  in codewarrior ?

 

Master

Content of ProcessorExpert.c:

#define BLOCK_SIZE 4

 

uint8_t OutData[BLOCK_SIZE] = "0123";

uint8_t InpData[BLOCK_SIZE];

volatile bool DataReceivedFlag = FALSE;

volatile LDD_SPIMASTER_TError ComError = 0U;

LDD_TError Error;

LDD_TDeviceData *MySPIPtr;

 

void main(void)

{

  ...

  MySPIPtr = SM1_Init(NULL);                               /* Initialization of SM1 component */

  Error = SM1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); /* Request data block reception */

  Error = SM1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE);    /* Start transmission/reception */

  while (!DataReceivedFlag) {};                            /* Wait until data block is transmitted/received */

}

Content of Event.c:

extern volatile bool DataReceivedFlag;

extern volatile LDD_SPIMASTER_TError ComError;

extern LDD_TError Error;

extern LDD_TDeviceData *MySPIPtr;

 

void SM1_OnBlockReceived(LDD_TUserData *UserDataPtr)

{

  DataReceivedFlag = TRUE;                                 /* Set Data received flag */

}

 

void SM1_OnError(LDD_TUserData *UserDataPtr)

{

  Error = SM1_GetError(MySPIPtr, (LDD_SPIMASTER_TError *)&ComError); /* Get communication errors if occured */

}

 

 

Slave

 

Content of ProcessorExpert.c:

#define BLOCK_SIZE 4
 
uint8_t OutData[BLOCK_SIZE] = "0123";
uint8_t InpData[BLOCK_SIZE];
volatile bool DataReceivedFlag = FALSE;
volatile LDD_SPISLAVE_TError ComError = 0U;
LDD_TError Error;
LDD_TDeviceData *MySPIPtr;
 
void main(void)
{
  ...
  MySPIPtr = SS1_Init(NULL);                               /* Initialization of SS1 component */
  Error = SS1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); /* Request data block reception */
  Error = SS1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE);    /* Start transmission/reception */
  while (!DataReceivedFlag) {};                            /* Wait until data block is transmitted/received */
}

Content of Event.c:

extern volatile bool DataReceivedFlag;
extern volatile LDD_SPISLAVE_TError ComError;
extern LDD_TError Error;
extern LDD_TDeviceData *MySPIPtr;
 
void SS1_OnBlockReceived(LDD_TUserData *UserDataPtr)
{
  DataReceivedFlag = TRUE;                                 /* Set Data received flag */
}
 
void SS1_OnError(LDD_TUserData *UserDataPtr)
{
  Error = SS1_GetError(MySPIPtr, (LDD_SPISLAVE_TError *)&ComError); /* Get communication errors if occured */
}

Outcomes