Other Parts Discussed in Thread: SYSCONFIG, MSPM0G3519
Tool/software:
Hi to everyone,
We have developed PCB with MSPM0G1507 MCU embedded on it. We are now in the process of writing the code for it and we have some strange issue with the UART module during message transmitting from the MCU.
First of all, we are using Code Composer Studio 12.8.1 to develop the project, using TI DriverLib and SysConfig as a code base and GCC compiler.
I'll make a short introduction to the problem first. We developed the PCB with intention for it to be a common control board for a lot of various machine projects and therefore a lot of components are used within the MCU. Among other things, we are using 3 UART modules. For this reason our intention is to use almost all DMA channels for various modules. Therefore, we have to use one DMA channel per UART module and reconfigure it when we need to switch between transmitting and receiving data over UART module. Also, to avoid a lot of CPU interrupts, we are trying to poll CPU Raw Interrupt Status registers for each UART module. Specifically for transmitting, we are checking if end of transmission flag is set in CPU_INT.RIS register and this way check if data transmission is complete.
Initially, we saw that this works just fine. After we detect a flag set into CPU_INT.RIS register, we also clear it over ICLR register and we continue with our program, but we just ran into some issue. In one of our projects we have to send machine status periodically (once per second for example) and now we saw that occasionally some bytes are skipped (not sent) on UART line. We are sending data packet of 10 bytes and occasionally 1 byte is skipped (each time it happens it can be different one). This happens usually 5-10% of the times and not with some specific period or order. We did a lot of tests to try to find the cause and we are 99% percent sure that it has something with this RIS register polling approach (and not just with UART module).
The status string is initiated as a char array and just 3 of its characters are modified within program main loop. One of the tests we tried is to disable the code optimization level by the compiler and this just reduced the problem to maybe about 1% of error appearance. Another test we tried is to replace status string variable with static string matching the status string and here actually there are no errors, regardless of code optimization level. So here we thought this has to be connected somehow with variable use.
But then we did the test where we actually ran interrupt routine on end of transmission event and here we actually also don't have errors. But... In our main project we also have ADC module running. There we want to do DMA Ping-Pong concept for ADC and in the main program loop we call a function in which we poll CPU_INT.RIS register of the ADC module and check if DMA_DONE interrupt flag is set, when we switch between ping and pong memory locations. The reason I'm writing about ADC concept is to make a parallel between ADC and UART interrupt flag polling and to make then a point that some bytes happens to be skipped on transmitting over UART module even if we use standard interrupt routine on UART module but we use RIS register polling routine on some other module.
At the end I have to add that DMA_DONE_TX flag is also set when we get end of transmission flag set. Also, we tapped to the UART module transmit line with the data logger and we can confirm that the byte is really skipped (not just like low or high line for the length of that byte).
So our conclusion is that if we use RIS registers polling anywhere in the code for any MCU module, some byte from character array variable gets skipped during UART transmission. If we are sending statis string or we don't use RIS registers polling then we don't have bytes skipped. As per RIS register and debug information, we see that the data is correctly passed to the DMA module and that the DMA module transfers requested amount of bytes to the UART module and that it seems that UART module then does not serialize all the data on the UART transmit line.
So now I'm reaching to you for help with a question, is it possible to successfully make end of transmission detection over RIS register polling instead of regular interrupt routine with some specific MCU configuration or procedure and to do this with all the data sent over the UART bus? I can provide test project if needed.
Thanks in advance and best regards!
Jovan