hi all,
i am configuring the CAN module in 500 Kbps with Bus clock of 20 MHz, i need to transmit and receive can messages but i couldnt get any supportive document other than the data sheet. I need some clear document or example code to send and receive CAN messages in KEA128.
Regards,
Jashan M
Hi Jashan,
Please download MSCAN driver for Kinetis EA devices from here.
And KEA128 produce MSCAN module detailed info could be found at KEA128 reference manual chapter 32.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Ma Hui,
i went through the reference manual, i have few clarifications to make with transmitting the CAN message.
1. first i make INITRQ = INITAK = 0
2. then read CANTFLG
3. later write CANTFLG to CANTBSEL
and now i also have send function which is as given below,
void MSCAN0_send(){
MSCAN_CANTBSEL = MSCAN_CANTFLG;
MSCAN_TSIDR0 = 0x12; /* ID of the CAN message is 0x123 */
MSCAN_TSIDR1 = 0x60;
MSCAN_CANCTL0 &= ~MSCAN_CANCTL0_INITRQ_MASK; /* Disable INIT mode ************/
MSCAN_CANCTL1 &= ~MSCAN_CANCTL1_INITAK_MASK; /* Disable INIT mode ************/
if(MSCAN_CANTFLG & 0x01){
for(i=0;i<5;i++){
MSCAN_TEDSR(i) = transmit[i];
}
}
}
now i can the data to be Tx in respective reg so how do i push this buffer into CAN bus, am i missing some thing here ??
Regards,
Jashan M
Hi Jashan,
1. It based on which CAN ID mode you are using, standard ID or extend ID.
If using Standard ID, it need to use MSCAN_TSIDR0 and MSCAN_TSIDR1 registers;
If using Extend ID, it need to use MSCAN_TEIDR[0~3] registers.
2. The MSCAN_TEDSRn register is using to storage the 8 bytes of transmit Data.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
hi,
ya that helped me, now if i want to shift data from buffer to the CAN bus, what should i do ??
Regards,
Jashan M
Hi,
In my previous answer, there with [MSCAN driver for Kinetis EA devices] software, which provides the example about how to use MSCAN send CAN frame.
The example using Transmit_DataFrame() function in <Test_case.c> file.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------