This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F28379D: Newbie CAN Communication Question

Part Number: LAUNCHXL-F28379D

Hello,

I'm a newbie trying to learn CAN communication using the LAUNCHXL-F28379D evaluation board.  I purchased a  PCAN-USB adapter from PEAK System.  It looks like PEAK System's corresponding software has the capability to both receive and send messages. For my application, I want to be able to both send information from the computer to the MCU and receive information on the computer from the MCU.

My question is can I use the F28379D Launchpad to both transmit data to the computer and to receive data from the computer since the Launchpad has a CAN transceiver only for CAN-B.?   In other words, can I use CAN-B for both transmitting and receiving in the same program?  Can I use CANTXB for both transmitting data from the Launchpad to the computer and CANRXB for receiving data from the computer (without needing CANA)?  

Thanks,

Kevin

  • Hi Kevin,

    Yes, you certainly can use CAN module B in the Launchpad to interface and communicate with any node in the CAN bus.  It will work with PCAN-USB as well.  You have probably checked this already but in your CAN channel setup for the launchpad, make sure to map GPIO12 as CANTX and GPIO17 as CANRX as this is how the launchpad is connected to the on-board transceiver.

    Regards,

    Joseph 

  • Joseph,

    Thanks for your helpful reply.  Yes, I see on the drawings that the CAN transceiver using GPIO12 and GPIO17.  I modified the code for "can_ex1_loopback.c" to use those GPIOs and I am reading the correct values on CANH and CANL using digital probes.

    Once I the PCAN-USB cable I ordered arrives, I need to send data both ways (from the local computer to the Launchpad and from the Launchpad to the local computer).

    Do I need to worry about the timing so that both sides are not both trying to transmit at the same time?  From what I understand, if both sides are trying to transmit at the same time, the identifier with the lower binary value will send.  After the message with the lower identifier gets sent, will the message with the higher identifier automatically send (or do I need to develop code to keep trying to resend it until it is not blocked)?

    Thanks,

    Kevin

  • Hi Kevin,

    Good that you have confirmed that you get the correct signals on the CAN bus pins CANL/CANH.  I think PCAN interface is a DB9 receptacle and launchpad may just have headers to CANL and CANH so you might have to be creative with wiring the CANL and CANH lines on the launchpad and PCAN.

    In order to establish communication, first make sure to set the PCAN baudrate to the same rate as what you have configured in your modified test case (if test case uses 500kbps, set PCAN to 500kbps as well).  You first might want to start with the ex5_simple_receive (launchpad will receive message while PCAN is transmitting) and ex4_simple_transmit (launchpad transmitting wile PCAN is receiving) test cases just to ensure that communication is established.  The  test case that you have currently chosen - ex1_loopback is a diagnostic example - you will see data being transmitted by the CAN in the CANTX pin but anything getting into the CANRX pin will not go into the CAN internal buffer.  This is a debug feature (loopback feature of the CAN) if you want to see how the CAN frame appears on a CAN analyzer (PCAN) and if you are interested to see what is happening with the receive mailbox and other registers.

    In CAN communication, you really do not have to worry about timing of when messages are transmitted.  CAN protocol takes care of this for the user through arbitration (lower messageIDs/nodeIDs get transmitted first) and if a receiver acknowledges receipt of a message, then node with the next lower ID gets to transmit - no need to write a code for this.  That is one good feature of CAN communication.

    Regards,

    Joseph