FRDM KE02Z SPI example

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

FRDM KE02Z SPI example

1,803 Views
CitRam
Contributor III

Hi to All

I'm learning to write code for FRDM KE02Z. I want to send 8bits words via SPI.

I  have created project, with Processor Expert have created and configurated SM1:SPIMaster_LDD.

And I don't know what code to write for sending 8bit word via SPI in ProcessorExpert.c or Events.c?


I think I have to use the SM1_SendBlock(); in ProcessorExpert.c, but don't know what arguments need to use.

I think must be something like

if(SM1_GetBlockSentStatus = false)

{

SM_SendBlock(,00110111);

}

Could you help me please.



ke02.jpg

0 Kudos
5 Replies

668 Views
CitRam
Contributor III

Thank you Robin and Erich.

I've made as adviced Robin, by Help on component. But, I'm sorry, i woluld like send binary word, for example write  11110111, and get from MOSI 11110111, not characters. Becuse in my task eighth bit must be parity bit. I already tried use parity bit set in Component Inspector/SPI0/Atribute Set List, but KE02 doesen't support SPI pairty bit.

Could you advice me how should I change the subroutine for ability writing binary word not ASCII characters

#define BLOCK_SIZE 4

uint8_t OutData[BLOCK_SIZE] = "FF";

uint8_t InpData[BLOCK_SIZE];

volatile LDD_SPIMASTER_TError ComError = 0U;

LDD_TError Error;

LDD_TDeviceData *MySPIPtr;

int main(void)

{

PE_low_level_init();

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

while(1){

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

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

    while (!SM1_GetBlockReceivedStatus(MySPIPtr)) {          /* Wait until data block is transmitted/received */

  SM1_Main(MySPIPtr);

  }

}

#ifdef PEX_RTOS_START

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

  #endif

for(;;){}

}

0 Kudos

668 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

Have you read the Typical Usage of SPIMaster_LDD ?

There are two Typical Usage what can show you how to use this SPIMaster_LDD.

You just need to do according to them.

1.jpg

2.jpg

Hope that help.

Best Regards

Binbin

668 Views
BlackNight
NXP Employee
NXP Employee

Hi,

you might have a look at this project:

FRDM with Arduino Ethernet Shield R3, Part 2: Ping

It is using SPI to communicate with the W5100.

668 Views
CitRam
Contributor III

Thenk you Erich for you answer. I have watched your projects before, in particular W5100 project. But you use FreeRTOS in W5100 project, I have not any experience with any RTOS.

0 Kudos

668 Views
BlackNight
NXP Employee
NXP Employee

The SPI with the W5100 can run with or without RTOS. The only thing which is RTOS specific in this driver is to get a semaphore/lock. Don't use that, and you have what you need.

0 Kudos