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.

TMS320F28379D: CAN protocol sending messages without cadence with the code using delay

Part Number: TMS320F28379D

Tool/software:

Hello everyone,

I have a f28379d control card, I'm compiling it with CCS, I started with an example from empty_driverlib_project, I put together a code basically to send CAN messages, but the board behaves abnormally, I've tried to configure it in other ways but without success, the code below is in my empty_driverlib_main:
#include "device.h"
#include "driverlib.h"
#include "board.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define TX_MSG_OBJ_ID 1
#define MSG_DATA_LENGTH 8

uint16_t txMsgData[8] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
uint16_t counter = 0;

void main(void) { Device_init();

Device_initGPIO();

Board_init();

GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);

// // Enable Global Interrupt (INTM) and real time interrupt (DBGM) // EINT;
//ERTM;


while(1) { counter++;
txMsgData[0] = counter;
CAN_sendMessage(myCAN0_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH, txMsgData);
while(((HWREGH(myCAN0_BASE + CAN_O_ES) & CAN_ES_TXOK)) == CAN_ES_TXOK) { } GPIO_togglePin(DEVICE_GPIO_PIN_LED1);
GPIO_togglePin(DEVICE_GPIO_PIN_LED2);
DEVICE_DELAY_US(500000);
} } // // End of File //

I set the board's LEDs to change state, and they work, but the CAN data writing function sends data frantically.

Could someone help me?

  • Hi Anderson,

    It would be best to start with the CAN examples instead of an empty driverlib project to ensure that that system clock set up as well as bit timings are properly set up.  I do not see the functions that set the clocks and timings in your main code above.  The example codes (transmit, receive, loopback...etc) have been checked out on control cards.

    Regards,

    Joseph 

  • I have already tested the basic examples like can_ex4_simple_transmit and can_ex5_simple_receive, but none of them had a different behavior, in my case I need to use the CANB register but instead of pins 17 and 12 I need to use pins 17 and 16, below is a picture showing the behavior of the control card:


    Is there a pin conflict and do I need to disable something to be able to use the CANB register?

  • Hi Anderson,

    CANA and CANB modules are independent of each other.  They have their own set of CAN register so there should not be a problem using both CAN modules, however there are only GPIOs that can connect to CANA and only a set of GPIOs that connect to CANB.  Make sure to check Section 5.4.1 GPIO Muxed Pins to ensure that the pins you are intending to use for CAN TX/RX are multiplexed to that GPIO pin and CAN module.

    Regards,

    Joseph

  • Hi everyone,
    I fix the problem, basically I had to put a pull-up resistor on the component's TXD, in addition to inverting the TXD and RXD which in the block diagram is different from the symbol, after that I tested the signals on the oscilloscope and now everything works.