Question
Memory Hard fault with string lib
Posted on September 02, 2016 at 15:29 Hi everyone, I have a question about an hard fault generated by a line of code. I'm working with a STM32F401RE and Atollic True Studio The line is : sprintf (str,
''PAIR %s\r''
,BT_deviceTAB[0].BDADDR); the BT_deviceTAB[0].BDADDR type is char tab[13]; and previously filled with a string ended with '\0'The hardfault is :Bus, memory management or usage fault (FORCED)
Attempt to switch to invalid state (INVSTATE) But when i use the following methode i don't have any problems : strcpy (str, ''PAIR '' ); strcpy (name,BT_deviceTabHeadset[BT_number].BDADDR); strcat (str, name); Do you have an explanation of how this functions works. I'm very surprised that sprintf generate memory hard fault Oo ! Thanks a lot #sprintf-hardfault
