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.

Network CAN with TMS320F28335

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hi! 

I have to do a network CAN with TMS320F28335, first of all i programming the module CAN on code composer studio, for use CANA. Then i used another DSP and programming the same code on the other. This i did for have two nodes on the network.

Then i check the schematics on this page http://c2000.spectrumdigital.com/ezf28335/docs/ezdspf28335_schem.pdf, but my question if it is necessary put the resistor  before the JP7?

if i connected each DSP to transceiver and this is connected to a pair of lines (wire belden 9841) it is posiible to send and receive the messages.

Please help me 

Thank you

These is my routine  

#include "DSP2833x_device.h"
// external function prototypes
extern void InitSysCtrl(void);
extern void InitPieCtrl(void);
extern void InitPieVectTable(void);
extern void InitCpuTimers(void);
extern void InitECan(void);	
extern void ConfigCpuTimer(struct CPUTIMER_VARS *, float, float);

void Gpio_select(void);
interrupt void cpu_timer0_isr(void);


void main (void) 
{

int counter=0;
struct ECAN_REGS ECanbShadow; //used as a local copy of the original CAN registers
InitSysCtrl(); // Initialize the CPU

EALLOW; // Enable EALLOW protected register access, is possible to write freely in this protected registers
SysCtrlRegs.WDKEY = 0x55;
SysCtrlRegs.WDKEY = 0xAA;
EDIS;


Gpio_select(); // function GPIO30 as TX and GPIO31 as RX

InitECan(); // initialization CAN module


 
//preparation the transmit mailbox 
ECanbMboxes.MBOX5.MSGID.all     = 0x10000000; //identifier
ECanbMboxes.MBOX5.MSGID.bit.IDE = 1;  //extended identifier

// configure mailbox 5

ECanbShadow.CANMD.all = ECanbRegs.CANMD.all;
ECanbShadow.CANMD.bit.MD5 = 0;
ECanbRegs.CANMD.all = ECanbShadow.CANMD.all;

// enable mailbox #5

ECanbShadow.CANME.all = ECanbRegs.CANME.all;
ECanbShadow.CANME.bit.ME5 = 1;
ECanbRegs.CANME.all = ECanbShadow.CANME.all;

// Data Length Code Field (DLC) in Message Control Register

ECanbMboxes.MBOX5.MSGCTRL.all = 0; //clear all reiaming bits of this register
ECanbMboxes.MBOX5.MSGCTRL.bit.DLC = 1;

ECanbMboxes.MBOX5.MSGID.all     = 0x10000000;	// message identifier 
ECanbMboxes.MBOX5.MSGID.bit.IDE = 1;  // Extended Identifier

InitPieCtrl();		// basic setup of PIE table; from DSP2833x_PieCtrl.c
	
InitPieVectTable();	// default ISR's in PIE

	EALLOW;
	PieVectTable.TINT0 = &cpu_timer0_isr;
	EDIS;

	InitCpuTimers();	// basic setup CPU Timer0, 1 and 2

	ConfigCpuTimer(&CpuTimer0,150,100000);

	PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

	IER |=1;

	EINT;
	ERTM;

	CpuTimer0Regs.TCR.bit.TSS = 0;	// start timer0




ECanbMboxes.MBOX5.MDL.byte.BYTE0=counter; 
ECanbShadow.CANTRS.all=0;
ECanbShadow.CANTRS.bit.TRS5=1; // set the TRS(n) bit to 1 to start the transmission
ECanbShadow.CANTRS.all=ECanbShadow.CANTRS.all;

while(1)
	{    
	  		while(CpuTimer0.InterruptCount < 10)	// wait for 10*100 milliseconds
			{
				EALLOW;
				SysCtrlRegs.WDKEY = 0xAA;	// service WD #2
				EDIS;
			}
			CpuTimer0.InterruptCount = 0;

			ECanbMboxes.MBOX5.MDL.byte.BYTE0 = counter & 0x00FF ;
     		ECanbShadow.CANTRS.all = 0; 	
     		ECanbShadow.CANTRS.bit.TRS5 = 1;     // Set TRS for mailbox under test       
     		ECanbRegs.CANTRS.all = ECanbShadow.CANTRS.all; 

			while(ECanbRegs.CANTA.bit.TA5 == 0 ) // Wait for TA5 bit to be set.
     		{
				EALLOW;
				SysCtrlRegs.WDKEY = 0xAA;				// Service watchdog #2
				EDIS;
     		} 
			   
	     	ECanbShadow.CANTA.all = 0; 	
	     	ECanbShadow.CANTA.bit.TA5 = 1;     	 // Clear Transmit Acknowledge #5       
	     	ECanbRegs.CANTA.all = ECanbShadow.CANTA.all;
			
			counter++;
			GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;		// toggle red LED LD3 @ 28335CC

     }
  

}

