2012-05-15 06:40 PM
Hi , i want to transfer the incoming data on uart2 to uart1 using DMA i d'ont know where is the problem with my code
2012-05-15 06:42 PM
2012-05-15 07:19 PM
Hi , i want to transfer the incoming data on uart2 to uart1 using DMA i d'ont know where is the problem with my code
There are a bunch, but the most fatal is I don't think you can do a Peripheral-to-Peripheral in this fashion. You need to Rx DMA into one buffer, and then Tx DMA back out to the other USART. You also need this buffer to provide some elasticity because the USART's aren't synchronous. You don't want to be incrementing the address. Actually what you are doing here would be better implemented with a piece of wire, with the added benefit that it wouldn't add ~10 bit times worth of delay into the signal.2012-05-15 08:15 PM
In the data sheet as showen section 9.2
DMA main featuresPeripheral-to-memory and memory-to-peripheral, and peripheral-to-peripheraltransfers�? Access to Flash, SRAM, APB1, APB2 and AHB peripherals as source and destination�? Programmable number of data to be transferred: up to 65536I use uart as asynchronous peripheral2012-05-16 05:12 AM
> I use uart as asynchronous peripheral
But one uart is not necessarily synchonious to the other. I can't see the special advantage of the DMA, compared to the wire clive proposed. A simple RS232 echo could be done cheaper, and anything else will not work with uart-to-uart DMA.2012-05-16 05:29 AM
I wanted
a less
cluttered
that's why
I used
DMA
THx for help
2012-05-16 06:57 AM
I use uart as asynchronous peripheral
The baud rates have errors (ie +1%, -2%), if the incoming data is slightly faster than the data going out you're going to have issues with tying them together. Using flow control here? Your method has no way to sample the incoming data for processing, and doesn't address parity, framing, or other errors that may occur. The following might work, but I'm skeptical of it's function/usability/* USART1_Tx_DMA_Channel (triggered by USART1 Tx event) Config */
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&USART2->DR;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&USART1->DR;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 0x20;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel7, &DMA_InitStructure);
Honestly, I think you'd want to be doing this via the USART2 RX DMA, not the USART1 TX. As you want the DMA occuring when you have data, not when the transmitter is empty.
Like I said, the less cluttered design is to wire the pins together.
2013-10-30 09:37 AM
So nethertheless it is not described in the Reference manual Peritheral to Peritheral will work?
We think about to sample some currents and make them available for an FPGA. I Think about to transfer ADC2->DR to SPI->Transmit Register would that work? or would it be better to have it transfered to a memory location first? best regards Stefan2013-10-30 11:00 AM
Possibly, you'd have to experiment.
From a DMA perspective the peripheral-to-peripheral is nuanced, a peripheral on a different APB is a memory transfer, on the same bus you're looking at memory-to-memory. The issue is with plumbing, a peripheral-to-memory transfer could be achieved directly, where-as other modes would require a holding register, and the operation decomposed into two separate operations. The DMA in your example would be in-attentive to the SPI TXE state, if the periodicity of the transfer was sufficiently long that probably wouldn't matter. The latency would be a lot lower, and would require a lot lower interrupt loading and buffer management.