RE: Need code for CAN driver for PK20DX256VLL7

"John Dammeyer" <[email protected]>
Newsgroups gmane.comp.hardware.bus.can
Message-ID <[email protected]>
The very first thing to do is to buy a CAN dongle like a CANUSB (Lawicel), CAN4USB (Zanthic), CAN Leaf (KVASER), CANVIEW USB (RM Michaelides) or some other version.  Since every CAN system needs at least two nodes it will give you one correctly working node to use for sending and receiving messages.  
 
If you are using Linux make sure you pick one of these dongles that is supported under Linux.
 
If you don’t have a development module with coded CAN drivers you will need to get that sorted out.
 
For example, a while back I needed a board with 5 CAN ports.  Searching the web I found this one.
http://hk.element14.com/freescale-semiconductor/evb9s12xdp512e/demo-board-mc9s12xdp512/dp/2134910
I’m in Canada and I bought two from a supplier in Italy, one for development and one for the end product.  It came with some simple test code.  It used the CodeWarrier development system that let me set breakpoints single step programs line by line.  Very important when developing code for hardware.  The 9S12 is a bit out of date now so I’m not suggesting you buy this board.
 
After I had a a simple “Hello World” program working on the serial port I wrote some code to send a single CAN message.  That meant initializing the registers, setting the ID and something like 1, 2, 3, 4 … into the data part of the message.  Once that was correctly received by the CANUSB dongle on a Hyperterm window I knew I had the bit rate and messaging correct.  
 
I then expanded on the transmit code to let me enter in the ID and data on the command line.  Once that was working I started on the receive code.
 
No interrupts.  Just polling the CAN message Receive Data available bit. Dump the received ID and data as hex bytes out the serial port to the second HyperTerm window.  The project I used the board for never did use or enable Rx Interrupts. It was the system master and determined when a node would reply.  Eventually I used all 5 CAN bus channels communicating through TKE Bridges (Finland)  to 50 nodes per channel for a total of 750 nodes.  To work with the TKE  Bridges I had to add a CAN4USB and write some CANOpen messages to talk to the control port on the Bridge for receiving  status information.  The end project is here.  http://www.autoartisans.com/rings/YVR_Rings.jpg
 
Sometimes it’s easier to also buy a small module that has a magazine article or workshop based around it.  Even if it’s not for the processor of choice.  Both ELEKTOR and CIRCUIT CELLAR magazines have had project articles with CAN.  None of that is money or time wasted since the education you get will help you with  your end project.  For example: http://www.elektor.com/controller-area-network-projects  I haven’t read this book but it may be the perfect thing to get you started.
 
I believe there is also an Arduino Shield that has CAN bus.  If you want to learn about CAN bus don’t get too focused on a specific processor.  Once you have the knowledge to get something working the target processor will be easy.  
 
John Dammeyer
 
 
 
 
 
 
From: [email protected] [mailto:[email protected]] On Behalf Of Sreevenkitesh Sree
Sent: July-14-14 4:02 AM
To: [email protected]
Subject: [CANLIST] Need code for CAN driver for PK20DX256VLL7
 
   i am using  freescale tower k20d72m , for that i need to interface CAN . can you please help me to get a sample code (to understand).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.