On my main board I have a STM32F103ZET6 and I use HAL library V1.6 in order to program it.There is also a sensor board which is connected to my main board and this sensor sends me data through UART continuously. In order to get sensor data, I use RXNE interrupt. There are some commands that I can send to this sensor in order to change some setting of this sensor. when I want to command this sensor and send some data to it, If I use HAL_UART_Transmit() (send data without using TXE interrupt) I get overrun error in some times. But when I use HAL_UART_Transmit_IT() (send data by using TXE interrupt) it seems that I get no error. why does it happen?

In reference manual RM0008, on page 794 we have USART block diagram. Although it shows that we have separated RDR and TDR but it seems that we have only one DATA Register that is shared by TDR and RDR and we have direct access to only DR. when we want to transmit data we should write in DR and and when some data received it is put in DR too. Now consider , meanwhile we are sending data and put some data in DR, there is a data which is being received and triggered interrupt. what would happen? Does this cause an Over run Error?

  • 1
    \$\begingroup\$ The shared data register is probably a shared memory location. Read and write of that address will have different side-effects - the UART will be full duplex. What is the worst-case time taken for the CPU to clear the received data? Is the TX routine blocking? \$\endgroup\$ – Sean Houlihane Oct 4 '17 at 12:11
  • \$\begingroup\$ @SeanHoulihane -"What is the worst-case time taken for the CPU to clear the received data?" I don't know. -"Is the TX routine blocking?" which one do you mean? HAL_UART_Transmit_IT() does not block and use TXE interrupt , but HAL_UART_Transmit() is blocking. \$\endgroup\$ – phoenix2000 Oct 4 '17 at 12:58
  • \$\begingroup\$ Between the UART having data, and the next character being received, what is your code doing? Interrupt driven means being stuck in a loop matters less. \$\endgroup\$ – Sean Houlihane Oct 4 '17 at 13:00
  • \$\begingroup\$ @SeanHoulihane read keys, touch and check if it needs to update the screen. \$\endgroup\$ – phoenix2000 Oct 4 '17 at 13:07
  • 1
    \$\begingroup\$ because the core doesn't respond, it's doing something else. That's the timing budget for responding to the UART? \$\endgroup\$ – Sean Houlihane Oct 4 '17 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.