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.

CCS/TMS320F28379D: Issue of Interconnections between two F28379X control Cards for CAN protocol testing

Part Number: TMS320F28379D
Other Parts Discussed in Thread: SN65HVD257EVM, , C2000WARE

Tool/software: Code Composer Studio

Dear all,

                  I am facing a problem regarding the Interconnections between two F28379X control Cards for CAN protocol testing. I have connected the two MCU Boards through DB9 connector at CAN Interface point (i.e VH and VL pins). I have dumped the source code of "CAN Loop Back" in both MCUs. So can anyone tell me the procedure of checking the output for testing CAN communications.

       Thanks in advance.



Sumanta

  • Hi Sumanta,

              If you are trying to establish communication between 2 MCU boards through CAN bus through a DB9 connector, the CAN loop back code will not work.  CAN loop back is intended only as a debug test where you can monitor or scope out the transmitted data on the CAN_TX pin that is fed back internally to the RX port on a CAN module in one MCU board. 

              For the 2 MCU Boards to communicate, you need to connect each CAN from the MCU Board's CAN_TX and CAN_RX pins to a transceiver (e.g. SN65HVD234D).  The transceiver will translate the CAN_TX and CAN_RX signals into a differential signal through the CANH and CANL pins.  The CANH and CANL pins together with GND is what goes to the DB9 connector.  The CANH and CANL lines is what defines the CAN bus.  You then would want to have a CAN network with 2 nodes (where 1 node is 1 MCU board + a CAN transceiver)  that are linked through a CAN bus.  Once you have made the necessary connections, you can use the example codes from CAN external transmit.  You can configure one MCU board to transmit data and the other MCU board will be receiving.

              Hope this will get you started.  Let me know if you have additional questions.

    Regards,

    Joseph

  • Sumanta,
    You can't simply connect CAN_TX and CAN_RX and make the CAN communication. You need to use CAN transceivers to convert CAN_TX and CAN_RX (CAN signals at MCU side) to CAN_H and CAN_L in order to make a CAN bus. Since you need two CAN transceivers to communicate between two MCUs, I would use SN65HVD257EVM board which has two transceivers and is ready to use.

    Good luck!
  • Hi Joseph,

    I have connected individual Transceiver ICs (SN65HVD251D) to 2 DSP microcontroller (TMS320F28379D) based MCU Boards and created the CAN bus through Db9 connector. At present I have dumped the source code for CAN_EXTERNAL_TRANSMIT in 1 MCU and trying to view the increment of memory address in sTXRegister. Can anyone suggest how to check the output in sRXRegister using a single MCU as my 2nd MCU is malfunctioning at present.

    Regards

    Sumanta
  • Hi Sumanta,

    Ok, in that case if you only wanted to look at the transmit and receive data and how they increment, then it is best to use the CAN loopback code.  You really do not need to connect the MCU to a CAN transceiver then.

    When using CAN loopback code in C2000Ware, set a breakpoint inside the for(;;) loop, then in the Variables window or Expressions window in CCS, you can monitor/add sTXCANMessage and sRXCANMessage.  Everytime you hit the play button, the code would pause at the breakpoint then the values of sTXCANMessage and sRXCANMessage would be visible in either the Variables or Expressions window.

    Let me know if this does not work for you.

    Regards,

    Joseph

  • Actually in my MCU board the Transceiver IC is already connected. So can I mutually connect the VH and VL output terminals of the transceiver to view the output in sTXCANMessage and sRXCANMessage variables using the CAN loopback code. Also can you suggest regarding the configuration of the MCU Boards so that Master/Slave communication can be established.

    Regards

    Sumanta
  • Hi Sumanta,

    CAN is a multi-master communication network. Any node connected to the CAN bus can transmit at any time, the priority of which nodes transmit is decided upon the arbitration ID. If more than one node is transmitting, the node which has a lower ID gets to transmit its data first. Rest of the nodes can be in receive mode and can accept any data that is being transmitted in the CAN bus by any node. Depending whether message filtering is implemented or not, a receiving node can ignore or accept the transmitted messages. More information on the message filtering topic is available in Section 22.12 Message Handling in the Technical Reference Manual www.ti.com/.../spruhm8f

    Regards,
    Joseph
  • Hi Joseph,

    I have tried with the Source code for "CAN_External_Transmit" and "CAN_Loopback" with single and 2 MCU boards by creating the CAN bus through DB9 connector, but the outputs obtained are as below:

    1) At CAN RX terminal I am getting 3.3 volts whereas

    2) At CAN TX terminal I am getting 0 volts.

    I want to check whether on application of a pulsating input at CAN terminals, pulsating output is obtained at CAN BUS terminals. Is it possible with Blinking LED program.

    Please suggest for proper testing in CAN Communication in single and between 2 MCU boards.


    Regards
    Sumanta
  • Hi Sumanta,

    Best way to monitor the CAN transmission is through the CAN_RX line on the MCU.  You should connect a scope and monitor the CAN activity (both transmit and receive).  A voltmeter or LED will not work as the signal transitions will be too fast to be able to visually monitor.

    Regards,

    Joseph

  • Hi Joseph,

    In the CAN_loopback source code, at RX and TX terminals of the DB9 connectors in CAN bus I am getting 3.3 volts and 1.5 volts respectively. So please suggest how to check the pulsating output on application of pulsating (square wave) input at CAN transceiver input terminals.

    Thanks in advance.


    Regards
    Sumanta
  • Sumanta,

    You can test your CAN bus with multi-meter since the frequency is too high to be detectable. You need to use oscilloscope to see the signals. Here is what you're supposed to catch on MCU side (CAN_TX and CAN_RX):

    While if you monitor CAN_H and CAN_L on CAN bus you're supposed to get a differential signals.

    Note: Don't forget to use 120 ohm termination resistor at each end of the CAN bus.

    Regards,

  • Kash,

    Thanks for posting the oscilloscope capture on the physical CAN_RX and TX pins.

    Sumanta,

    When you execute the CAN loopback code, does it run continuously or does it stop in the ESTOP0 instruction? If the test failed and stopped, the transmission will cease and you cannot observe anything in the physical pins. The loopback example runs at 500Kbps, so setting your scope's horizontal resolution to ~100uS/div should allow you to capture some messages being transmitted.

    Regards,
    Joseph
  • Hi Joseph,

                      I have done the programming for CAN_Loopback test where i checked the following waveforms:

    1) At RX and TX terminal with respect to GND, where zero voltage is obtained.

    2) CAN Bus voltage with respect to GND, where VH= 4.8 volts and VL= 1.25 volts which are all DC voltages.

    I given Input data as [ucTXMsgData[4]= {'a','b','c','d'} and ucRXMsgData[4]= {'0','0','0','0'} in the source code. So please suggest the necessary modifications in source code or in Test setup, so that the waveforms posted by [@Kash] can be obtained.

    Thanks in advance.

    Regards

    Sumanta

  • Hi Sumanta,

            From your description, it seems like you are limiting the transmission of 4 values which are ucTCMsgData[0] = 'a' ascii or 0x61 in HEX, ucTCMsgData[1] = 'b' or 0x62, ucTCMsgData[2] = 'c' or 0x63 and ucTCMsgData[3] = 'd' or 0x64.  Not sure where in the loop you are setting the value of ucRXMsgData to {'0','0','0','0'} [by the way '0' here means 0x30 in HEX] but if you are setting ucRXMsgData[4]= {'0','0','0','0'} AFTER the call to CANMessageGet, then the loop will stop since ucTXMsgData will never be equal to ucRXMsgData based from the initializations you did:  [ucTXMsgData[4]= {'a','b','c','d'} and ucRXMsgData[4]= {'0','0','0','0'}.  This is probably what is happening in your case.  Transmission probably stopped because transmitted data is not equal to received data.

          What I suggest is run the CAN loopback code as it is, with no modifications whatsoever.  The test will loop indefinitely with ucTXMsgData[0] seeded first with value of 0x01, ascii SOH and ucTXMsgData[1] with value of 0x02, ascii STX, then these are incremented by 1 every time CAN finishes transmit/receive transaction and once the transmit data reaches 0xFF (which is maximum value for ascii), value is seeded back to 0.  Can loopback test, if ran correctly will be transmitting / receiving all possible ascii codes from 0 to 255 and repeated indefinitely until program is stopped.  This would encompass all ascii characters, from symbols, numbers and upper and lower case letters in the alphabet.  This will be your best chance to monitor the signals in the CAN_TX and RX pins.

    Regards,

    Joseph

  • Hi Joseph,

                      I have tested my MCU with the CAN_Loopback source code but I am unable to get the waveforms at TX and RX terminals. I checked the continuity with the CAN terminals to the Isolator IC (ADUM7643). Not sure where the problem is actually happening. Pls suggest if anybody has faced the similar problem.

    Thanks in advance.

    Regards

    Sumanta

  • Hi,

          I have tested individual 2 MCUs with CAN_Loopback source codes in which I observed the differential signals at the CAN bus through SCOPE. Presently I am modifying the CAN_External Transmit source code for 1 MCU to act as a Transmitter and another as a Receiver. The Transmitter MCU is able to transmit the message (in the form of pulsating signal), but the Receiver MCU is not able to receive the same (as observed at the CAN bus output). Please suggest how to modify the source code so that the MCU should be able to receive the signal.

          Thanks in advance.

    Regards

    Sumanta

  • Hi Sumanta,

    Good to know that you are now able to see activities on the CAN bus.  I would like to understand more about your setup first, specifically how you interfaced the 2 MCUs.  Did you use the same CAN transceiver that was in the Launchpad for both MCUs?  If so, note that the CAN_RX and CAN_TX pins are tied to specific GPIO pins and the CAN external transmit code example uses a different set of GPIO channels for CAN_RX and CAN_TX.  Please ensure that you have matched the GPIO channel assignments accordingly to match the CAN pin functionality.  If you used a different transceiver, please note that the F28379X CAN pins are 3.3V type I/Os hence you also need to use a transceiver with 3.3V I/O.  Using a different I/O type for the transceiver is usually a common mistake that mislead to not establishing CAN communication.

    As for your code, if you have used the CAN external transmit example, you can follow these steps for the transmitter (suggest to just use CANA module for both RX and TX):

         Set the CAN_TX/RX pins accordingly

         Initialize CAN - CANInit();

         Select Clock Source - CANClkSourceSelect();

         Set Bit Rate - CANBit RateSet(); // TX and RX should match

         Initialize the transmit message (as in the external transmit example for sTXCANMessage structure - here you need to define the message length)

         Enable CAN - CANEnable();

         Set the data you want to transmit by modifying txMsgData array depending on the length of data you want to transmit

         Send the data to the CAN pins - CANMessageSet();

    You can transmit multiple frames by looping through the last two lines in the above pseudo code, but you need to add some delay after the CANMessageSet call to ensure the data will be transmitted - use the same delay function as in the example code.

    For the receiver MCU,  you want your code to look like this:

     

         Set the CAN_TX/RX pins accordingly

         Initialize CAN - CANInit();

         Select Clock Source - CANClkSourceSelect();

         Set Bit Rate - CANBit RateSet(); // TX and RX should match

         Initialize the receive message structure sRXCANMessage (follow the same as in the example)

          Enable CAN - CANEnable();

          Receive data from CAN bus - CANMessageGet();

          Received message would be available in rxMsgData array, and you and also scope the differential signal on the CANL and CANH lines or monitor them on the physical pins CAN_RX and GND or CAN_TX and GND.

    Hope this will work for you.

    Regards,

    Joseph

        

  • Hi Joseph,

                      Thanks for your response. I have connected the 2 MCUs and build the code in Transmitter and Receiver MCUs with the changes you have mentioned in your previous post. I have assigned data to ucTXMsg and ucRXMSG variables as below:

    "unsigned char ucTXMsgData[4]= {'a','b','c','d'}, ucRXMsgData[4]={'0','0','0','0'};"

    Waveforms are observed at CAN bus (pulsating square wave) and data in CCS window. But the same waveforms in not visible when programming the receiver MCU RX terminal and also no data in RX register in CCS window. Pls suggest.

                  Thanks in advance.

    Regards

    Sumanta

  • Hi Joseph,

                        I have checked the CAN loopback source code by debugging it as a Transmitter in 1st MCU and Receiver in 2nd MCU. I am able to observe data

    pulse in Scope at the CAN Receiver terminal of the Receiver MCU. But as I mentioned in my mentioned post if the Transmitting data is defined as:

    [ucTXMsgData[4]= {'a','b','c','d'}, ucRXMsgData[4]={'0','0','0','0'}], then I am getting ucRXMsgData[4]={'h','0','c','d'} instead of {'a','b','c','d'} in Code Composer

    Window.

    Please suggest if anyone has faced similar problem.

            Thanks in advance.

    Regards

    Sumanta

     

         

  • Hi Sumanta,

    When you debugged the CAN test you described above:

      1.) Did you monitor the CAN_ES (error and status register)?  Were any errors flagged?

      2.) What is the part number of the transceiver that you used to interface the CAN_TX/RX pins to the CAN bus?  Just wanted to make sure that the transceiver levels are compatible with the 28379D levels.

      3.)  What is the clock source used on both MCUs - on board crystal, oscillator or are you supplying the clocks separately from an external source?

    From your description, looks like there are dropped bits / shifted data when data is received that might hint to timing issues.  That is the reason for the above questions.

    Thanks,

    Joseph

  • Hi Joseph,

                      For your information:

    1) Presently I am operating the CAN_Loopback source code which do not contain the CAN_ES variable to display the error Flag signal which you have pointed out.    

        But the same variable is getting assigned in CAN_External transmit source code which I have not currently debugged.

    2) Transceiver [SN65HVD251D] is getting used with 28379D controller.

    3) No External clock is getting used except the Internal clock of the Controller.

     

    Please suggest why the same data assigned in Transmitter variable is not getting transmitted in Receiver Variable.

                Thanks in advance.

     

    Regards

    Sumanta

     

     

  • Hi Sumanta,

    Thank you for your response.  Your answer in item #2 is the reason why you are not seeing the full data in the receiver side.  The transceiver you are using is a 5V I/O level device (SN65HVD251D).  The 28377D I/O is operating at the 3.3V level so they are incompatible.  I suggest you use 3.3V transceivers (SN65HV23xx series).

    Hope this will finally resolve you issues.

    Regards,

    Joseph

  • Hi Joseph,

                      I have missed to inform you about an Isolator IC (I/P - 3.3V and O/P - 5V), which has been placed in between Controller (28379D) and the Transceiver IC, so both the TX and RX terminals of controller are held at 3.3V whereas the CAN bus O/P is at 5V. Hope it will clear your confusion regarding the incompatibility of using the (SN65HVD251D) transceiver with (28379D). Please suggest if any other changes in Hardware circuit or modifications in source code is required to solve the problem.

            Thanks in advance.

    Regards

    Sumanta

  • Hi Joseph,

    As I have mentioned in my previous post, The voltage levels for the Controller and the Transceiver are proper as per the requirement. I checked even with 8 bytes of data as:

    [unsigned char ucTXMsgData[4]={'a','b','c','d','e','f','g','h'}, ucRXMsgData[4]={'0','0','0','0','0','0','0','0'}; ] in the Transmitter MCU, then I receive 8 bytes of data in Receiver MCU as:

    [unsigned char ucTXMsgData[8]= {'0','0','0','0','0','0','0','0'}, ucRXMsgData[8]= ['.','.','c','d','e','f','g','h'};]. Please suggest if anybody has faced similar problem.


    Regards
    Sumanta
  • Hi All,

              Can anyone please suggest regarding the query of my previous post. I will be highly obliged.

              Thanks in advance.

    Regards

    Sumanta

  • Sumanta,

                First and foremost, please post the schematic diagram of the circuit you are using. You don’t have to post the whole circuit, just the CAN portion is enough. I would like to see the circuit starting from the CANTX & CANRX pins of the transmitting node, through the isolator IC, transceivers and finally the CANTX & CANRX pins of the receiving node. Clearly indicate the termination resistors. Please post a photograph or two of your setup as well.

     

    CAN communication is "binary". Either it works or it does not. If there is any corruption (or shifted bits), error frames would be triggered and the frame discarded. Data transmission will be attempted again.

     

    There have been way too many posts on this thread. Let us use this strategy to solve your problem:

     

    1. Ensure there are no hardware issues.
    2. Ensure you are able to run the c2000ware examples "as is" or with the least modification possible.
    3. Check why your modified code does not work.

     

     

     

  • Hi Hareesh,

                         You can find the approximate CAN circuit above. The problem is with the display of Ist two data byte content as send through Transmitter (TX) port as I have defined it in a detailed way in my previous post. Please have your suggestions.

                         Thanks in advance.

    Regards

    Sumanta

  • Sumanta,
    I presume you are using your own hardware and not a "standard" platform like the LaunchPad. Is this correct?

    Transmit just eight bytes one time (i.e. do not transmit an incrementing pattern in a loop)

    Please use a CAN bus analyzer and capture the data that gets transmitted on the bus. Let me know what you see.

    Also capture the waveform at the CANTX/CANRX pins of both the transmitter and receiver and send it across.

    If there are no hardware issues, this should be fairly straightforward to debug
  • Hi Hareesh,

                        I am using my customized MCU card with F28379 controller. Right now I am sending 4 bytes of data of which 3 bytes are getting transmitted appropriately. Please find the waveforms for TX pin of controller. [Pk magnitude- 3.3 volts]. I have checked the continuity between Controller and CAN bus which is proper. Pls suggest.

  • Sumanta,

                The image you attached doesn’t convey much. If 3 out of 4 bytes are received correctly, you can pretty much rule out any hardware issue and focus on your code. You need to ascertain exactly what got transmitted from the transmitter. You either need an oscilloscope with CAN bus triggering/decoding or a USB-based CAN bus analyzer. Without that information, it is hard to move forward on the debug.

     

  • Hi Hareesh,

                        Right now we dont have any Oscilloscope with CAN bus triggering/decoding or a USB-based CAN bus analyzer but we have begin its purchasing. So can you suggest how to test the CAN BUS output to ensure the content of the transmitted message or is there any possibility to modify the source codes accordingly.

            Thanks in advance.

    Regards

    Sumanta

  • Hi all,

              I have checked debugging the source code for CAN_loopback in my MCU board and I have defined the Input data as below:

    1) unsigned char ucTXMsgData [4] = {'a','b','c','d'}, ucRXMsgData [4] = {'0','0','0','0'};

    The output obtained is as shown in the screenshot below. So the Ist byte output is changing repeatatively, while the rest 3 bytes output are coming same as the input.

              Please suggest if anyone has faced the similar problem.