Tool/software:
Hi,
I am working on an application where I need to communicate between 2 devices. I was currently testing message transfer using the SCI and the DMA.
I have different messages MSG1 of size 15, MSG2 of size 14 and MSG3 of size 13. I configured 3 DMA packet like so :
g_dmaCTRL g_dmaCTRLPKT1;
/*Configure control packet for Channel 0*/
g_dmaCTRLPKT1.SADD = (uint32_t)MSG1; /* source address*/
g_dmaCTRLPKT1.DADD = (uint32_t)((uint8*)&(sciREG->TD)+3); /* destination address */
g_dmaCTRLPKT1.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT1.FRCNT = 15; /* frame count */
g_dmaCTRLPKT1.ELCNT = 1; /* element count */
g_dmaCTRLPKT1.ELDOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT1.ELSOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT1.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT1.FRSOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT1.PORTASGN = 4;
g_dmaCTRLPKT1.RDSIZE = ACCESS_8_BIT; /* read size */
g_dmaCTRLPKT1.WRSIZE = ACCESS_8_BIT; /* write size */
g_dmaCTRLPKT1.TTYPE = FRAME_TRANSFER; /* transfer type */
g_dmaCTRLPKT1.ADDMODERD = ADDR_INC1; /* address mode read */
g_dmaCTRLPKT1.ADDMODEWR = ADDR_FIXED; /* address mode write */
g_dmaCTRLPKT1.AUTOINIT = AUTOINIT_OFF; /* autoinit */
dmaReqAssign(DMA_CH0, 31);
dmaSetCtrlPacket(DMA_CH0, g_dmaCTRLPKT1);
g_dmaCTRL g_dmaCTRLPKT2;
/*Configure control packet for Channel 1*/
g_dmaCTRLPKT2.SADD = (uint32_t)MSG2; /* source address*/
g_dmaCTRLPKT2.DADD = (uint32_t)((uint8*)&(sciREG->TD)+3); /* destination address */
g_dmaCTRLPKT2.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT2.FRCNT = 14; /* frame count */
g_dmaCTRLPKT2.ELCNT = 1; /* element count */
g_dmaCTRLPKT2.ELDOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT2.ELSOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT2.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT2.FRSOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT2.PORTASGN = 4;
g_dmaCTRLPKT2.RDSIZE = ACCESS_8_BIT; /* read size */
g_dmaCTRLPKT2.WRSIZE = ACCESS_8_BIT; /* write size */
g_dmaCTRLPKT2.TTYPE = FRAME_TRANSFER; /* transfer type */
g_dmaCTRLPKT2.ADDMODERD = ADDR_INC1; /* address mode read */
g_dmaCTRLPKT2.ADDMODEWR = ADDR_FIXED; /* address mode write */
g_dmaCTRLPKT2.AUTOINIT = AUTOINIT_OFF; /* autoinit */
dmaReqAssign(DMA_CH1, 31);
dmaSetCtrlPacket(DMA_CH1, g_dmaCTRLPKT2);
g_dmaCTRL g_dmaCTRLPKT3;
/*Configure control packet for Channel 1*/
g_dmaCTRLPKT3.SADD = (uint32_t)MSG3; /* source address*/
g_dmaCTRLPKT3.DADD = (uint32_t)((uint8*)&(sciREG->TD)+3); /* destination address */
g_dmaCTRLPKT3.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT3.FRCNT = 13; /* frame count */
g_dmaCTRLPKT3.ELCNT = 1; /* element count */
g_dmaCTRLPKT3.ELDOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT3.ELSOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT3.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT3.FRSOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT3.PORTASGN = 4;
g_dmaCTRLPKT3.RDSIZE = ACCESS_8_BIT; /* read size */
g_dmaCTRLPKT3.WRSIZE = ACCESS_8_BIT; /* write size */
g_dmaCTRLPKT3.TTYPE = FRAME_TRANSFER; /* transfer type */
g_dmaCTRLPKT3.ADDMODERD = ADDR_INC1; /* address mode read */
g_dmaCTRLPKT3.ADDMODEWR = ADDR_FIXED; /* address mode write */
g_dmaCTRLPKT3.AUTOINIT = AUTOINIT_OFF; /* autoinit */
dmaReqAssign(DMA_CH2, 31);
dmaSetCtrlPacket(DMA_CH2, g_dmaCTRLPKT3);
In my main i do all the necessay init and then :
sciREG->SETINT = (1<<16)| (1<<8); // set tx dma and set tx int
then in my loop i use dmaSetChEnable(DMA_CH0, DMA_HW),dmaSetChEnable(DMA_CH1, DMA_HW) and dmaSetChEnable(DMA_CH2, DMA_HW) with delays but using hterm the first message received is correct i get 15 bytes out of 15, the second message is wrong i get 13 bytes out of 14 all the bytes are correct except the second byte completly missing.
For exemple for a message like 0xB7,0X56,0XAA,0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 I get 0xB7,0XAA,0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66.
For the third message i get the same error as the second message 12 bytes out of 13 were all the bytes are correct except the second byte compltely missing.
When i only send the 1st, 2nd or 3rd message I have no error but whenever the DMA switch between channels the first messages is correct but the rest of the messages are received by hterm without the second byte.
Any idea why ? am I missing a configuration step ?
Thank you for your help in advance.