Hi,
I use the startertrak dev kit mpc5606b.
I just wanted to know how to use multiple CAN buses simultaneouly.
for example ,
void CanTxMsg (uint32_t id, uint8_t mb, uint8_t dlc, uint8_t data[], uint8_t ext)
{
uint8_t i;
if (ext)
{
CAN_1.BUF[mb].CS.B.IDE = 1; /* extended ID */
CAN_1.BUF[mb].ID.R = id; /* Tx ID extended */
}
else
{
CAN_1.BUF[mb].CS.B.IDE = 0; /* standard ID */
CAN_1.BUF[mb].ID.B.STD_ID = (uint16_t)id; /* Tx ID standard */
}
CAN_1.BUF[mb].CS.B.RTR = 0; /* no remote Tx request frame */
CAN_1.BUF[mb].CS.B.LENGTH = dlc; /* # bytes to Tx */
for (i = 0; i < dlc; i++)
{
CAN_1.BUF[mb].DATA.B[i] = data[i]; /* Data to Tx */
}
CAN_1.BUF[mb].CS.B.SRR = 1; /* Tx frame */
CAN_1.BUF[mb].CS.B.CODE = CAN_TX_MSG; /* Send msg */
}
The above is the function definition for using CAN 1 to transmit messages , should I replace "CAN_1" to "CAN_0" to use the 0th CAN bus?
To be precise:
1. initialize required CAN buses using RAPPID.
2. create my own function definition in CANdrv.c
for example, to use 0th CAN bus , I will replace all "CAN_1" with "CAN_0" and create a new function definition known as CanTxMsg0()
3. Declare the same as global funtion declaration in CANapi.h
For example , I will declare the above CanTxMsg0() as global function declaration
CanTxMsg0(uint32_t, uint8_t, uint8_t, uint8_t[], uint8_t)
4.Call the function in main.c
For example, I will call the above function as
CanTxMsg0 (2, 1, 8, (uint8_t *)msgOKCAN, 0);
Is my procedure correct ?
Thank you