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.

adding controller area network to the DRV8312-C2_KIT

I am trying to develop a product based on the DRV8312-C2-KIT which receives speed control commands via the CAN bus.

I am using the PM_Sensorless project, unchanged apart from the CAN code additions,  in RAM.

I have added code from the various CAN examples, but am not seeing any activity (oscilloscope) on the isolated CAN outputs of the card when my code runs.

I can still control the motor from the watch window.

(Interestingly, if I close the IDE, remove the USB cable from the kit, power the kit down then up and reconnect the USB cable, I get 2-3 seconds of activity on the isolated CAN connections - is that a red-herring?)

Can anyone provide guidance to why I am not  getting CAN transmissions?

Thanks

steve robinson

Below are the changes I have made to the project.

PM_Sensorless-DevInit_F2803x.c

// GPIO-30 - PIN FUNCTION = CANRX
GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1; // 0=GPIO, 1=CANRX-A, 2=Resv, 3=Resv
GpioCtrlRegs.GPADIR.bit.GPIO30 = 0; // 1=OUTput, 0=INput
GpioDataRegs.GPACLEAR.bit.GPIO30 = 1; // uncomment if --> Set Low initially
// GpioDataRegs.GPASET.bit.GPIO30 = 1; // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
// GPIO-31 - PIN FUNCTION = LED2 on controlCARD (CANTX)
GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1; // 0=GPIO, 1=CANTX-A, 2=Resv, 3=Resv
GpioCtrlRegs.GPADIR.bit.GPIO31 = 1; // 1=OUTput, 0=INput
GpioDataRegs.GPACLEAR.bit.GPIO31 = 1; // uncomment if --> Set Low initially
// GpioDataRegs.GPASET.bit.GPIO31 = 1; // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------


SysCtrlRegs.PCLKCR0.bit.ECANAENCLK=1; // eCAN-A


PM_Sensorless.c

after..... DeviceInit(); // Device Life support & GPIO

//STEVES CAN STUFF - RIGHT PLACE????
InitECanaGpio(); //from the DSP2803x_Ecan.c example
InitECana(); //as from the DSP2803x_Ecan.c example BUT with the message id setup added from the Example_2803xECanBack2Back.c example
//send some can
ECanaRegs.CANTRS.all = 0x0000FFFF; // Set TRS for all transmit mailboxes
while(ECanaRegs.CANTA.all != 0x0000FFFF ) {} // Wait for all TAn bits to be set..
ECanaRegs.CANTA.all = 0x0000FFFF; // Clear all TAn

... and before the infinite while loop so that it would transmit only once

  • Steve,

    Have you tried running the ECanBack2Back example directly yet?  If not, I would recommend it. 
    (I would just make sure that the placement of eCAN GPIO outputs in the code matches the placement of where they are on the kit before running the software)

    I haven't used CAN much, but one extra thing to note is that the ECanBack2Back example runs in Self Test mode (STM = 1) and therefore won't work as-is when a CAN bus is attached.  Without digging into the details, I cannot remember if Self test mode allows data to go out of physical pin attached to CANTX or not.  So that should be another thing to look at.
    (at reset, STM mode will be 0 until it is configured to 1 in your code; so perhaps this may provide some rationale for what I think is a red herring)


    Thank you,
    Brett

  • Steve,

    what's at the other side of your CAN?   If there is no 2nd node to acknowledge the transmission, your 1st node will go into "bus-off" after a while. That is probably the 2-3 seconds interval of bus activities after a power on.