AnsweredAssumed Answered

From ASCII to binary (SPI config)

Question asked by CitRam on Jan 26, 2014
Latest reply on Jan 29, 2014 by CitRam




I'm learning to write code for FRDM KE02Z. I woluld like send binary word via SPI, for example write binary word like  11110111 not ASCII characters. 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 string uint8_t OutData[BLOCK_SIZE] = "FF", for ability writing binary word not ASCII characters.


Below  my code




#define BLOCK_SIZE 4

uint8_t f;
uint8_t OutData[BLOCK_SIZE] = "FF";
uint8_t InpData[BLOCK_SIZE];
volatile LDD_SPIMASTER_TError ComError = 0U;
LDD_TError Error;
LDD_TDeviceData *MySPIPtr;

/* User includes (#include below this line is not maintained by Processor Expert) */

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  /*** End of Processor Expert internal initialization.                    ***/
  MySPIPtr = SM1_Init(NULL);                               /* Initialization of SM1 component */
  //SM1_SelectConfiguration(MySPIPtr, 1U, 1U);               /* Select chip select 1 and attribute set 1 */
  Error = SM1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); 
  //f=atof(OutData);/* 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 */
  /* Write your code here */
  /* For example: for(;;) { } */

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/