title: STM32 USART Rx Interrupt doesn´t work correctly
body: <p>I´m using the STM32F407, and work on a project which I try to receive data with the USART3. </p>
  
  <p><strong>Project Overview:</strong></p>
  
  <p>I have to send a special PWM sequenz over a wire. After I sent the PWM, I´ve got on the same wire a response of serial data instantly (USART standard, 8N1). I generate the PWM with the timer1 update interrupt. After the last pulse I deactivate the timer1 interrupt an activate the USART Rx interrupt. Then - normaly - I should receive the serial data. The code which receive data and store them in a ringbuffer works very fine in a other project.</p>
  
  <p><strong>My problem:</strong></p>
  
  <p>The serial data, which are incoming will <strong>sometimes</strong> received correctly (It´s a stream of 96 single bytes). With an oscilloscope which can decode the USART signals I can see that the correct data arriving the USART Rx Pin. But the USART Rx interrupt doesn´t work correctly. Mostly I receive only one Byte (only one interrupt). To debug the ISR, I have saved the SR, DR and CR1 register into a array to log which of the error flags occured. The register values shows me, that ervery time, the reception of the frame failed, I have one or more different error flags set. Noise error, overrun error and framing error. But if sometimes the reception works, I see that no error flags was set. </p>
  
  <p>I thought that an Rx interrupt will generate everytime a byte arrived at the USART independent of the state of the error flags... </p>
  
  <p>I have really no idea why the ISR only works one time if there is an error flag. </p>
  
  <p>Could someone help me? </p>
  
  <p><strong>Update 1</strong>  </p>
  
  <p>Here is a short update. 
  I talked widh somebody who told me, it could be a problem that the USART receive the PWM signals too. I will try to change the state of the pin as an output while the USART is still running. After the last PWM pulse I will change the state of the Pin as UASRT Rx input. Maybe this could be fix the problem if the USART only can receive serial signals. I will post my proccress here. </p>
  
  <p><strong>Solution</strong></p>
  
  <p>Last week I solved my problems. </p>
  
  <p>First I have the problem that a function configure the Rx pin to an input for another peripheral...  (._.) </p>
  
  <p>The second problem was the bad signal quality. The USART of the STM32 have the possibility to work in the ONEBIT mode. This mode (as I understood) sample ervery bit only one time and not three times of each bit. So I increase the tolerance of my USART to 3,88%. </p>
  
  <p>Finally, but this is just to be on the safe side, I cleared all pending USART interrupt bits before I activate the USART Rx interrupt. </p>
  
  <p>Now I can receive the incoming frame reliable. </p>
  
  <p>Thanks for the comments and the help.  </p>