uracoli-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [uracoli-devel] error in UART baudrate?


From: Tomás Glaria
Subject: Re: [uracoli-devel] error in UART baudrate?
Date: Thu, 18 Dec 2014 15:11:24 -0300

You're right, there they are, now watching the code for in hif_uart.c there's the call to HIF_UART_INIT():
void hif_init(const uint32_t baudrate)
{
    HIF_UART_INIT(baudrate);
    HIF_UART_TXIRQ_DI();
    HIF_IO_ENABLE();
    tx.head = tx.tail = 0;
    rx.head = rx.tail = 0;
}

'baudrate is defined as uint32_t, but in hif_uart.h is defined as uint16_t:
inline void HIF_UART_INIT(uint16_t baudrate)
   {
       uint16_t br;
       br = ENCODE_BAUDRATE(baudrate);
       if ( br & 0x8000 )
       {
      HIF_UART_STATUS = _BV(U2X0);  //Enable 2x speed
      br &= ~0x8000;
      }
       UBRR0H = (uint8_t)(br>>8);
       UBRR0L = (uint8_t) br;
...
   }

Also, what does that (br & 0x8000) do?
If F_CPU=16MHz, then br is >0x8000 when baudrate<30bps.
Is that expected?

On Thu, Dec 18, 2014 at 1:59 PM, <address@hidden> wrote:
Hi Tomas,
 
just had a quick look, the definition is in the files
 
Src/Lib/Inc/hif.h:void hif_init(const uint32_t baudrate);
Src/Lib/Ioutil/hif_at90usb.c:void hif_init(const uint32_t baudrate)
Src/Lib/Ioutil/hif_ft245.c:void hif_init(const uint32_t baudrate)
Src/Lib/Ioutil/hif_none.c:void hif_init(const uint32_t baudrate)
Src/Lib/Ioutil/hif_uart.c:void hif_init(const uint32_t baudrate)
 
So, let me have a look in detail tomorrow.
 
Cheers, Axel
 
 
 
Gesendet: Donnerstag, 18. Dezember 2014 um 16:37 Uhr
Von: "Tomás Glaria" <address@hidden>
An: address@hidden
Betreff: [uracoli-devel] error in UART baudrate?
I'm trying to use WiBo as the bootloader for my application and I'm trying to set higher baudrates than the default one (38400bps) to match the speed my devices will be using.
I've made a custom board based on a ATmega128RFA1 (pretty similar to the sparkfun board).
The thing is that whenever I try to set a baudrate bigger than 65555 (2^16, 2 bytes variable) I can't communicate with the board through the serial port.
 
I found that the configuration for the baudrate is in the file hif_uart.h, with the function definition "inline void HIF_UART_INIT(uint16_t baudrate){}"
Is that value correct?
What happens if I want to use 115200bps as baudrate (or 500000)?
 
I tried changing the declaration to "inline void HIF_UART_INIT(uint32_t baudrate){}" and then recompiled the 'board code' and THEN recompiled the host app (which is the one I'm testing right now) but no change.
 
So far I'm adding the code 
#define UBRR_VALUE (((F_CPU / (BAUD * 16UL))) - 1)
UBRR0H = (uint8_t)(UBRR_VALUE>>8);
UBRR0L = (uint8_t)UBRR_VALUE;
Which so far works, but I don't like calling a function which I can't find ("hif_init(BAUD);" is declared in hif.h but can't find its definition).
 
Ideas?
Explanations?
Someway to fix this?
 
I was just thinking in removing the code for the serial initialization in my particular case, but I guess that's not the solution for the whole uracoli environment.
 
--
Atte.
Tomás Ángel Glaría López
Ing. de Estudios
CADETECH S.A.


--
Atte.
Tomás Ángel Glaría López
Ing. de Estudios
CADETECH S.A.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]