AnsweredAssumed Answered

Printf in event.c causes probles

Question asked by Jace Walton on Mar 15, 2017
Latest reply on Mar 15, 2017 by Alice_Yang

using chip set mk22fx512vlk12

in even.c ...

void I2C_OnMasterBlockSent(LDD_TUserData *UserDataPtr)
{
/* Write your code here ... */
/* Set DataTransmittedFlg flag */
appData.DataTransmittedFlg = TRUE;
printf("Event I2C Block Sent\n\r");
}

/*
** ===================================================================
** Event : I2C_OnMasterBlockReceived (module Events)
**
** Component : I2C [I2C_LDD]
*/
/*!
** @brief
** This event is called when I2C is in master mode and finishes
** the reception of the data successfully. This event is not
** available for the SLAVE mode and if MasterReceiveBlock is
** disabled.
** @param
** UserDataPtr - Pointer to the user or
** RTOS specific data. This pointer is passed
** as the parameter of Init method.
*/
/* ===================================================================*/

void I2C_OnMasterBlockReceived(LDD_TUserData *UserDataPtr)
{
/* Write your code here ... */
/* Set DataReceivedFlg flag */
appData.DataReceivedFlg = TRUE;
//printf("Event I2C Block Received\n\r");
}

Notice the two printf lines. I can have both statements print 

when I comment out the printf in I2C_OnMasterBlockSend this event never asserts.

the code gets stuck in the first I2C write event.

 

do
{
appData.Error = I2C_MasterSendBlock(appData.I2C_Ptr, &data, 1U,LDD_I2C_SEND_STOP);
while (!appData.DataTransmittedFlg){}
appData.DataTransmittedFlg = FALSE;    ///CODE REMAINS HEAR.
if (appData.Error != 0)
{
printf("I2C write during read error %d\r\n", appData.Error);
//cpu_delay_ms(1);
}
} while (appData.Error != 0);

 

when I put it back in it works fine. 

 

how can I remove these printf calls and still have my code work?

thanks

Outcomes