Simone Iori

FlexCan strange behaviour

Discussion created by Simone Iori on Nov 23, 2006
Latest reply on Nov 24, 2006 by Simone Iori
Hello!
I'm working on a FlexCan application on the MCF52235. Everything works well, until I have at least two devices connected on the bus. Today I discovered that there is a problem when I left the board with the micro unconnected. The program stucks at this instruction:
Code:
while( (MCF_CAN_ERRSTAT & MCF_CAN_ERRSTAT_IDLE)==0 );

 

 

The complete code for sending routine is the following:
Code:
void CANSendData(int i, int ID, int length, int *data, int ide ){ //Attendi che il bus sia idlewhile( (MCF_CAN_ERRSTAT & MCF_CAN_ERRSTAT_IDLE)==0 );MCF_CAN_MBUF_CODE(i) = MCF_CAN_TX_INACTIVE; //MBi is inactive while( (MCF_CAN_ERRSTAT &    (MCF_CAN_ERRSTAT_TXRX + MCF_CAN_ERRSTAT_IDLE))       == MCF_CAN_ERRSTAT_TXRX);    // Configure IDMCF_CAN_MBUF_ID(i) = ID;  // Copy Tx data bytes to the message bufferCANLoadBufferData(i, length, data);      if(ide){ MCF_CAN_MBUF_CTRL(i) = 0x40 + 0x20 + length; }else { MCF_CAN_MBUF_CTRL(i) = length; }MCF_CAN_MBUF_CODE(i) = MCF_CAN_TX_TRONCE;}

 I thought that the bus never goes "idle" if the micro is not connected; so I removed the two while loop, and the program started to work correctly even when unconnected (or at least, doesn't stuck in the loop).
 
I'm still quite uncertain about the usefulness of these while loops...but I was adviced to put them in the code to be sure that the buffer was deactivated.
Does anybody  find a similar problem?
 
Simone

 

Outcomes