While checking the code generated by Halcogen, to check if a msg obj is free or not, few msg obj check IF1STAT,few check IF2STAT.
Why is it so?
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.
While checking the code generated by Halcogen, to check if a msg obj is free or not, few msg obj check IF1STAT,few check IF2STAT.
Why is it so?
Yes, you could just use one set of IF registers. The reason HALCoGen alternates the use of IF1 and IF2 when initializing the can mailboxes is that you don't waste time waiting for the IF registers to write to the mailbox RAM before starting to setup the next mailbox. For example, in canInit(), it uses IF1 registers to setup message1, then it checks if IF2 registers are busy (they should not be because they have not been used yet). Now it can write to IF2 registers while the IF1 registers are being copied into the message RAM by the DCAN hardware. Then while IF2 registers are being copied into message2 RAM, the code checks if IF1 registers are busy and then starts to setup message3.
The whole setup could be done using only IF1 (or only IF2), but then the code would actually spend some time waiting in the loop:
while ((canREG1->IF1STAT & 0x80U) ==0x80U);