Hello
Here is my simple code which i have written to transmit a single byte through UART using DMA. I have added destination address of my UART D register. I am not understanding after loading the destination address its going to hard fault. Please any one help me out in this
Attached the code
Hi
Is the hard fault an eDMA fault or a CPU fault?
CPU: I see no risk in DMA_TCD0_DAAR = 0x400eb007; itself as long as the DMA controller has been powered up (previous writes to it worked)
eDMA: If it is an eDMA error (that is, the eDMA status register is showing the fault) it could be due to the fact that you look to have enabled the DMA operation before configuring its registers. If the UART triggers a transfer in the meantime it could do illegal things.
Here is commented reference code for your case as reference:
ptrBufSource = a;
ptrBufDest = 0x400eb007;
ulBufLength = 1;
ptrDMA_TCD->DMA_TCD_SOFF = 1; // source increment (buffer)
ptrDMA_TCD->DMA_TCD_DOFF = 0; // destination not incremented
ptrDMA_TCD->DMA_TCD_DLASTSGA = 0; // no destination displacement on transmit buffer completion
ptrDMA_TCD->DMA_TCD_SLAST = (-(signed long)(ulBufLength)); // when the buffer has been transmitted set the destination back to the start of it
ptrDMA_TCD->DMA_TCD_ATTR = (DMA_TCD_ATTR_DSIZE_8 | DMA_TCD_ATTR_SSIZE_8); // transfer sizes bytes
ptrDMA_TCD->DMA_TCD_SADDR = (unsigned long)ptrBufSource;// source buffer
ptrDMA_TCD->DMA_TCD_CSR = (DMA_TCD_CSR_INTMAJOR); // interrupt when the transmit/receive buffer is full
ptrDMA_TCD->DMA_TCD_CSR |= DMA_TCD_CSR_DREQ; // stop the DMA activity once the single buffer transfer completes
ptrDMA_TCD->DMA_TCD_DADDR = (unsigned long)ptrBufDest; // destination
ptrDMA_TCD->DMA_TCD_NBYTES_ML = 1; // each request starts a single transfer of this size (minor byte transfer count)
ptrDMA_TCD->DMA_TCD_CITER_ELINK = (signed short)(ulBufLength); // the number of service requests to be performed each buffer cycle
ptrDMA_TCD->DMA_TCD_BITER_ELINK = ptrDMA_TCD->DMA_TCD_CITER_ELINK;
DMA_ERQ |= ulChannel; // enable operation
Regards
Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements
Thanks,
But still i could not able to see the DMA transfer on putty. Its showing nothing.
Hi
Do you have code that works in non-DMA mode to be sure there are not issues elsewhere?
As noted in other thread you may find it easier to start with a working solution and reverse engineer it back to you own code if you need to write everything yourself.
https://github.com/uTasker/uTasker-Kinetis
contains complete code for your device with UART Rx and Tx DMA on any/all UARTs and simulation of its operation in Visual Studio, which you can dissect and copy bits across from.
Regards
Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements
I have checked my uart without DMA its working perfectly fine. When i am enabling DMA its not working. It could not able to print on to the putty.