AN2283 Freescale Semiconductor / Motorola, AN2283 Datasheet - Page 23

no-image

AN2283

Manufacturer Part Number
AN2283
Description
Scalable Controller Area Network (MSCAN)
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
/************************************************
***************************************************/
@interrupt void receive_interrupt(void){
MOTOROLA
volatile unsigned char received_length;
volatile unsigned char count;
Store_RX[m].ID0 = rx_buffer.ID0; // Stores the message’s ID from the receive buffer
Store_RX[m].Length =
Store_RX[m].Priority = rx_buffer.Priority // Stores the message’s priority from the receive buffer
received_length = Store_RX[m].Length; //Stores the Data Length of the message into a variable to be used in the next step
// Store the data bytes of the message from the receive buffer
// The number of data bytes in the message is determined by length
for(count = 0; count < received_length; ++count){Store_RX[m].data[count] = rx_buffer.data[count];}
HIT = CIDAC & 0x07; // Stores the filter heads
CRFLG = 0x01;
// DO NOT USE THE BSET Instruction Instead use the STA when clearing the RXF flag..
}
RECEIVE INTERRUPT
NOTE:
//Clear the RXF flag in the CRFLG register to indicate this buffer is empty(released) and another
//message can be accepted into the receive buffer
rx_buffer.DLC; // Stores the message’s length from the receive buffer
Motorola Scalable Controller Area Network (MSCAN) Interrupts
RXF — Receive Buffer Full
As discussed, a successful message received is one that has passed through
the hardware filters set up by CIDAR and CIDMR. Additional filtering can be
implemented through software. Maximize the hardware filtering process in
order to improve the software filtering efficiency.
For more details on acceptance filters and secondary software filtering, refer to
Using The Motorola msCAN Filter Configuration Tool (Motorola document
order number AN2010/D).
A piece of sample code illustrating the receive interrupt follows.
The receive interrupt routine is short, just a couple steps. This is very important
to achieve code/time efficiency.
WUPIF
The RXF flag is set by the MSCAN when a new message is available in the
foreground receive buffer. This flag indicates whether the buffer is loaded
with a correctly received message. After the CPU reads the message from
the receive buffer, the RXF flag must be handshaken in order to release the
buffer. When the RXF flag is set it prohibits the exchange of a successfully
received message from the background receive buffer into the foreground
buffer.
Freescale Semiconductor, Inc.
Bit 7
For More Information On This Product,
1 (set) =
0 (clear) = The receive buffer is released (empty).
RWRNIF
Figure 18. MSCAN Receiver Flag Register (CRFLG)
Go to: www.freescale.com
6
The receive buffer is full and a new message is available.
TWRNIF
5
RERRIF
4
TERRIF
3
BOFFIF
2
Receive Structure Overview
OVRIF
1
AN2283/D
Bit 0
RXF
23

Related parts for AN2283