void Gpio_select(void)
{
   
    EALLOW;
	GpioCtrlRegs.GPAMUX1.all = 0;		// GPIO15 ... GPIO0 = General Puropse I/O
	GpioCtrlRegs.GPAMUX2.all = 0;		// GPIO31 ... GPIO16 = General Purpose I/O
	
	GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1;	// Enable pull-up for GPIO30  (CANRXA)
	GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1;	// Enable pull-up for GPIO31  (CANTXA) 

	GpioCtrlRegs.GPBMUX1.all = 0;		// GPIO47 ... GPIO32 = General Purpose I/O
	GpioCtrlRegs.GPBMUX2.all = 0;		// GPIO63 ... GPIO48 = General Purpose I/O
	GpioCtrlRegs.GPCMUX1.all = 0;		// GPIO79 ... GPIO64 = General Purpose I/O
	GpioCtrlRegs.GPCMUX2.all = 0;		// GPIO87 ... GPIO80 = General Purpose I/O
	 
	GpioCtrlRegs.GPADIR.all = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO9 = 1;	// peripheral explorer: LED LD1 at GPIO9
	GpioCtrlRegs.GPADIR.bit.GPIO11 = 1;	// peripheral explorer: LED LD2 at GPIO11

	GpioCtrlRegs.GPBDIR.all = 0;		// GPIO63-32 as inputs
	GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;	// peripheral explorer: LED LD3 at GPIO34
	GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49
	GpioCtrlRegs.GPCDIR.all = 0;		// GPIO87-64 as inputs
	
	EDIS;
}

interrupt void cpu_timer0_isr(void)
{
	CpuTimer0.InterruptCount++;
	EALLOW;
	SysCtrlRegs.WDKEY = 0x55;	// service WD #1
	EDIS;
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

  

  • William,

    Firstly, the 120ohm resistor (R23 or R24) are termination resistors for the CAN bus.  There should only be two resistors connected in the CAN bus, one at each end.

    With a quick look at your software, I see that you seem to be configuring CANB, although in your post you say that you are trying to use CANA.  Perhaps this is part of the problem?

    If you haven't already, I would use the CAN back2back example (or the ecan_a_to_b_xmit example for some MCUs) within controlSUITE as a place to start.


    Thank you,
    Brett

  • Hi!

    Thank you for your response, i was trying to work with routine Example_28xEcan_A_to_B_Xmit.c, but i have a doubt, i don't know if my connections are ok.

    First of all i have 2 DSP, one of this i connected to a pc and load the program the connector DB9 (CANA) is connected to a transceiver pins 2 and 7, two pins of the transceiver it is connected to a network CAN this is a wire belden 9841. For the other DSP i made the same. 

    I'm using CAN to USB interface of grid connect that works with hyperterminal to see the frames but there isn't happen. Idon't know what is making wrong, please help me with the problem.

    i'll put here photos of the watch window on the code composer and one photo of the connections phsically.

    i really apreciate you help 

    Thank you

  • William,

    I would recommend first getting the hardware to work with known good software and then slowly building to your full solution.  The ecan_a_to_b_xmit project is designed try out two eCAN peripherals on one board.  This is what I would start with.

    Run the example as-is and look at the signals on P11.  Next, connect a wire between the appropriate pins of P11 and J11 and see if you can read the mailbox's message in CANB.  Get comfortable with the hardware and software.  Then you can try loading the code on both devices, modifying the connections some more and have board1.CANA talk with board2.CANB and prove out this functionality. Then you can port the software to use board2.CANA if desired or modify the software to make it into your format.  And so on until you meet your requirements...


    Thank you,
    Brett

  • Hello!!

    I was following your instructions and i connected the board together like you said. i tested example Example_28xEcan_A_to_B_Xmit.c and looking i saw watch eCAN registers and i saw that eCANB CANLNT was working because each time change the register like that, may be this said me that the biard is receiving the message, it is ok?

    This said me that the communications between two boards are ok, nevertheless, i connected the transceivers on the same connector DB9 (P11) and J11 and the CAN-RS232 adapter but again doesn`t work. i don't know if the transceivers i have to connected like that. i was looking these file http://c2000.spectrumdigital.com/ezf28335/docs/ezdspf28335_schem.pdf  on page A-8 and the transceivers are connected on P11 and J11 but on the same place it is connected both board, cpould you tell where i have to connect the transceivers?

    Thank you