CAN bus calculated data is wrong, preset data is right
Good day
I am sending a CAN message from a STM32F042. The first two bytes are the value read from an ADC split into 2 bytes. Then just for testing I set 4 bytes to "F042" which is then a fixed value that i know its sending what I ask. The problem I have is no matter how i format the ADC value its never correct on the CAN BUS even though my RxData that i pass to can shows it is correct. Any value that I put into RxData that is fixed such as the F042 is always correct.
I believe based on on the fact that I can fill all 8 bytes with fixed data like F042 and it always transmits as recieves correctly that my harware is good (My harness, a twisted pair cable with 120ohm termination, and both boards), for me that means it must be something in code of the F042 is going wrong.
This is the section of code described above
ADC_Select_CH4();
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
HAL_ADC_Stop(&hadc);
temp = HAL_ADC_GetValue(&hadc);
remainder100 = temp%100;
TxData[0] = remainder100;
count100 = (temp-remainder100)/100;
TxData[1] = count100;
TxData[3] = 'F';
TxData[4] = '0';
TxData[5] = '4';
TxData[6] = '2';
HAL_CAN_AddTxMessage(&hcan, &TxHeader, TxData, &TxMailbox);Ive attached a screenshot of the logic analizer, the RxData from cubeide and the main.c file.
