- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a doubt about configuring a DMA with two TDs. For example, the first TD (TD[0]) goes from position 0 to 63 of an array, when it finishes, it switches to TD[1], where it goes from 64 to 128 of that same array. The first part is done correctly, however, the second part, the DMA is not transferring correctly the array's data.
I have set up the configuration as below:
-------------------------------------------------------------------------------------------------------------------------------------
CyDmaTdSetConfiguration(dmaDescriptor[0],
TEXT_MESSAGE_LENGTH*2, dmaDescriptor[1],
(TD_INC_SRC_ADR | DMA_1__TD_TERMOUT_EN));
CyDmaTdSetConfiguration(dmaDescriptor[1],
TEXT_MESSAGE_LENGTH*2, dmaDescriptor[0],
(TD_INC_SRC_ADR | DMA_1__TD_TERMOUT_EN));
CyDmaTdSetAddress(dmaDescriptor[0],
LO16((uint32)textMessage), LO16((uint32)UART_1_TXDATA_PTR));
CyDmaTdSetAddress(dmaDescriptor[1],
LO16((textMessage[TEXT_MESSAGE_LENGTH])), LO16((uint32)UART_1_TXDATA_PTR));
-------------------------------------------------------------------------------------------------------------------------------------
I think that the problem is that I didn't set up the offset correctly (I have tried using pointers also).
Thank you in advance
Chang
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I read your code right, each TD transfers TEXT_MESSAGE_LENGTH*2 bytes. But you set the address of the second TD with an offset of just TEXT_MESSAGE_LENGTH to the beginning of the textMessage array. This means the two TDs overlap by TEXT_MESSAGE_LENGTH bytes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have changed the length of the TD, but I am also I am getting strange output for the second half of the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to figure it out. The reason was that the source address (in this case) is a memory address, so to give the address of that position we should put '&':
------------------------------------------------------------------------------------------------------------------------------------------------------------
CyDmaTdSetAddress(dmaDescriptor[0],
LO16((uint32)textMessage), LO16((uint32)UART_1_TXDATA_PTR));
CyDmaTdSetAddress(dmaDescriptor[1],
LO16((uint32)(&textMessage[TEXT_MESSAGE_LENGTH])), LO16((uint32)UART_1_TXDATA_PTR));
------------------------------------------------------------------------------------------------------------------------------------------------------------
Chang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, the wonders of C pointer handling 🙂