We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello i am trying to build a simple DMA program to read ADC values and its working but not completely
the problem is here: at first this code is working 1.
u[0]=((float)ADC_Data[0])*3; sprintf(str,"%.2fv ",u[0]); LCD_SetPos(0,0); LCD_String(str);
when changed to : or even divide by 1 its not working any more and the LCD is too slow
u[0]=((float)ADC_Data[0])*3/4096; sprintf(str,"%.2fv ",u[0]); LCD_SetPos(0,0); LCD_String(str);
2. the debugger is updating the correct u[0] in this code without a problem:
but in this code not !!! why even when i put the 3 lines to comments its must not affect the u[0] value
u[0]=((float)ADC_Data[0])*3; // sprintf(str,"%.2fv ",u[0]); // LCD_SetPos(0,0); // LCD_String(str);
please please i spend hours ... hours without any success please help why the division is not working and the bug in updating u[0] value i tryied to use volatile variable double or others but always when i use division the code runs very slow
the full code is generated with Cubemx.
www.mediafire.com/.../file
volatile uint16_t ADC_Data[3]; // Changed by DMA, not normal code flow, must be volatile double d[3]; // sprintf works on doubles char str[32]; // plenty of space .. d[0]=(double)ADC_Data[0]) * (3.0 / 4096.0); // use floating point sprintf(str,"%.2lfv ",d[0]); LCD_SetPos(0,0); LCD_String(str);