* UPDATE *
here is what I found. Whenever I had that function in there it wouldnt actually make the code lock up. what it would actually do is make the Read RTC I2C function very slow to execute but the code would still run properly, but I had to wait a really long time to get past everytime I read the RTC. so what ended up happening was that there is an alarm interrupt for the RTC and this was triggering other I2C interactions inside the ISR so what it looks like it was doing was trying to do two i2c communications at the same time therefore slowing down the process. I removed the functions in the ISR and it now its working I will keep investigating.
I am having this problem when programming an STM32F103 micro using IAR 5.40 I have this function that If I try to printf a local variable it causes the code to freeze at another point way before it even gets to that function in question.
What could possibly be causing this ??
this is the function
u8 GSM_Telit_ReadSms( u8 bSmsIndex )
{
char bTmpSms[3] = { 0 };
itoa( bSmsIndex, bTmpSms, 10 ); // converts the smsindex into a string
printf("index = %s\n", bTmpSms); //this printf caused the code to get stuck in the RTC // byte read function !!!!!!!
GSM_Telit_RequestModem( "AT+CMGR=""1", 10, "CMGR", 5, 0 );
return 1;
}
I tried this as well and this does not causes the lock I experienced
u8 GSM_Telit_ReadSms( u8 bSmsIndex )
{
char bTmpSms[3] = { 0 };
itoa( bSmsIndex, bTmpSms, 10 );
printf("index = 2\n");
GSM_Telit_RequestModem( "AT+CMGR=""1", 10, "CMGR", 5, 0 );
return 1;
}
There is no optimization enabled whatsoever and the code gets stuck when trying to read a byte out of my I2C RTC, but as soon as I remove this printf("index = %s\n", bTmpSms);
or use this one instead printf("index = 2\n");
then everything is happy Any ideas ???
Edit : The bSmsIndex will never be more than 30 actually and even then the lock up happens wayyyy before this function gets called.