Rx framing error

rx framing error

There is no interrupt for a framing error. Instead you'll need to check the RX status for this kind of error. Open datasheet and search for "framing". Bob. The uart is implemented with a FTDI USB to UART converter - FT230XS-R: Concerned that the FTDI is not driving a logic '1' as 5v but only 3.3. Framing errors might also occur if the baud rate/crystal/pll are generating less than ideal clocks, or the sender is not clocking the data at.

Rx framing error - sorry

(1<<WGM01); //FAST PWM mode

TCCR0 = (1<<PA0);

break; //Change motor direction to left

 

case 'S':

PORTB = (1<<PB0); //in1=1

break; //Change motor direction to Right

 

case 'L':

PORTB &= ~(1<<PB0) & ~(1<<PB1); //clear Dir-pins

PORTA&=~(1<<PA0)&~(1<<PA1);

PORTA

UARTE Frame error receiving

// Initialize uarte nrfx_uarte_config_t config = NRFX_UARTE_DEFAULT_CONFIG; // Initialize uart result = nrfx_uarte_init(&m_serial[id].uart, &config, SerialInterfaceEventHandler); APP_ERROR_CHECK(result); // Start receiving and specify buffer for double buffering result = nrfx_uarte_rx(&m_serial[id].uart, &m_serial[id].rxBuffer[0], 1); APP_ERROR_CHECK(result); result = nrfx_uarte_rx(&m_serial[id].uart, &m_serial[id].rxBuffer[1], 1); APP_ERROR_CHECK(result); // Event handler static void SerialInterfaceEventHandler(nrfx_uarte_event_t const * p_event, void* p_context) { ret_code_t ret; int id = (uint32_t)p_context; switch (p_event->type) { case NRFX_UARTE_EVT_TX_DONE: //!< Chunk of data has been sent. SerialCallEventHandler(id, SE_TX_COMPLETE); break; case NRFX_UARTE_EVT_RX_DONE: //!< New chunk of data has been received. rxCount++; if (p_event->data.rxtx.bytes > 0) { SerialReceiveInsert(id, p_event->data.rxtx.p_data[0]); } // Previous test, not sure if a new nrfx_uarte_rx call is needed when using // double buffering (but it works like below for UART interface // SerialReceiveInsert(id, m_serial[id].rxBuffer[m_serial[id].rxIndex]); // ret = nrfx_uarte_rx(&m_serial[id].uart, &m_serial[id].rxBuffer[m_serial[id].rxIndex], 1); // APP_ERROR_CHECK(ret); // m_serial[id].rxIndex = 1-m_serial[id].rxIndex; SerialCallEventHandler(id, SE_RX_READY); break; case NRFX_UARTE_EVT_ERROR: serError++; error = p_event->data.error.error_mask; SerialCallEventHandler(id, SE_ERROR); break; } }

I have attached the basic initialization and eventhandler code. 

= 0b11; //in1 ,in2=1

PORTA = (1<<CS01); //  PRESCALLER /8

TCNT0=0;  //initialize TCNT0

OCR0 = 0; //Initialize PWM duty cycle to 0%

 

//UART initialization

UCSRB

Rx framing error - agree, very

=(1<<COM01); // SET OC0 (PB3)AT BOTTOM NON INVERTING MODE ...note that OCR0 IS CONNECTED TO EN1 AND EN2

TCCR0 =(1<<PB7);

_delay_ms(150);

PORTB&=~(1<<PB7);

break; //Increase PWM duty cycle by 10

 

 

 

case 'D':

if(OCR0 >= 0)

OCR0 -= 10;

PORTB =(1<<PB6); //turn on yellow led

_delay_ms(150);

PORTB&=~(1<<PB6);// turn off yellow led

break; //Decrease PWM duty cycle by 10

 

case 'F': 

PORTB &= ~(1<<PB1); //clear Dir-pins

PORTA&=~(1<<PA1); // clear Dir-pins

PORTB =(1<<PA0);//in3=1

break; //Change motor direction to be Forward

 

case 'B':

PORTB &= ~(1<<PB0); //clear Dir-pins

PORTA&=~(1<<PA0); // clear Dir-pins

PORTB (1<<PB5)

UART frame error

niv's profile photo

niv

unread,
Jan 24, 2002, 10:40:59 PM1/24/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

You do not have permission to delete messages in this group

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

Anyone know the philosophy behind frame error on uarts?

I've designed a uart which works fine, but to fully test it, the test bench
sends a frame with a wrong stop bit (i.e. set to 0, to force a frame error).

when this happens the uart receiver gets a bit screwed up at the moment.
This is because after the middle of the stop bit detection (be it good or
bad) the rx starts looking for a new start bit.
Since a bad stop was sent, this is seen straightaway as the new start bit,
so everything gets out of step.

What is the correct methodology for dealing with incorrect stop bit(s)?

One option is to abort reception until a '1' is detected on the line, and
then start again searching for start bit.

Anyone got any good ideas or point me at the relevant web page.

TIA Niv.

Ray Andraka's profile photo

Ray Andraka

unread,
Jan 24, 2002, 11:20:31 PM1/24/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

You do not have permission to delete messages in this group

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

You usually sample at some multiple of the bit clock. From the start bit
detection, you wait a half of a bit time then sample at 1 bit intervals. After
you sample the stop bit (at the center of the bit) you should wait a half bit
time before enabling the start bit detect again. That said, even then you may
get a false start due to unknown timing relationship between your local timing
and the sender.

