Hello
I am measuring magnetic fields with the HMC5883L chip in single measurement mode, and transmitting the data via UART to a PC.
The program crashes (goes into faultISR loop) when the sprintf function is used. Often, it only happens the second time the function is used and everything from the first call is actually transmitted fine via UART (not every time).
I tried to increase the heap and stack sizes to 3072 and 2048 in the project properties window, but this didn't solve it.
Below is the part of the program where the sprintf function is used:
uint32_t measxL, measxH, measyL, measyH, measzL, measzH;
int16_t measx, measy, measz;
char meas[30];
while(1) // each cycle will give a measurement
{
// single measurement mode
reg = 0x02; // to CRA register
value = 0x01; // single measurement mode
HMC_I2C_TRANSMIT(slave_address, reg, value); // send to HMC5883L for configuration
vTaskDelay(10/portTICK_RATE_MS); // wait 10 ms for measurements to be performed (alternatively monitor DRDY)
// read data in HMC5883L registers
HMC_I2C_MEASUREMENT(slave_address, 0x06, &measxL, &measxH, &measyL, &measyH, &measzL, &measzH);
measx = ((measxH & 0xFF) << 8) | measxL;
measy = ((measyH & 0xFF) << 8) | measyL;
measz = ((measzH & 0xFF) << 8) | measzL;
sprintf(meas,"%d, %d, %d",measx,measy,measz);
uart0_printstring(meas);
vTaskDelay(1000/ portTICK_RATE_MS); // wait 1000 ms for next measurement
}
I just started working with this microcontroller, so I am beginner level. I have tried to look at other posts such as this one: https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1186770/tm4c123gh6pm-sprintf-with-float---printf_support-full-and-stack-size-to-1024-crashes
But it didn't solve my problem, and the last one is too advanced for me at this time.
I have included the required libraries and CCS doesn't give me any complaints.
Best regards,
Simon