simple SPI checking

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

simple SPI checking

Jump to solution
2,100 Views
afdasdfas
Contributor II

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 */
}
Tags (3)
1 Solution
1,063 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

I record a video about how to add variable to CodeWarrior's watch window.

Wish it helps.

B.R.

Ma Hui

View solution in original post

0 Kudos
7 Replies
1,063 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

After you run the both boards, the SPI master will start SPI communication and the SPI slave will receive related data.

You can check the SPI InpData[] array in CodeWarrior watch window or use serial print related data after SPI transfer.

Wish it helps.

B.R.

Ma Hui

1,063 Views
afdasdfas
Contributor II

Can you tell me the way to :"CodeWarrior watch window" to see the  SPI InpData[] value ? I try to find it in Codewarrior , but not see this tab.

0 Kudos
1,064 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

I record a video about how to add variable to CodeWarrior's watch window.

Wish it helps.

B.R.

Ma Hui

0 Kudos
1,063 Views
afdasdfas
Contributor II

Yes, that is right. Now i can read the Value of SPI debug. Thank you very much

0 Kudos
1,063 Views
afdasdfas
Contributor II

Hi all

And other question , after i check the Value of the SPI InpData[] . I see that all SPI InpData[] value is 0xff although i send "0123", please help me  to view and correct the code over here and help me to correct my SPI connect.

0 Kudos
1,064 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Please check the hardware connection between 2 FRDM Kit ( KL25Z and K20D50M). And there is a thread about FRDM-K20D50M board connection, wish it helps.

https://community.freescale.com/thread/313682

1,063 Views
changkenta
Contributor II

Hello,

I have question about this issue: I can not setting the OnError Event mask of SPIMaster_LDD?

please let me know How to setting it.

Regards,

Kenta

0 Kudos