cancel
Showing results for 
Search instead for 
Did you mean: 

USART - wrong data

johanbleumers9
Associate II
Posted on August 30, 2012 at 15:01

I'm currently debugging STM8 software of a colleague who is on holiday and i face a problem which i cannot immediatly solve...  (I’m an analog engineer, so software is not really my cup of tea)

The device has a USART interface (at 250kBaud). 99% of the received data is correct, but sometimes dataslots are skipped. Usualy (allways???) skipped slots are

the first few after the break.

The break of the transmitter is 3,4ms and the MAB is 108µs, only 32 slots are sent. When i use another transmitter with 15ms break, 136µs MAB and

512 data slots, the receiver works flawless.

I have simplified the code to the basic functionality as shown below, but the problem remains...

  INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)

  {

   

  RxBuffer[RxPos] = UART2_ReceiveData8();

  if(UART2_GetFlagStatus(UART2_FLAG_FE) )

  {

   Data_1 = RxBuffer[DMX_Structure.start_address];

   Data_2 = RxBuffer[DMX_Structure.start_address + 1];

   Data_3 = RxBuffer[DMX_Structure.start_address + 2];

   Data_4 = RxBuffer[DMX_Structure.start_address + 3];

   Data_5 = RxBuffer[DMX_Structure.start_address + 4];

   RxPos = 0;  

   UART2_ClearFlag (UART2_FLAG_FE); // Clear frame error flag of UART

  }

 

  if(RxPos<513)

   RxPos++;         

  UART2_ClearFlag(UART2_FLAG_RXNE);

  }

  Any ideas what might go wrong?

Regards.

1 REPLY 1
johanbleumers9
Associate II
Posted on September 04, 2012 at 17:21

I've been capturing data the uart receives, and it seems as if the uart occasionaly sees a break in the middle of a data frame and resettes the framecounter.

Is it possible that framing errors occur, that are misinterpreted as a break? Is the way the break is detected in my code above correct?

Regards,

Johan