AnsweredAssumed Answered

KSDK SPI Driver Issue

Question asked by Adam Carlson on Aug 2, 2015
Latest reply on Aug 8, 2015 by Adam Carlson

I am sure that I am just missing something stupidly simple, but I cannot see it.  It may be because I have stayed up too late the last few nights soldering up breakout boards.  I am trying to get SPI communications working on a KL03Freedom board working.  I am using the SPI_DRV_MasterTransfer() function.  This is a processor expert project and the SPI comms are setup through the fsl_spi component.

 

When I use the SPI_DRV_MasterTransfer, I can get the clock line working, though I cannot get any data out.  I have just tryed to set it such that it is sending and receiving a simple Byte.  Once this is achieved, then I will get into an array.  I have it such that the code is to turn the light green if it gets the proper response from the connected device, or red if it does not get the proper response.  I have confirmed by presetting the proper response value and commenting out the code for SPI_DRV_MasterTransfer() that this portion is working as expected (there was no doubt that it would, but just in case I was doing something dumb, I wanted to be sure).

 

Any help would be appreciated, thanks!

 

Adam

/* ################################################################### **     Filename    : main.c **     Project     : Test **     Processor   : MKL03Z32VFK4 **     Version     : Driver 01.01 **     Compiler    : GNU C Compiler **     Date/Time   : 2015-05-09, 14:30, # CodeGen: 0 **     Abstract    : **         Main module. **         This module contains user's application code. **     Settings    : **     Contents    : **         No public methods ** ** ###################################################################*/ /*! ** @file main.c ** @version 01.01 ** @brief **         Main module. **         This module contains user's application code. */         /*! **  @addtogroup main_module main module documentation **  @{ */         /* MODULE main */   /* Including needed modules to compile this module/procedure */ #include "Cpu.h" #include "Events.h" #include "clockMan1.h" #include "osa1.h" #include "pin_mux.h" #include "spiCom2.h" #if CPU_INIT_CONFIG   #include "Init_Config.h" #endif /* User includes (#include below this line is not maintained by Processor Expert) */  /*lint -save  -e970 Disable MISRA rule (6.3) checking. */  unsigned int testing = 0; unsigned int count = 0; unsigned int clockOld; unsigned int clockNew = 0; unsigned int pwmCounterValue; unsigned int spiRead; unsigned int i = 0; uint8_t spiBufferValues = 0b00100000;        //Who Am I address uint8_t spiReadBufferValues = 0b10110001;    //Proper response  int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ {   /* Write your local variable definition here */   unsigned int count = 0;    /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/   PE_low_level_init();   /*** End of Processor Expert internal initialization.                    ***/    /* Write your code here */   SPI_DRV_MasterTransfer(FSL_SPICOM2,NULL,&spiBufferValues,&spiReadBufferValues,1);    //Blue Led   //TPM1_C1V = 65535;                    //Set Blue LED On   //LPTMR0_CNR = 65535;    for(;;)   {       //count = LPTMR0_CNR;       //TPM1_C1V = 65535;       if (spiReadBufferValues == 0b10110001)    //If response is valid, light the Green LED       {           TPM0_C0V = 65535;        //Green           TPM0_C1V = 1;            //Red           TPM1_C0V = 1;            //Blue       }       else                                        //If response invalid, light Red LED       {           TPM0_C0V = 1;            //Green           TPM0_C1V = 65535;        //Red           TPM1_C0V = 1;            //Blue       }   }    /*** 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!!! ***/   #ifdef PEX_RTOS_START     PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */   #endif   /*** End of RTOS startup code.  ***/   /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/   for(;;){}   /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/  /* END main */ /*! ** @} */ /* ** ################################################################### ** **     This file was created by Processor Expert 10.5 [05.21] **     for the Freescale Kinetis series of microcontrollers. ** ** ################################################################### */

Outcomes