cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 + FreeRTOS + USART Interrupt: Receive: some of the letters received twice

kupchykdaniil
Associate III
Posted on February 14, 2013 at 13:47

The original post was too long to process during our migration. Please click on the attachment to read the original post.
3 REPLIES 3
Posted on February 14, 2013 at 14:21

Don't be putting blocking functions like USART_puts(USART3, RBUF); in the interrupt?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kupchykdaniil
Associate III
Posted on February 14, 2013 at 14:55

Blocked function was deleted, I really have no need in it, because RBUF variable is a global variable, but the problem still here, chars doubling in random position of message.

Thank you for try.

It goes worst:

1R0,Dm=004D,Dx=060D,Sn=0.0M,Sm=0.0M,Sx=0.1M,Taa=24.1C,Ua=31.5P,Pa=1007.1H,Rc=0.00M,Ri=0.0M,Hc=0.0M,HHi=0.0M,Th=24.0C,Vh=0.0N,Vs=12.0V,Vr=3.512V

1R0,Dm=348D,Dx=002D,Sn=0.0M,Sm=0.1M,Sx=0.1M,Ta=24.1C,Ua=31.5P,Pa=1007.1H,Rc=0.00MM,Ri=0.0M,Hc=0.0M,Hi=0.0M,Th=24.0C,Vh=0.0N,Vs=12.0V,Vr=3.510V

1R0,Dm=042D,Dx=066D,Sn=0.1M,Smm=0.1M,Sx=00.2M,Ta=24.2C,Ua=31.44P,Pa=1007.0H,Rcc=0.00M,Ri=0.0M,Hc=0.0M,Hi=0.0M,Th=24.0C,Vh=0.0N,Vs=12.0V,Vr=3.508V

M,Sx=0.2M,Ta=24.2C,Ua=331.4P,Pa=1007.0H,Rc=0.00M,Ri=0.0M,Hc=0.0a=1007.0H,Rc=0.00M,Ri=0.0M,Hc=0.0M,Hi=0.0M,Th=23.8C,,Vh=0.0N,Vs=12.0V,Vr=3.510V

.1M,Sx=00.2M,Ta=24.2C,Ua=31.44P,Pa=1007.0H,Rcc=0.00M,Ri=0.0M,Hc=0.0M,Hi=0.0M,Th=24.0C,Vh=0.0N,Vs=12.0V,Vr=3.508V

1R0,Dm=017D,Dx=017D,Sn=0.1M,Sm=0.1M,Sx=0.2M,Ta=24.2C,Ua=31.4P,Pa=1007.0H,Rc=0.00M,Ri=0.0M,Hc=0.0M,Hi=0.0M,Th=23.8C,,Vh=0.0N,Vs=12.0V,Vr=3.510V

1R0,Dm=032D,Dx=047D,Sn=0.0M,Sm=0.1M,Sx=0..1M,Ta=24.2C,Ua=31.4P,Pa=1007.0H,Rc=0.000M,Ri=0.0M,Hc=0.0M,Hi=0.00M,Th=23.8C,Vh=0.0N,Vs=12.0V,Vr=3.510V

.1M,Sx=0.2M,Ta=24.2C,Ua=31.4P,P0.1M,Sx=0.1M,Ta=24.2C,Ua=31.4P,Pa=10077.0H,Rc=0.00M,Ri=0.0M,Hc=0.0M,Hi=0.0M,Th=24.0C,,Vh=0.0N,Vs=12.0V,Vr=3.510V

1M,Sx=0..1M,Ta=24.2C,Ua=31.4P,Pa=1007.0H,Rc=0.000M,Ri=0.0M,Hc=0.0M,Hi=0.00M,Th=23.8C,Vh=0.0N,Vs=12.0V,Vr=3.510V

1R0,Dm=062D,Dx=062D,Sn=0.0M,Sm=
Posted on February 14, 2013 at 18:17

I don't have the time to wade into your project.

Of what I can see you really need to buffer and abstract the serial port data better. You need to be sending/receiving into some ring buffers of sufficient size, and have the interrupt shoveling the data as the USART is ready for it, at a singular point.

Then you might want to look at data loss issues, whether you're losing stuff on the wire, or getting in to the buffer in multiple places, and if you need a mutex/semaphore to arbitrate access.

The way you clear our RBUF is a complete waste of effort/resources.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..