This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

spurious byte transmitted when enabling USCI UART

Hi,

When I enable the uart I see a byte that I have not written to UCA1TXBUF appear on the hyperterminal screen.

It appears to happen just after:

UCA1CTL1 |= UCSWRST;

This is using a 5437 device.

I can avoid this by not setting P5SEL to uart until after I have pulled the USCI out of reset.

I also appear to have to add a delay before I begin transmitting in order to avoid errors.

If I add these modifications then I can transmit without issues

Is this behaviour expected? Not sure if it is something wrong with the USB->serial dongle that I have.

   UCA1CTL1 |= UCSWRST;                      // **Put state machine in reset**
   UCA1CTL1 |= UCSSEL_2;                     // SMCLK
   UCA1BR0 = (uint8_t)prescale;               // set prescaler
   UCA1BR1 = (uint8_t)(prescale>>8);
   UCA1MCTL |= UCBRS_7 + UCBRF_0;            // Modulation
   UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**                              
   //we seem to require this delay, still no idea why..
   __delay_cycles(1000);
   P5SEL = (BIT6 | BIT7);                    //Enable output pins after reset to avoid spurious transmit

Thanks,

 

Alistair

  • Just curious, how are P5DIR and P5OUT set before all this code?

    You may just need to make sure that the bit for the TX pin is set high in both P5DIR and P5OUT.

    Jeff

  • Thanks Jeff!

    They were set to output but with POUT=0.

    Setting them high fixed my problem and allowed me to remove the delay.

    So I guess the problem was that the serial port was interpreting the change on the lines from output low to the UART being enabled?

  • alistair crawford said:
    the serial port was interpreting the change on the lines from output low to the UART being enabled

    A low line signal longer than 9 bit times (all data bits and stop bits and parity bits low) is considered a break character (the 257th character in the 8 bit set). Incoming break characters trigger RXIFG and RXBUF contains a 0 value.
    Also, the initial (after reset) high line, then the port initialization to low and then switching to UART with idle-high could be interpreted as a real character (starting with a low start bit, some more low data bits, some high data bits and a high stop bit)

**Attention** This is a public forum