Closed Riesi closed 1 year ago
Hi Riesi,
sorry for the late reply. You are totally right, I've already fixed this with a commit ~2 weeks ago. I just forgot to reply to this issue, I'm very sorry.
The problem was the same in the "parent" library code, I've fixed it there as well: TLE493D-3DMagnetic-Sensor
Thank you very much for reporting this. I will close this issue for now, if there is anything else, feel free to reopen it.
Hello! When using the concatResults code as a reference I found that the code path for the temperature conversion looks quite wrong. https://github.com/Infineon/TLI493D-W2BW/blob/master/src/Tli493d.cpp#L567-L574
upperByte contains Bit 11-4 and is not ambiguous lowerByte only contains Bit 3 and 2 with two layouts which both don't work with the given code Layout A) Bit 3&2 are in the LSBs so XXXX XX32 Layout B) They are in the MSBs still 32XX XXXX
The bit mask is 0xC0 = 0b1100 0000
1)
value
's upper byte gets set to upperByte. 2) Masking lowerByte with 0xC0 will only keep the two MSB resulting in 0000 0000 or 3200 0000 depending on the given layout. Casting this to 16Bit and shifting 6 to the left results in either a value of 0 or 0032 0000 0000 0000. ORing this withvalue
will do nothing or collide upperByte bits with lowerByte bits, which seems wrong. 3) ORing 0x06 = 0b0000 0110 tovalue
4) Right shifting ofvalue
by 4 makes step 3) irrelevantI assume the correct version assuming lowerByte contains the temperature bits in its LSBs (layout A) should look like this:
Assuming layout B:
I would do a PR, but I am not sure what your layout is, so I wanted to discuss this first.
Kind regards, Riesi