S12ZVC how to clear the RX buffer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12ZVC how to clear the RX buffer

1,422 Views
highlander
Contributor II

Is there a way to directly clear the CAN RX Buffer?

I have a routine that starts when it reads a certain ID. I need it to stop sending data as soon as the ECM is not sending this ID.
On certain occasions the buffer is kept full with this specific ID thus the code keeps running even when the ECM is not sending any other messages and I need to clear it.

Is there a way to clear the CAN RX buffer to avoid this loop?

 

Thanks

0 Kudos
Reply
3 Replies

1,406 Views
dastek
Contributor III

Hi,

This may not be relevant, but I want to accept all CAN traffic and I use

   CAN0IDAR0 = 0xff;

   CAN0IDMR0 = 0xff;

I want the CAN in a Don't Care mode, where is interrupts on all messages.

 

 

0 Kudos
Reply

1,410 Views
highlander
Contributor II

The setup is done by processor Expert.

CAN0BTR0 = 0x01U;

CAN0BTR1 = 0x1CU;

CANxIDAR0 = 0x00U

CANxIDMR1 = 0xFFU

The acceptance mode is Two 32-bit acceptance filters


I do not have a problem receiving. It works really nice and reliable. The problem is when it stops and that particular ID is on the buffer. I tested with CAN0RFLG = RXF; and it still did the same. I solved it by adding another timer into the code that resets when the id changes, thus is if the buffer is with the same ID for too long it stops transmitting. This was the current solution for now. Works rather well, but feel its not the correct way to code it.

Now if I could only get the chip after this development, it would be great.

 

0 Kudos
Reply

1,417 Views
dastek
Contributor III

Mr Highlander

The CAN bus has an acknowledge bit that is sent when you module receives the message,

This is automatic.

You need to do the following at the end of your CAN interrupt .

CAN1RFLG = RXF;     // Clear the RX Full flag to release buffer

I think that the re-transmit that you see is the fact that the transmiter and receiver do not have the same setup and by this I mean bit rate and other CAN setup which is in :

     CANxBTR0 and

     CANxBTR1

Have you setup the CAN acceptance to receive this CAN ID?

    CANxIDAC = ?

    CANxIDAR0 = ?   and   CANxIDMR1 = ?

I have seen that once you get the CAN settings right, it magically just works.

Good luck.

0 Kudos
Reply