I am learning to use DMA in Scatter Gather mode. So i use example code ("xaxidma_example_sg_poll.c"). Using "xil_printf" function to see value, I am done with this but it only transmit 1 BD, and i want more. I edit "SendData" function like this to transmit 2 BDs.
// i edit this code to transmit more than 1 BD staticintSendPacket(XAxiDma*AxiDmaInstPtr){XAxiDma_BdRing*TxRingPtr;
u8 *TxPacket;
u8 Value;XAxiDma_Bd*BdPtr;intStatus;intIndex;TxRingPtr=XAxiDma_GetTxRing(AxiDmaInstPtr);/* Create pattern in the packet to transmit */TxPacket=(u8 *)Packet;Value= TEST_START_VALUE;for(Index=0;Index<2*MAX_PKT_LEN;Index++){TxPacket[Index]=Value;
xil_printf ("TX addr: %x and value: %x\n\r",(unsignedint)(TxPacket+Index),(unsignedint)*(TxPacket+Index));Value=(Value+1)&0xFF;}/* Allocate 2 BD */Status=XAxiDma_BdRingAlloc(TxRingPtr,2,&BdPtr);if(Status!= XST_SUCCESS){return XST_FAILURE;}for(Index=0;Index<2;Index++){/* Set up the BD using the information of the packet to transmit */Status=XAxiDma_BdSetBufAddr(BdPtr,(UINTPTR)Packet);if(Status!= XST_SUCCESS){
xil_printf("Tx set buffer addr %x on BD %x failed %d\r\n",(UINTPTR)Packet,(UINTPTR)BdPtr,Status);return XST_FAILURE;}Status=XAxiDma_BdSetLength(BdPtr, MAX_PKT_LEN,TxRingPtr->MaxTransferLen);if(Status!= XST_SUCCESS){
xil_printf("Tx set length %d on BD %x failed %d\r\n",
MAX_PKT_LEN,(UINTPTR)BdPtr,Status);return XST_FAILURE;}
xil_printf ("TX BD addr: %x and value: %x\n\r",BdPtr,TxPacket);/* For single packet, both SOF and EOF are to be set
*/XAxiDma_BdSetCtrl(BdPtr, XAXIDMA_BD_CTRL_TXEOF_MASK |
XAXIDMA_BD_CTRL_TXSOF_MASK);XAxiDma_BdSetId(BdPtr,(UINTPTR)Packet);TxPacket+= MAX_PKT_LEN;BdPtr=(XAxiDma_Bd*)XAxiDma_BdRingNext(TxRingPtr,BdPtr);}/* Give the BD to DMA to kick off the transmission. */Status=XAxiDma_BdRingToHw(TxRingPtr,2,BdPtr);if(Status!= XST_SUCCESS){
xil_printf("to hw failed %d\r\n",Status);return XST_FAILURE;}return XST_SUCCESS;}
And error appear from "XAxiDma_BdRingToHw()" function
.
Question
Bui Cuong
I am learning to use DMA in Scatter Gather mode. So i use example code ("xaxidma_example_sg_poll.c"). Using "xil_printf" function to see value, I am done with this but it only transmit 1 BD, and i want more. I edit "SendData" function like this to transmit 2 BDs.
And error appear from "XAxiDma_BdRingToHw()" function
.
Any suggestion for me ? Thank
P.S: xaxidma_example_sg_poll.c : full code file
I will post my project file soon.
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.