
Software Module Descriptions
Software Implementation
DRM033 — Rev 0
Designer Reference Manual
MOTOROLA
Software Module Descriptions
For More Information On This Product,
Go to: www.freescale.com
95
sendData[1] = node.digitIn.byte.lsb;
sendData[2] = node.digitIn.byte.msb;
tmp = CAN_LoadMB(5, sendData, 0); /* load buf */
tmp = CAN_TransmitMB(5, 0); /* send buf */
For the
CAN reception
the pooling technique is utilized in msCAN
Driver Software. Therefore user code has to periodically check the
status of each message buffer, by calling
CAN_CheckStatusMB()
function. When data arrives it can be read using
CAN_ReadDataMB()
function. The following demonstration piece of code checks the
message buffers 0 and 1; when status
NEWDATA
is detected on them,
the message buffer received a CAN message with a valid message
object identifier.
tU08 bufSts[2]; /* buffer status of CAN reception */
tU08 bufData[9]; /* buffer of received CAN message */
tmp = CAN_CheckStatusMB(0, bufSts, 0); /* MB 0 - configure (set) digit out*/
if(bufSts[0] == NEWDATA) /* new data in MB 0 */
{
tmp = CAN_ReadDataMB(0, bufData, 0);
node.digitOut.byte.lsb = bufData[1]; /* write new value */
node.digitOut.byte.msb = bufData[2];
}
tmp = CAN_CheckStatusMB(1, bufSts, 0); /* Mb 1 - configure analog inputs */
if(bufSts[0] == NEWDATA) /* new data in MB 1 */
{
tmp = CAN_ReadDataMB(1, bufData, 0);
...
}
4.4.3 SCI Module Initialization
Although the SCI module is not utilized within the application, the project
is already supplemented with SCI initialization function called
sci0Init(void)
(
sci.c
file),
which enables both the transmitter and the
receiver of the module and sets the SCI baudrate. When running with a
16 MHz crystal, the SCI baudrate is set to 38.400 bps, while for a 4 MHz
crystal, the preset baudrate is equal to 9.600 bps.
F
Freescale Semiconductor, Inc.
n
.