niv wrote:

--
--Ray Andraka, P.E.
President, the Andraka Consulting Group, Inc.
401/884-7930 Fax 401/884-7950
email [email protected]
http://www.andraka.com

"They that give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety."
-Benjamin Franklin, 1759

niv's profile photo

niv

unread,
Jan 25, 2002, 12:30:16 AM1/25/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

You do not have permission to delete messages in this group

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

I know all about the 16x clock etc., the problem is that you MUST start to
look for a new start bit after the middle of the last stop bit to ensure the
+ or - 4% tolerance on the baud rate.

(I believe this comes from 16x 12 bits [strt,8data,parity 2 stop;as worst
case], which is 192 clk cycles, so half bit period or 8 clks in 192 gives
4%)

Niv.

Ray Andraka <[email protected]> wrote in message
news:[email protected]

Allan Herriman's profile photo

Allan Herriman

unread,
Jan 25, 2002, 4:10:27 AM1/25/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

On Thu, 24 Jan 2002 20:30:16 -0000, "niv" <[email protected]> wrote:

>I know all about the 16x clock etc., the problem is that you MUST start to
>look for a new start bit after the middle of the last stop bit to ensure the
>+ or - 4% tolerance on the baud rate.
>
>(I believe this comes from 16x 12 bits [strt,8data,parity 2 stop;as worst
>case], which is 192 clk cycles, so half bit period or 8 clks in 192 gives
>4%)

Yeah, some of the early 8051 variants had this bug. They would wait
until the end of the stop bit before looking for a start bit.
If the tx device had a clock that was a few ppm faster than the rx
clock, it would evenually cause errors if the tx was sending
characters continuously.

(The fix for that particular product was to get the tx to send two
stop bits.)

Philips eventually fixed the uart, and it now starts looking for a
start bit from the middle of the stop bit.

Regards,
Allan.

Eric Smith's profile photo

Eric Smith

unread,
Jan 25, 2002, 8:53:47 AM1/25/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

"niv" <[email protected]> writes:
> I know all about the 16x clock etc., the problem is that you MUST start to
> look for a new start bit after the middle of the last stop bit to ensure the
> + or - 4% tolerance on the baud rate.

It's not just for baud rate tolerance. A modem that is receiving a signal
that is slightly overspeed will shave a fraction off the stop bit to allow
it to keep up, if you are using a synchronous modulation (basically anything
from 1200 bps up) and you are not using error control (MNP or V.42). This
was specified in some CCITT (now ITU-T) standard, but I don't recall which
one.

This caused problems with the NEC 7210 SCC, which was found in the
AT&T 7300 and 3B1 "UnixPC" computers. It required one full stop bit, and
would fail if it got the occasional 15/16 stop bit.

Allan Herriman's profile photo

Allan Herriman

unread,
Jan 25, 2002, 10:43:36 AM1/25/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

On 24 Jan 2002 20:53:47 -0800, Eric Smith
<[email protected]> wrote:

Sounds like ITU-T V.14. There's also one in V.22 (as part of a modem
standard) IIRC.

ITU-T also have asynchronous to synchronous mappings in V.110 and
V.120 (as part of ISDN), but they work a bit differently.

Regards,
Allan.

Niv's profile photo

Niv

unread,
Jan 27, 2002, 2:59:47 PM1/27/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

You do not have permission to delete messages in this group

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

I think I've found what a uart should do (hopefully).

If a stop error occurs on the first stop bit, flag this as a frame error.
An error on second stop bit (only) is not catered for. (I assume it is seen
as a start bit, so following byte will be in error).

If stop error on first, and possibly only, stop bit, and all data bits are
also '0', then assume a line break, and stay here until a '1' is detected on
the line again.

If anyone knows differently, please speak now; I'm about to recode my custom
uart RX.

Niv.

Allan Herriman's profile photo

Allan Herriman

unread,
Jan 27, 2002, 4:55:08 PM1/27/02

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

What you have described sounds like standard UART operation.

I assume that when you say:

>An error on second stop bit (only) is not catered for.

you mean that you don't check the second stop bit.
Most UARTs (well, all UARTs that I've used) only ever check one stop
bit on receive. The "two stop bit" setting only affects the
transmitter.

I think some break detectors require multiple characters to have all
zero data bits and framing errors to detect break. I'm not sure what
the ideal number is though. (A single character sounds like it would
be too sensitive to noise.)

Regards,
Allan.

(1<<PA1); //DIR2 AND ENABLE PINS

PORTB=0; //All initialized to 0

PORTA=0;//ALL initialized to 0

 

//Timer0 initialization

TCCR0=(1<<WGM00) =(1<<PA1); //in4=1

break; //Change motor direction to be Backward

case 'R':

PORTB &= ~(1<<PB0) & ~(1<<PB1); //clear Dir-pins

PORTA&=~(1<<PA0)&~(1<<PA1);//Clear Dir-Pins

PORTB =(1<<PA0);//in3=1

break; //Change motor direction to be Forward

 

case 'B':

PORTB &= ~(1<<PB0); //clear Dir-pins

PORTA&=~(1<<PA0); // clear Dir-pins

PORTB = (1<<PB0); //in1 =1

PORTA (1<<PB2) (1<<WGM01); //FAST PWM mode

TCCR0 rx framing error

0 Comments

Leave a Comment