cancel
Showing results for 
Search instead for 
Did you mean: 

CAN bus, stop transmitting when no othet node on bus?

ezanen9
Associate II
Posted on May 30, 2009 at 16:04

CAN bus, stop transmitting when no othet node on bus?

2 REPLIES 2
ezanen9
Associate II
Posted on May 28, 2009 at 12:10

Dear all,

When I have only one node on the CAN bus and this node is start sending data it will never stop transmitting. Of course this is because there is no other node to answer/reply.

However in all the ST library/examples all the transmit message functions CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg[0]);are followed bij the CAN_WaitEndOfTx(); function.

When there is no other node on the bus the software will hang in this CAN_WaitEndOfTx(); function(and never get out of it). This way my MCU does not continue to do it's other tasks.

I created a timer (inside waitfunction) that forced to leave this wait function after 1 second of no replay/answer of a other node. After leaving the waitfunction I used the CAN_ReleaseTxMessage(CAN_TX_MSGOBJ); function to cleare the message object. But I knowtest that some of the CAN bus messages are lost/not transmitted to the other nodes using is timeout function.

Does someone have any idea who to solve this problem.

Thanks Jim,

my code:

CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg);

CAN_WaitEndOfTx();//see changed function below

CAN_ReleaseTxMessage(CAN_TX_MSGOBJ);

void CAN_WaitEndOfTx( void )

{

unsigned int iTeller=0;

while (((CAN->SR & CAN_SR_TXOK) == 0)&& iTeller < 7)//second delay//while (((CAN->SR & CAN_SR_TXOK) == 0) && ((TIM2_SR & TIM_TO_IT) == 0))//second delay

{

if((TIM2_SR & TIM_TO_IT) != 0)

{

TIM2_SR &= ~TIM_TO_IT; //reset TOF bit

iTeller++;

IOPORT0_PD ^= 0x0080;

}

//Wait

}

CAN->SR &= ~CAN_SR_TXOK;

}

gedas
Associate
Posted on May 30, 2009 at 16:04

Code:

<BR> <BR>main() <BR>( <BR> while(1) <BR> { <BR> if(!CAN_IsTransmitRequested (31)) <BR> { <BR> CAN_SendMessage( 31,&TxCanMsg); <BR> } <BR> do_another_work(); <BR> } <BR>} <BR> <BR>INTERRUPT_function() <BR>{ <BR> CAN_ReleaseTxMessage(31); <BR>} <BR> <BR>

Gediminas

http://www.edevices.lt

[ This message was edited by: gedas on 30-05-2009 19:35 ]

[ This message was edited by: gedas on 30-05-2009 19:37 ]