Hi, all.
I am trying to use the CAN time management unit in order to know if a message is transmitted in 20 msec, but I can not find any example about how to use it.
The CAN bit rate is 500Kbps, therefore the time stamp counter register must be increased in 10000 units to count 20msec. I do not know how to do it and I hope someone can help me.
I have planned two options.
1st option:
- Every time that I want to transmit a message, I read CANTSC register, add 10000 units to its value and write this value in the MOTO register.
- Start the transmission (TRS=1) and wait until TA = 1 (transmission OK) or CANTOS bit = 1 (fault transmission)
- In the case of fault transmission, I suppose that I must abort the transmission using the corresponding CANTRR bit.
2nd option:
- Every time that I want to transmit a message, reset CANTSC register writing a 00000 and charge MOTO register with the value 10000,
- Start the transmission (TRS=1) and wait until TA = 1 (transmission OK) or CANTOS bit = 1 (fault transmission)
- In the case of fault transmission, I suppose that I must abort the transmission using the corresponding CANTRR bit.
I think both options can work successfully, but what happen in the first option if CANTSC value + 10000 is overflowing the maximum value of a 32-bit MOTO register.
The second option, I think it can work well with only 1 mailbox working but if you want to use more than one mailbox, we can not reset the CANTSC register every time that I charge a new mailbox with a new value. I Think CANTSC counter register is the same for all mailboxes.
Other doubt. According to the datasheet, TSC is a 32-bit free-running timer, so I can not stop/start it. Is it running since RESET the micro or is it running since I enable something in the CAN module?
Thanks in advance.