-->
Page 1 of 1

How to avoid garbage in UART0 after restart of ESP8266?

PostPosted: Tue Jun 02, 2015 8:54 am
by fvpalha
Hi.

We are using the ESP-12 and we need send data by UART0.
We are using the Unofficial Development Kit for Espressif ESP8266 (http://www.programs74.ru) and Absolutely transparent bridge for the ESP8266 (https://github.com/beckdac/ESP8266-transparent-bridge).

The problem is the garbage on start.
We are using GPIO15 to signal the beginning of the UART0.
We are using GPIO4 to signal the beginning of the uart_tx_one_char().
Code: Select allLOCAL STATUS
uart_tx_one_char(uint8 uart, uint8 TxChar)
{
   // INTCOM em alta - envio de comando
   gpio_write(GPIO_4_PIN, 1);

   while (true)
   {
      uint32 fifo_cnt = READ_PERI_REG(UART_STATUS(uart)) & (UART_TXFIFO_CNT<<UART_TXFIFO_CNT_S);
      if ((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) < 126) {
         break;
      }
   }

   WRITE_PERI_REG(UART_FIFO(uart) , TxChar);
   return OK;
}


How to avoid garbage in UART0 after restart of ESP8266?

Re: How to avoid garbage in UART0 after restart of ESP8266?

PostPosted: Tue Jun 02, 2015 12:27 pm
by tytower
From what I've seen when it resets it dumps this out on 75000 baud odd then changes serial speed to 115200 baud . I would expect this will be the same each reset so can you have your program skipp so many bytes of data to some point you know that it will be at the later baud rate? Or perhaps time it ,say 5 seconds delay before you use UART

Re: How to avoid garbage in UART0 after restart of ESP8266?

PostPosted: Tue Jun 02, 2015 2:39 pm
by fvpalha
Hi tytower.

Thank you for your reply.
I added a delay as you suggested.

Re: How to avoid garbage in UART0 after restart of ESP8266?

PostPosted: Wed Jun 03, 2015 3:46 pm
by fvpalha
I added this tip too:
http://www.esp8266.com/viewtopic.php?f=6&t=425&p=1827&hilit=softAP+dhcp+server+start#p1827

Code: Select allLOCAL void ICACHE_FLASH_ATTR
uart1_write_char(char c) {
   uart_tx_one_char(UART1, c);
}

void ICACHE_FLASH_ATTR
uart_init(UartBautRate uart0_br)
{
   UartDev.baut_rate = uart0_br;
   uart_config(UART0);

   // install uart1 putc callback
   os_install_putc1((void *)uart1_write_char);
}