MO_YA_NE
Member
I'm trying to transfer the data received by UART to RAM by DMA, but it fails.
When I execute the code below and enter 4 characters from the terminal software, an unintended result is output.
The execution result will be like this...
Hellow!!
97
255
115
255
100
255
102
255
I typed in 4 numbers, so I want the RAM to contain 4 numbers, but for some reason 255 is inserted.
I want someone to point out my mistake or correct it.
When I execute the code below and enter 4 characters from the terminal software, an unintended result is output.
Code:
#include "DMAChannel.h"
unsigned char DMA_TxBuf[50]; //transfer buffer 50
unsigned char DMA_RxBuf[50]; //receive buffer 50
DMAChannel dmachannel1;
void INT_DMA1(void)
{
int i;
dmachannel1.clearInterrupt();
for(i=0;i<8;i++){
Serial8.printf("%d\n\r",DMA_RxBuf[i]);
}
}
void DMA_Init(void)
{
//*****************DMA1****************************************************
dmachannel1.begin();
dmachannel1.source((uint8_t&)LPUART5_DATA);
dmachannel1.destinationBuffer(DMA_RxBuf,8);
dmachannel1.triggerAtHardwareEvent(DMAMUX_SOURCE_LPUART5_RX);
dmachannel1.interruptAtCompletion();
dmachannel1.attachInterrupt(INT_DMA1);
dmachannel1.enable();
}
void setup() {
Serial8.begin(115200); //115200kbps
LPUART5_BAUD|=0x100000; //RDMAE
DMA_Init();
Serial8.printf("Hellow!!\n\r");
}
void loop() {
}
The execution result will be like this...
Hellow!!
97
255
115
255
100
255
102
255
I typed in 4 numbers, so I want the RAM to contain 4 numbers, but for some reason 255 is inserted.
I want someone to point out my mistake or correct it.