Printf in event.c causes probles

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Printf in event.c causes probles

417 Views
jacewalton
Contributor III

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

Tags (1)
0 Kudos
1 Reply

300 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Jace,

The "printf" shouldn't impact the project .

I recommend you first refer to the demo code under "Help on component ":

pastedImage_2.png

pastedImage_1.png

Hope it helps

Alice

0 Kudos