2020-12-22 09:52 PM - edited 2023-11-20 09:20 AM
Hi. I am trying to make a tester for a PCB and implemented ADC value display and Timer PWM output with no issues thanks to examples and youtube videos.
Application has 2 screens, 1 with ADC measurements and 1 with Frequency Check. When trying to update textAreaWithOneWildcard on the 1st screen there are no issues, but doing same on 2nd screen causes system to fall into Memory Management Interrupt Handler (both screens use the similar logic, names of variables and methods are different).
The debugger can not provide any Error details as the issue seems to be in the Drawable class.
The definition of all textAreasWithOneWildcard is similar (position, buffer lengths are different obviously).
// 1st screen display update function - works with no issues
void MeasurementScreenView::analogUpdate(uint32_t value0, uint32_t value1, uint32_t value2, uint32_t value3)
{
memset(&measurementValue_5VBuffer, 0, MEASUREMENTVALUE_5V_SIZE);
Unicode::snprintfFloat(measurementValue_5VBuffer, sizeof(measurementValue_5VBuffer), "%.2f", value0 * 0.000805664); // converting ADC integer to Voltage 3.3/4096 = 0.000805664
measurementValue_5V.invalidate();
memset(&measurementValue_3V3Buffer, 0, MEASUREMENTVALUE_3V3_SIZE);
Unicode::snprintfFloat(measurementValue_3V3Buffer, sizeof(measurementValue_3V3Buffer), "%.2f", value1 * 0.000805664); // converting ADC integer to Voltage 3.3/4096 = 0.000805664
measurementValue_3V3.invalidate();
memset(&measurementValue_PEBuffer, 0, MEASUREMENTVALUE_PE_SIZE);
Unicode::snprintfFloat(measurementValue_PEBuffer, sizeof(measurementValue_PEBuffer), "%.2f", value2 * 0.000805664); // converting ADC integer to Voltage 3.3/4096 = 0.000805664
measurementValue_PE.invalidate();
memset(&measurementValue_PTBuffer, 0, MEASUREMENTVALUE_PT_SIZE);
Unicode::snprintfFloat(measurementValue_PTBuffer, sizeof(measurementValue_PTBuffer), "%.2f", value3 * 0.000805664); // converting ADC integer to Voltage 3.3/4096 = 0.000805664
measurementValue_PT.invalidate();
}
// 2nd screen display function - crashes to Memory Management Interrupt handler
void FrequencyScreenView::frequencyUpdate(uint32_t frequency1, uint32_t frequency2, uint32_t frequency3)
{
memset(&frequencyValue_****, 0, FREQUENCYVALUE_****_SIZE); // fills array with 0s
Unicode::snprintfFloat(frequencyValue_toONBuffer, sizeof(frequencyValue_toONBuffer), "%.2f", frequency2 * 0.001); // displaying converted value of Low to High frequency in kHz
frequencyValue_****.invalidate();
memset(&frequencyValue_toOFF, 0, FREQUENCYVALUE_TOOFF_SIZE);
Unicode::snprintfFloat(frequencyValue_toOFFBuffer, sizeof(frequencyValue_toOFFBuffer), "%.2f", frequency3 * 0.001); // displaying converted value of High to Low frequency in kHz
frequencyValue_toOFF.invalidate();
memset(&frequencyValue_Current, 0, FREQUENCYVALUE_CURRENT_SIZE);
Unicode::snprintfFloat(frequencyValue_CurrentBuffer, sizeof(frequencyValue_CurrentBuffer), "%.2f", frequency1 * 0.001); // displaying converted value of Current frequency in kHz
frequencyValue_Current.invalidate();
}
Attached is my CubeIDE application project, just need to add "Middlewares" folders in CubeIDE.
Thank you in advance.
Solved! Go to Solution.
2020-12-23 12:03 AM
WTF is memset(&frequencyValue_****, 0, FREQUENCYVALUE_****_SIZE);
and all memset in freq miss Buffer in names.
2020-12-23 12:03 AM
WTF is memset(&frequencyValue_****, 0, FREQUENCYVALUE_****_SIZE);
and all memset in freq miss Buffer in names.
2021-01-03 02:43 PM
'*' filled in space of the word that the Comment editor sees as offensive - to ON as one word comes as **** that is not allowed here.
memset is to overwrite previous characters in the array, just in case new value doesn't fill the whole array
2021-01-03 02:56 PM
Oh I see now, thanks.
2021-01-03 03:01 PM
Moderator - you can delete the post now.