This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi.I am working on a CAN Bus project and I cant seem to print the floating value after performing a division operation between 2 unsigned 16 bit numbers. The value is printed as "ERROR2f":
Attached the code snippet for only the Print section:
uint8_t PPGMsg[5]; float PPG; uint16_t IR_combined,RED_combined; for(uIdx = 0; uIdx < psCANMsg->ui32MsgLen; uIdx++) { PPGMsg[uIdx]=psCANMsg->pui8MsgData[uIdx]; } IR_combined = (PPGMsg[1]<< 8)|PPGMsg[2]; RED_combined = (PPGMsg[3]<< 8)|PPGMsg[4]; if(RED_combined==0) PPGMsg[0]=0; else PPGMsg[0]=(RED_combined/IR_combined); PPG=((float)RED_combined/(float)IR_combined); UARTprintf("IR_combined is: %d\n",IR_combined); UARTprintf("RED_combined is: %d\n",RED_combined); UARTprintf("PPG is: %d\n",PPGMsg[0]); UARTprintf("float PPG 1 is: %.2f\n",PPG); UARTprintf("done\n");
Hello Gowtham,
Please see these threads for details about how to print floating point numbers with TivaWare:
https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/396220
http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/313525/1090648#1090648