Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CAN implementation for the MC9S12C128 Freescale controller

Status
Not open for further replies.

saudrehman

Member level 1
Member level 1
Joined
Dec 20, 2005
Messages
40
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,697
hi guys,
i am supposed to write application programs for sending and receiving data from PC (RS232 vi)a CAN Bus using the MC9S12C128 Freescale controller which has a MsCAN module.i have two boards and i have to send data fromPC to one of the boards which will convert it into a Can Frame and send it to the other board which will receive it and send back to PC .
how should i go about writing the code.i have read and re-read the controller data sheets but have no clue on how to implement it.
how should i go abt it?
please help.
 

CAN Implementation

First off all, you have to decide for a communication protocol or to create one. The CAN frame is limited to 8 bytes. If you want to transmit from PC, messages with more then 8 bytes then you have to think how the message will be fragmented and pack inside the CAN messages. Also you have to decide if you use ACK reply for packets.
I don't have any experience with MC9S12C128, but the principles have to be the same with other CAN controllers:
if we suppose that your messages are shorter then 8 bytes you have to assign an ID for CAN telegram (different for each node), set the reception filter for that ID at the receiver node and transfer the serial received bytes in CAN data registers. Start the CAN transmision and at reception node, poll the CAN reception flag. Took the data from CAN receiver registers when the telegram arrived and transfer it to PC trough serial.
Looks simple but it isn't. You will have to set all the CAN parameters carefully, in order to work. And don't forget the 120 ohm line terminations.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top