Hi @ all,
I have got a weird problem determining the transmission direction of CAN messages in the message RAM. Due to auto-code portions in my project I am unable to predetermine the message direction and have to distinguish it during runtime.
Therefor I used the following code snippet:
"for (ctr_msgbox=1;ctr_msgbox<=64;ctr_msgbox++){
if ( canIsMessageBoxValid( canREG1, ctr_msgbox ) ){
// check whether message is a transmit message
while ((canREG1->IF2STAT & 0x80U) ==0x80U){
}/* wait */
buffer = canREG1->IF2CMD;
canREG1->IF2CMD = 0x20; // read arb field from ram only
canREG1->IF2NO = (uint8) ctr_msgbox; // set actual message box number
while ((canREG1->IF2STAT & 0x80U) ==0x80U){
}/* wait */
dir = (uint8) ( (uint32) ((canREG1->IF2ARB & (1<<29) )>>29)); // mask tx/rx bit
if ( dir ){
// if message is tx messages, then send through CAN driver
canTransmit(canREG1, ctr_msgbox, &tx_data[0]);
}
}
}"
This one works fine, but a susequent function doing the same for the receive direction is unable to detect the right tx/rx bit! Is there a structural problem in the code?
It seems as a subsequent call of canIsRxMessageArrived( ) is unable to get a actual value. This leads to a permanent call canGetData() although no new message were transmitted to the system:
"for(ctr_msgbox=1;ctr_msgbox<=64;ctr_msgbox++){
if ( canIsMessageBoxValid( canREG1, ctr_msgbox ) ){
// check whether message is receive message
while ((canREG1->IF1STAT & 0x80U) ==0x80U){
}/* wait */
buffer = canREG1->IF1CMD;
canREG1->IF1CMD = 0x20;
canREG1->IF1NO = (uint8) ctr_msgbox;
while ((canREG1->IF1STAT & 0x80U) ==0x80U){
}/* wait */
dir = (uint8) ( (uint32) ((canREG1->IF1ARB & (1<<29) )>>29));
if ( !dir ){
if ( canIsRxMessageArrived( canREG1, ctr_msgbox ) ){
canGetData(canREG1, ctr_msgbox, &rx_data[0]);
}
}
}
}"
CAN driver was generated with HALCOGEN 03.06.00
Hercules RM48L952ZWT on control card
Thanks in advance for any hints and remarks!