1 (edited by vmoses 20-01-2019 04:45:46)

Topic: Receive Data Registers Don't Clear

I had some logic that was manipulating a one byte message and it worked flawlessly when running it through debug in CannyLab.  It would never work in the car.  I finally figured out that it wasn't the logic...it was the data. Canny doesn't clear the Received Data Registers before a message is read.  If you receive a message of length 1 and then read D1,D0 you will get the data from your message in D0 and whatever was left over from the last received message in D1. This will happen when reading the even numbered byte that is the the last byte in any message.

This isn't really a problem if you know about it.   A bitwise-and with 0x00ff  before you try to use the data will clear the upper bits in the word.  It's just that if you are reading odd (as opposed to even) length can messages, some care needs to be taken.

2

Re: Receive Data Registers Don't Clear

Yes, that was intended. Unused registers are not cleared for performance reasons. Unused receive message bytes have undefined values.
Anyway, thank you for sharing your experience!

PS:
There was a small failure on the forum, we fixed it.