I am using LPC822.
C: \ nxp \ LPCXpresso_8.2.2_650 \ lpcxpresso \ Examples \ LPCOpen \ lpcopen_3 _ 02 _ lpcxpresso _ nxp _ lpc xpresso _ 824. Zip \ periph _ dma _ uart
As in this example, four descriptors are used, and DMA_UART is performed only on RX by ping-pong operation.
Received data is always 8 bytes of uint, but there are occasional drops.
I improved it by adding delay so that it does not get lost, but when I miss it, I want to discard the data and capture it at the beginning of the next descriptor, how can it be done?
Or how do I initialize the descriptor?
Now 2 bytes of the next 8 bytes are included in the continuation area of the missing data (eg 6 bytes).
For example, suppose that data "01234567" "89 ABCDEF" is continuously received
descriptor 1: 01234589 (I missed "67")
descriptor 2: ABCDEF00
Because it becomes like this, I want to do as follows.
descriptor 1: 012345 (Discard this data)
descriptor 2: 89 ABCDEF
or
descriptor 1: 012345
Discard this data, initialize the descriptor
↓
descriptor 1: 89 ABCDEF
descriptor 2: 00000000
I want to capture like this.
Thank you.
Yukiyo Watanabe.
Hi 友妃代 渡辺,
Today, I test the project which you mentioned.
That project cr_startup_lpc82x.c g_pfnVectors have the problems, it doesn't add the DMA interrupt, so you need to add the DMA_IRQHandler, handler at first:
extern void (* const g_pfnVectors[])(void);
__attribute__ ((section(".isr_vector")))
void (* const g_pfnVectors[])(void) = {
// Core Level - CM0plus
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
SVC_Handler, // SVCall handler
0, // Reserved
0, // Reserved
PendSV_Handler, // The PendSV handler
SysTick_Handler, // The SysTick handler
// Chip Level - LPC8xx
SPI0_IRQHandler, // SPI0 controller
SPI1_IRQHandler, // SPI1 controller
0, // Reserved
UART0_IRQHandler, // UART0
UART1_IRQHandler, // UART1
UART2_IRQHandler, // UART2
0, // Reserved
0, // Reserved
I2C_IRQHandler, // I2C controller
SCT_IRQHandler, // Smart Counter Timer
MRT_IRQHandler, // Multi-Rate Timer
CMP_IRQHandler, // Comparator
WDT_IRQHandler, // Watchdog
BOD_IRQHandler, // Brown Out Detect
0, // Reserved
WKT_IRQHandler, // Wakeup timer
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
DMA_IRQHandler, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
PININT0_IRQHandler, // PIO INT0
PININT1_IRQHandler, // PIO INT1
PININT2_IRQHandler, // PIO INT2
PININT3_IRQHandler, // PIO INT3
PININT4_IRQHandler, // PIO INT4
PININT5_IRQHandler, // PIO INT5
PININT6_IRQHandler, // PIO INT6
PININT7_IRQHandler, // PIO INT7
}; /* End of g_pfnVectors */
void DMA_IRQHandler(void) ALIAS(IntDefaultHandler);
Actually, it't better to refer to the following vector table add the whole vector tables.
extern void (* const g_pfnVectors[])(void);
__attribute__ ((used,section(".isr_vector")))
void (* const g_pfnVectors[])(void) = {
// Core Level - CM0plus
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
0, // Reserved
0, // Reserved
0, // Reserved
__valid_user_code_checksum, // LPC MCU Checksum
0, // Reserved
0, // Reserved
0, // Reserved
SVC_Handler, // SVCall handler
0, // Reserved
0, // Reserved
PendSV_Handler, // The PendSV handler
SysTick_Handler, // The SysTick handler
// Chip Level - LPC82x
SPI0_IRQHandler, // SPI0 controller
SPI1_IRQHandler, // SPI1 controller
0, // Reserved
UART0_IRQHandler, // UART0
UART1_IRQHandler, // UART1
UART2_IRQHandler, // UART2
0, // Reserved
I2C1_IRQHandler, // I2C1 controller
I2C0_IRQHandler, // I2C0 controller
SCT_IRQHandler, // Smart Counter Timer
MRT_IRQHandler, // Multi-Rate Timer
CMP_IRQHandler, // Comparator
WDT_IRQHandler, // Watchdog
BOD_IRQHandler, // Brown Out Detect
FLASH_IRQHandler, // Flash Interrupt
WKT_IRQHandler, // Wakeup timer
ADC_SEQA_IRQHandler, // ADC sequence A completion
ADC_SEQB_IRQHandler, // ADC sequence B completion
ADC_THCMP_IRQHandler, // ADC threshold compare
ADC_OVR_IRQHandler, // ADC overrun
DMA_IRQHandler, // DMA
I2C2_IRQHandler, // I2C2 controller
I2C3_IRQHandler, // I2C3 controller
0, // Reserved
PININT0_IRQHandler, // PIO INT0
PININT1_IRQHandler, // PIO INT1
PININT2_IRQHandler, // PIO INT2
PININT3_IRQHandler, // PIO INT3
PININT4_IRQHandler, // PIO INT4
PININT5_IRQHandler, // PIO INT5
PININT6_IRQHandler, // PIO INT6
PININT7_IRQHandler, // PIO INT7
}; /* End of g_pfnVectors */
Then build the periph_dma_uart project and run it again.
This is my test result:
You can find, after several times send, I can receive the correct data.
Just from the received result, I didn't meet the problem which you mentioned, I didn't add the delay code, just comment the __WFI(); code.
My test board is the LPCXpresso824-MAX board, associated with the TTL-USB tool.
So, do you have the official board, can you also use the official board to reflect the problem? If you also can use the official board to reproduce it, please tell me the reproduce steps, thank you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi, Kerry
Thank you very much.
I'm sorry for the late reply.
It is "g_pfnVectors" of "cr_startup_lpc82x.c" that you taught, but I have already used the one that was fixed.
In my program, it is judged whether or not the following 1. exists in while (1) {} of int main (void), and 2. It executes the following.
1. Receive "command to send version information" from FPGA every certain period (A few tens of seconds).
2. Send Version information from the LPC822 to the FPGA
3. Receive "command to send voltage data" from FPGA
4. Send "command to send voltage data" by UART to microcomputer of other device 1
5. Receive voltage data from microcomputer of other device 1
6. Send the voltage data of the device 1 from the LPC822 to the FPGA
7. Send "command to send voltage data" by UART to the microcomputer of other device 2
8. Receive voltage data from microcomputer of other device 2
9. Send the voltage data of the device 2 from the LPC822 to the FPGA
(All commands here are uint 8 byte.)
I repeat this flow all the while.
However 3 to 5 days later, the command data of 8 bytes is cut off by several bytes, and the next 8 bytes will be inserted in succession.
(The environment uses the debug mode of LPCXpresso v8.2.2)
Since it takes a long time to test, we want to make it a good flow even if this phenomenon occurs.
I want to discard the lost data and put the next data from the beginning of the next descriptor.
Can not you do something like that?
(I am using the original board.
Since there are peripheral devices, exactly the same environment can not be reproduced using LPCXpresso 824-MAX board, but I will try to test whether to reproduce using LPCXpresso 824-MAX board. )
Thank you.