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 ?
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 */
}
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 */
}
已解决! 转到解答。
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
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.
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.