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.

How to use IF1 of DCAN3 to send data

Other Parts Discussed in Thread: HALCOGEN

I want to send data from DCAN3 with DMA

The following is my code ,but it have not interrupt at DMA. I use DMA chanel 4 , mailbox 1.

How to start sending data with DMA?

Is it  "canREG3->IF1NO = (uint8) canMESSAGE_BOX1;"?

void dmaGroupANotification(dmaInterrupt_t inttype, sint32 channel)
{
switch(channel)
{
case DMA_CH4:
DMA_Comp_Flag = 0x5555AAAA;
break;
}
DMA_Comp_Flag = 0x5555AAAA;
}

_enable_interrupt_();

canInit();

canREG3->CTL |= (1U << 18U);   /***enable IF1 for translate***/

dmaEnable();

dmaEnableInterrupt(DMA_CH4, FTC);   /*tx*/

dmaReqAssign(DMA_CH4,17);  /*tx,DCAN3IF1*/

dmaConfigCtrlTxPacket((uint32)(&(TX_DATA1)),
(uint32)(&canREG3->IF1DATx[0]),
1);
dmaSetCtrlPacket(DMA_CH4,g_dmaCTRLPKT);
dmaSetChEnable(DMA_CH4, DMA_HW);

canREG3->IF1STAT |= 0x40; /**DMA active*/
canREG3->IF1NO = (uint8) canMESSAGE_BOX1; /*send can*/

void dmaConfigCtrlTxPacket(uint32 sadd,uint32 dadd,uint32 dsize)
{
g_dmaCTRLPKT.SADD = sadd; /* source address */
g_dmaCTRLPKT.DADD = dadd; /* destination address */
g_dmaCTRLPKT.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT.FRCNT = 1; /* frame count */
g_dmaCTRLPKT.ELCNT = dsize; /* element count */
g_dmaCTRLPKT.ELDOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT.ELSOFFSET = 0; /* element source offset */
g_dmaCTRLPKT.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT.FRSOFFSET = 0; /* frame source offset */
g_dmaCTRLPKT.PORTASGN = 4; /* port b */
g_dmaCTRLPKT.RDSIZE = ACCESS_64_BIT; /* read size */
g_dmaCTRLPKT.WRSIZE = ACCESS_64_BIT; /* write size */
g_dmaCTRLPKT.TTYPE = FRAME_TRANSFER ; /* transfer type */
g_dmaCTRLPKT.ADDMODERD = ADDR_FIXED; /* address mode read */
g_dmaCTRLPKT.ADDMODEWR = ADDR_FIXED; /* address mode write */
g_dmaCTRLPKT.AUTOINIT = AUTOINIT_ON; /* autoinit */
}

  • Hi yunfeng

    Hope this thread helps. http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/287665/1013345.aspx#1013345

    Look for the attachment 8030.CAN+DMA_new.zip

    You can use the HALCogen project in it and configure for DCAN3 and Enable IF3 DCAN3 Interrupt (Channel 60 in Vim channel 32 - 63 tab). Also change all the canREG1 reference to canREG3

  • These thread is not relevant with DMA translmit

    I want to transmit data with DMA.

    Is there some examples for DMA transmit?

  • Hi Yunfeng,

    I have not worked on TX DMA for CAN, I am travelling may not be able to help you for couple of days.

    My suggestion, ( Have not tried before).
    If you intention is only TX, then I think it can be configured like a regular DMA transfer where in DMA can be configured as Software trigger. Configure two DMA channels, 1 puts the 8-Bytes data in to IF1data register , 2 updates the ID and Mailbox number. Trigger 2nd channel after first channel, so that end of second transfer the content from IF1 is copied to Mailbox and transmitted.

  • Hi Prathap,

    I've been working on a TX DMA example with another customer.    Similar conclusion to your suggestion, in that the 2nd DMA is needed to write to the 1st word (Channel ID) which has to be done *after* all the other words are written to the IF1 registers.

    However, a couple additional observations:

       1) it seems possible to trigger both DMA from one DMA request.  the DMA will take them in priority order, so if the 2nd DMA is a higher channel # (lower priority) then from the same trigger it will be executed after the 1st DMA.

       2) to transfer multiple messages through IF1 (i.e. to use the DCAN to trigger) it's tricky because the DMA request comes when the IF1 register set is free, not from when the mailbox has transferred.   So if you just point a string of DMA's at the same mailbox chances are they'll overwrite each other before appearing on the CAN bus.

    Don't have a working example yet unfortunately but getting close.