element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs TI Hercules LaunchPad -  test the CAN with a poor man's CAN driver
  • Blogs
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 13 Dec 2014 10:40 PM Date Created
  • Views 260 views
  • Likes 6 likes
  • Comments 7 comments
  • hercules_launchpad
  • arm_cortex
  • texas_instruments
  • automotive
  • microcontroller
  • protocol
  • feature_tutorial
  • can
Related
Recommended

TI Hercules LaunchPad -  test the CAN with a poor man's CAN driver

Jan Cumps
Jan Cumps
13 Dec 2014

I've been working on a breadboarded BoosterPack to test the CAN modules on the TI Hercules LaunchPad, without transceivers or real CAN bus.

This is inspired by the following Siemens application note AP2921 On-Board Communication via CAN without Transceiver.
The example allows you to run and probe the canIntCommunication example from HALCoGen by using 1 resistor, 2 diodes, some wire and a breadboard.

For learning use only. This design is not intended for use outside your lab. See this design for a fully functional CAN bus.

 

EXPERIENCE ZONE:

  • Automotive: My design facilitates investigating the automotive CAN protocol.

PROJECT FEATURES:

  • Learn CAN with your LaunchPad and a few passive components
  • the CAN1 and CAN2 module on your LaunchPad can talk to each other - just like with the bigger development boards
  • You can probe the signals with oscilloscope and logic analyzer
  • Low entry point to experiment with CAN

 

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

 

The poor man's can bus

 

A proper CAN implementation uses tranceivers and twisted pair wiring. And in an automotive setting I would not use anything different.

But for experimenting purposes, there's a simpler solution. You can replace a driver by a single diode on the transmit line:

 

The launchpad has 2 CAN modules, but no driver. In a test setting, that driver is not really needed.

Send and Receive of all CAN devices use the same single wire. The only thing we have to take care of is that the send lines don't conflict.

A simple isolation diode does the job. It takes care that a transmit line can drive the line without having to fight with the line's level.

If there's a conflict between senders, the diode takes care that it doesn't result in overload of the CAN peripheral.

Code

 

I use HALCoGen's canIntCommunication example.

The only change I've made is to place the canMessageNotification() function in notification.c in stead of in sys_main.c, because it belongs there.

 

sys_main.c:

// ...
/* USER CODE BEGIN (1) */
#include "can.h"
#include "esm.h"
#include "sys_core.h"


#define D_COUNT  8


uint32 cnt=0, error =0, tx_done =0;
uint8 tx_data[D_COUNT][8] = {0};
uint8 rx_data[D_COUNT][8] = {0};
uint8 *tx_ptr = &tx_data[0][0];
uint8 *rx_ptr = &rx_data[0][0];
uint8 *dptr=0;


void dumpSomeData();
/* USER CODE END */







// ..// ....

 

void main(void)
{
/* USER CODE BEGIN (3) */


    /* enable irq interrupt in Cortex R4 */
    _enable_interrupt_();


    /** - writing a random data in RAM - to transmit */
    dumpSomeData();


    /** - configuring CAN1 MB1,Msg ID-1 to transmit and CAN2 MB1 to receive */
    canInit();


    /** - enabling error interrupts */
    canEnableErrorNotification(canREG1);
  canEnableErrorNotification(canREG2);


    /** - starting transmission */
     for(cnt=0;cnt<D_COUNT;cnt++)
    {
      canTransmit(canREG1, canMESSAGE_BOX1, tx_ptr); /* transmitting 8 different chunks 1 by 1 */
      while(tx_done == 0){};                 /* ... wait until transmit request is through        */
      tx_done=0;
      tx_ptr +=8;    /* next chunk ...*/
    }


    /** - check the received data with the one that was transmitted */
    tx_ptr = &tx_data[0][0];
    rx_ptr = &rx_data[0][0];


    for(cnt=0;cnt<63;cnt++)
     {
          if(*tx_ptr++ != *rx_ptr++)
          {
               error++; /* data error */
          }
     }


    while(1){}; /* wait forever after tx-rx complete. */


/* USER CODE END */
}


/* USER CODE BEGIN (4) */
/* writing some data to ram  */
void dumpSomeData()
{
     uint32 tmp = 0x11;


     cnt = (D_COUNT*8)-1;
     dptr = &tx_data[0][0];
     *dptr = tmp;


     while(cnt--)
     {
        tmp = *dptr++;
        *dptr = tmp + 0x11;
     }
}




/* can interrupt notification */
/* Note-You need to remove canMessageNotification from notification.c to avoid redefinition */


// jc: moved to notification.c




/* USER CODE END */

 

 

notification.c:

/* USER CODE BEGIN (0) */
extern uint32 tx_done;
extern uint8 *rx_ptr;


/* USER CODE END */

...

#pragma WEAK(canMessageNotification)
void canMessageNotification(canBASE_t *node, uint32 messageBox)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (15) */
    /* node 1 - transfer request */
    if(node==canREG1)
    {
      tx_done=1; /* confirm transfer request */
    }


    /* node 2 - receive complete */
    if(node==canREG2)
    {
     while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1));
     canGetData(canREG2, canMESSAGE_BOX1, rx_ptr); /* copy to RAM */
     rx_ptr +=8;
    }


   /* Note: since only message box 1 is used on both nodes we dont check it here.*/
/* USER CODE END */
}

 

Result

 

Here's a sample taken with my protocol analyzer (a Papilio Pro loaded with the LogicSniffer design, with OpenLogic Sniffer as client):

 

Nothing spectacular here. But it's now possible to start digging into the CAN protocol with the Hercules LaunchPad without additional investment. A few scrap parts will do.

Anonymous

Top Comments

  • jw0752
    jw0752 over 7 years ago +1

    Thanks for your post. I had never even heard of the CAN buss before this. Learn something new everyday.

    John

  • michaelkellett
    michaelkellett over 3 years ago in reply to DAB +1

    CAN bus had several advantages over other things that were available at the time of its introduction and some of these persist. At the time the main competitor in automotive were various forms of UART…

  • Jan Cumps
    Jan Cumps over 3 years ago in reply to michaelkellett +1

    michaelkellett  wrote:

     

    ...

    I've just noticed that DAB wrote his comment 4 years ago -

     

    MK

    He's a visionary  . Also shows that I never give up on a design, even though many kickstarters and new disrupting…

  • jw0752
    jw0752 over 7 years ago

    Thanks for your post. I had never even heard of the CAN buss before this. Learn something new everyday.

    John

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • DAB
    DAB over 7 years ago

    Interesting post.

     

    I have no experience with the CAN bus.

    I always wondered why the auto industry created their own bus when they could just as easily borrowed one of the many avionics bus standards.

    It is not like they had any unique environmental requirements.

     

    Anyway, I will be looking forward to seeing what you find out.

     

    DAB

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
<
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube