I create a project in KDS, and it use MK10DX256VLH7. Now, I have a question to ask for your help.
I use PE to initial a SPI component, which involve Input interrupt and Output interrupt,and at the initial progress, PE auto enable SPI component also.Then, I define two variables, spi_tx_fin and spi_rx_fin. In the project, PE create two event functions, void SPI_OnBlockReceived(LDD_TUserData *UserDataPtr) and void SPI_OnBlockSent(LDD_TUserData *UserDataPtr). For the convenience of polling SPI transmit and/or receive progress success or not, I write the code: spi_tx_fin = Yesand spi_rx_fin = Yes (Macro: Yes=1, No=0) in the two event functions respectively. Afterward, I define another function MotorInit(), which call function LDD_TError SPI_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr, uint16_t Size) generated by PE to transmit data on the SPI module. The code as follows:
uint32 INV_REF : 1;
uint32 SDO_INT : 1;
uint32 STEP_HALF : 1;
uint32 INV_STP : 1;
uint32 INV_DIR : 1;
uint32 EN_SD : 1;
uint32 POS_COMP_SEL_0 : 1;
uint32 POS_COMP_SEL_1 : 1;
uint32 EN_REFR : 1;
uint32 RESERVE : 15;
uint32 RW : 1;
uint32 JDX : 4;
uint32 smda : 2;
uint32 RRS : 1;
if_configuration_429.if_configuration_429.INV_REF = 0;
spi_tx_fin = No;
while(spi_tx_fin == No);
void SPI_OnBlockSent(LDD_TUserData *UserDataPtr)
/* Write your code here ... */
spi_tx_fin = Yes;
Unfortunately, when debug program, the progress was blocked here while(spi_tx_fin == No); I checked the debug progress and was sure in the event function void SPI_OnBlockSent(LDD_TUserData *UserDataPtr) the variable spi_tx_fin was set Yes
By the way, I offer my project to you. Thank you!
Above picture is about the build optimization level -Os, it is that debug progress was blocked here while(spi_tx_fin == No);
Now, the below picture is about the build optimization level None(-O0), it is that debug progress was ok sometime.
消息编辑者为：guo huoping One picture added
消息编辑者为：guo huoping Edit my question again! Wait your answer sincerely! Thank you!
Original Attachment has been moved to: workspace.kds.rar