Hello everyone,
I am trying the dma_led_pattern example on pic32mz ef sk Evaluation board. What it does is basically to load the bytes from the array to the port H every time the Timer goes overflow.
It works fine.
Now, I want to load this source-array into another Array instead of PORTH but while debugging I can't see any data in the destination array.
Here the code that shows what I am trying to accomplish.
Original working code:
const unsigned char LED_pattern[]=
{
0x01, 0x02, 0x04, 0x01, 0x02, 0x04, 0x01, 0x02,
0x04, 0x01, 0x02, 0x04, 0x01, 0x02, 0x04, 0x01,
0x02, 0x04, 0x01, 0x02, 0x04, 0x01, 0x01, 0x01
};
#include "framework/system/dma/sys_dma_static.h"
void SYS_DMA_Channel0TransferAdd(void)
{
/* Set the source and destinaton addresses (addresses are converted from virtual to physical) */
PLIB_DMA_ChannelXSourceStartAddressSet(DMA_ID_0, DMA_CHANNEL_0, (uint32_t)LED_pattern);
PLIB_DMA_ChannelXDestinationStartAddressSet(DMA_ID_0, DMA_CHANNEL_0, (uint32_t)&LATH);
/* Set the source and destination sizes */
PLIB_DMA_ChannelXSourceSizeSet(DMA_ID_0, DMA_CHANNEL_0, 24);
PLIB_DMA_ChannelXDestinationSizeSet(DMA_ID_0, DMA_CHANNEL_0, 2);
/* Set the number of bytes per transfer */
PLIB_DMA_ChannelXCellSizeSet(DMA_ID_0, DMA_CHANNEL_0, 1);
}
my code:
const unsigned char LED_pattern[]=
{
0x01, 0x02, 0x04, 0x01, 0x02, 0x04, 0x01, 0x02,
0x04, 0x01, 0x02, 0x04, 0x01, 0x02, 0x04, 0x01,
0x02, 0x04, 0x01, 0x02, 0x04, 0x01, 0x01, 0x01
};
#include "framework/system/dma/sys_dma_static.h"
volatile uint16_t LATHbuffer[24];
void SYS_DMA_Channel0TransferAdd(void)
{
/* Set the source and destinaton addresses (addresses are converted from virtual to physical) */
PLIB_DMA_ChannelXSourceStartAddressSet(DMA_ID_0, DMA_CHANNEL_0, (uint32_t)LED_pattern);
PLIB_DMA_ChannelXDestinationStartAddressSet(DMA_ID_0, DMA_CHANNEL_0, (uint32_t)&LATHbuffer[0]);
/* Set the source and destination sizes */
PLIB_DMA_ChannelXSourceSizeSet(DMA_ID_0, DMA_CHANNEL_0, 24);
PLIB_DMA_ChannelXDestinationSizeSet(DMA_ID_0, DMA_CHANNEL_0, 24);
/* Set the number of bytes per transfer */
PLIB_DMA_ChannelXCellSizeSet(DMA_ID_0, DMA_CHANNEL_0, 1);
}
The LATHbuffer is always empty showing 0x00.
What am I doing wrong?
I appreciate any help. Thank you in advance.