AnsweredAssumed Answered

SPI not working on twr-k70f120m tower module

Question asked by sameerarvikar on Apr 11, 2017
Latest reply on Apr 28, 2017 by Robin_Shen

I am using kinetis design studio v3.2 and processor expert to write a code for spi on k70 chip (twr-k70f120m tower board) I have used the polling method example given by help component

but when i check there is no clock coming on spi:clk pin of the board

so to check whether program is running i also added a led blink code which blinks led every one second using timer interrupt,it is working but still no clock on spi:clk of the above board

What is missing in the code ?




I have used following component setup as per the example

Interrupt service/event: Disabled
Input pin: Enabled
Output pin: Enabled
Attribute set list: 2
Attribute set 0 and 1: configured as slaves require
Width: 8 bits
Enabled in init. code: yes
Event mask/OnError: Enabled
Methods: SendBlock, ReceiveBlock, GetBlockReceivedStatus, GetError
Events: OnError


following is main.c

#include "Cpu.h"
#include "Events.h"
#include "SM1.h"
#include "Bit1.h"
#include "BitIoLdd1.h"
#include "TI1.h"
#include "TimerIntLdd1.h"
#include "TU1.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

#define BLOCK_SIZE 4
uint8_t OutData[BLOCK_SIZE] = "0123";
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. */
void 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. ***/

/* Write your code here */
/* For example: for(;;) { } */

MySPIPtr = SM1_Init(NULL);
SM1_Enable(MySPIPtr) ;/* Initialization of SM1 component */
//SM1_Sel; /* Select chip select 0 and attribute set 0 */
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 */


/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */

Following is event.c


#include "Cpu.h"
#include "Events.h"

#ifdef __cplusplus
extern "C" {



void Cpu_OnNMIINT(void)
/* Write your code here ... */

** ===================================================================


void SM1_OnBlockSent(LDD_TUserData *UserDataPtr)
/* Write your code here ... */


void SM1_OnBlockReceived(LDD_TUserData *UserDataPtr)
/* Write your code here ... */

extern volatile LDD_SPIMASTER_TError ComError;
extern LDD_TError Error;
extern LDD_TDeviceData *MySPIPtr;

void SM1_OnError(LDD_TUserData *UserDataPtr)
Error = SM1_GetError(MySPIPtr, (LDD_SPIMASTER_TError *)&ComError); /* Get communication errors if occured */

void TI1_OnInterrupt(void)
Bit1_NegVal(); /* Write your code here ... */

/* END Events */

#ifdef __cplusplus
} /* extern "C" */