I am developing a system using a MSP430F5418a as the core part. In the system, there is a UART connection to an external device. The data is a string of commands. There is no way to hold off the data stream so the MSP has to be able to accept whatever data comes. The commands are variable length and the time between the commands is indeterminate. Some of the commands cause the flash on the MSP to be erased and written. Because of that, I am not able to use a simple ISR routine to pull the data from the UART module on the MSP. Therefore, I have to use the DMA in conjunction with the UART.
My problem is how to handle the DMA. I plan on setting it up in a repeated single transfer mode with a size of around 512 bytes. I would then periodically pull the data out of the block the DMA is writing to. However, at some point, the DMA block needs to be reset to the start of the buffer. To reset it, I would have to disable the DMA. If a receive byte happens to arrive during the time it is disabled, when I re-enable the DMA, it would miss that byte and be locked up. The only way I can think to handle it is to check the UCRXIFG flag after I have re-enabled the DMA. If it is set, then I would pull the byte from the UART RX buffer and add it to the data I just pulled from the block.
Is this an acceptable solution? Is there a better way of dealing with this problem?
Thanks,
Brent