Using Multiple Tx MBs for transmiting CAN Messages

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Using Multiple Tx MBs for transmiting CAN Messages

ソリューションへジャンプ
1,300件の閲覧回数
davidzhou
Contributor V

Hi,

I Have K60 Tower board: _K60P144M150SF3RM. using Code Warrior 10.6.4 and MQX 4.2

I have the following code for transmitting CAN Messages. It works if one TX MB is used for transmitting, or if any TX MB is busy, just return the function and do another try. But if one of the MB is busy, i.e. Not NOT_ACTIVE, then it cannot use another MB for TX. Although multiple TX MBs are scanned for highest priority message to be TX-ed first. It shall allow using multiple TX MBs. Something is not right. What needs to be done for using multiple TX MBs for transmitting?

uint8_t TransmitCanMsg(uint8_t bCANId_Index, uint8_t bTail) {
volatile CanMemMapPtr pCanReg = _bsp_get_flexcan_base_address(0);
int i=0;
volatile uint8_t bMbID = 0;
volatile uint8_t bBusy = TRUE;

for (i=8; i<(8+NUM_OF_MB_USED_TX); i++) {  
_disable_int();
if ((pCanReg->MB[i].CS & CAN_CS_CODE(CAN_TX_MSG_BUFFER_NOT_ACTIVE))== CAN_CS_CODE(CAN_TX_MSG_BUFFER_NOT_ACTIVE)) {
    bBusy = FALSE;
}
_enable_int();


if ( bBusy == TRUE) {
    continue;
}
pCanReg->MB[i].ID  &= ~(0x1FFFFFFF);  //clear
pCanReg->MB[i].ID = MyID & 0x1FFFFFFF ;
pCanReg->MB[i].WORD0 = MyWORD0;  
pCanReg->MB[i].WORD1 = MyWORD1;  
     // Set IDE  //Set SRR bit -Not Set
pCanReg->MB[bMbID].CS &= ~(CAN_CS_CODE_MASK);    // Reset the code
//pCanReg->MB[i].CS &= ~CAN_CS_DLC_MASK;    //Clear the DLC
pCanReg->MB[bMbID].CS |= (CAN_CS_IDE_MASK | (CAN_CS_CODE(CAN_MESSAGE_TRANSMIT_ONCE) | TX_DLC));  
return 1;     //transmitted
}
return 0;                                                 
}

Thank you,

David Zhou

ラベル(1)
0 件の賞賛
返信
1 解決策
1,094件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi David:

I think for one can port, you can transmit one mailbox at one time, if more mailbox needs to be sent, they will become part of the arbitration process. if two or more Mailbox have the same priority, the regular ID will determine the priority of transmission. If two or more MBs have the same priority and the same regular ID, the lowest MB will be transmitted first.

Regards

Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,095件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi David:

I think for one can port, you can transmit one mailbox at one time, if more mailbox needs to be sent, they will become part of the arbitration process. if two or more Mailbox have the same priority, the regular ID will determine the priority of transmission. If two or more MBs have the same priority and the same regular ID, the lowest MB will be transmitted first.

Regards

Daniel

0 件の賞賛
返信
1,094件の閲覧回数
davidzhou
Contributor V

Hi Daniel,

Thank you.

David Zhou

0 件の賞賛
返信