Hi kerryzhou,
I don't know how to check spi wave, please tell me how and please give any link of spi example using dma. I already done the optimization IAR, there is no difference in code between IAR and CW I don't why the write operation isn't working.
/* ###################################################################
** Filename : main.c
** Project : RCC_SPI
** Processor : MKL25Z128VLK4
** Version : Driver 01.01
** Compiler : GNU C Compiler
** Date/Time : 2016-12-23, 16:33, # 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 */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "SM1.h"
#include "SM1_TxDMA.h"
#include "HOLD.h"
#include "BitIoLdd1.h"
#include "WP.h"
#include "BitIoLdd2.h"
#include "CS.h"
#include "BitIoLdd3.h"
#include "DMA1.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 5
#define BLOCKSIZE 5
/* 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 */
uint8 OutData[BLOCKSIZE];
OutData[0] =0x02;
OutData[1] =0x02;
OutData[2] =0x00;
OutData[3] =0x00;
OutData[4] =0x22; // don't care, just for read back data.
//uint8 OutData[BLOCKSIZE] = {0x90,0x00,0x00,0x00,0xff};
//uint8 OutData[BLOCKSIZE] = {0x05};
uint8 InpData[BLOCK_SIZE]={0xFF};
LDD_TDeviceData *spi_ptr;
uint16 transmit_no;
uint16 receive_no;
uint16 Error;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
/* For example: for(;;) { } */
/* PORTD_PCR7: Enable Pull Up ON MISO (PORT_PCR_PE_MASK|PORT_PCR_PS_MASK) */
HOLD_SetVal();
WP_SetVal();
//SM1_TxDMA_ChInit
spi_ptr=SM1_Init(NULL);
while(1)
{
// PORTE_PCR4 |= (PORT_PCR_PE_MASK|PORT_PCR_PS_MASK);//
GPIOE_PDOR &= ~(GPIO_PDOR_PDO(0x10));
//CS_ClrVal();
Error = SM1_ReceiveBlock(spi_ptr, InpData, BLOCK_SIZE);
Error = SM1_SendBlock(spi_ptr, OutData,BLOCKSIZE);
while (!SM1_GetBlockSentStatus(spi_ptr)) { /* Wait until data block is transmitted/received */
SM1_Main(spi_ptr);
}
transmit_no=SM1_GetSentDataNum(spi_ptr);
receive_no=SM1_GetReceivedDataNum(spi_ptr);
while (!SM1_GetBlockReceivedStatus(spi_ptr)) { /* Wait until data block is transmitted/received */
SM1_Main(spi_ptr);
}
// PORTE_PCR4 &= ~(PORT_PCR_PE_MASK|PORT_PCR_PS_MASK);
//CS_SetVal();
GPIOE_PDOR |= (GPIO_PDOR_PDO(0x10));
}
/*** 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.3 [05.09]
** for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/
The above is the code in IAR for writing a byte.