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: Mon, 22 Dec 2014 16:20:22 -0300

If "serialdebug" is not mantained, then I guess I'll just implement another way, no problem.
I just need something check for modifications.

Also, is there a 'long address comunication implementation'?
I expect to have a 64bit address to use as an unvariable ID but to be able to change PAN_ID and SHORT_ADDRESS on the nodes by my application.
Haven't found that yet.

Also, in the wibo.(txt/pdf) says the the bootloader application and wibohost application must be the same.
That means that the bootloader can only program wireless nodes on it's same pan_id, am I right?
Is this a restriction on the uracoli 'API' or only in the WiBo?
Easily expandable to use any pan_id or not so trivial?



On Mon, Dec 22, 2014 at 4:10 PM, Axel Wachtler <address@hidden> wrote:
Hi Tomás,


not sure how far SERIALDEBUG still works. This was just a vehicle when
bringing up the Wibo itself.

Before changing the code, you should just try the example given
uracoli-src-0.4.2/doc/wibo.(txt,pdf) - if this is not working, we
still can spent time to debug ;-) ... which is hopefully not needed.

Best, Axel.






Am 22.12.2014 um 16:58 schrieb Tomás Glaria:
Well I got it to work a lot easier with the updated code (I now remember
that I chose the one I was using because it had the 'sparkfun board'
defined and I was using one just like it, but then I just 'made' my own
so don't need it anymore).

So now the high speed works without problem (I'm testing with 500kbps)
on the wibhost app.
I compile, flash and check the input on console "WIBO Host <Build xxxxxx>"

I try the same thing with "wibo" application, for the wireless nodes but
can't get any serial communication with the stock code.
I (obviously) changed the SERIALDEBUG define to 1.

First of all, I don't find any initialization for the UART, so I added
the initialization before printing (line around 300)
#if SERIALDEBUG > 0
hif_init(HIF_DEFAULT_BAUDRATE);   // ------------------> This is new
stdout = stderr = &usart0_stdio;
puts("WIBO Bootlapp Serial Debug");
printf("PANID: %04X SHORTADDR: %04X CHANNEL: %d\n",
nodeconfig.pan_id, nodeconfig.short_addr, nodeconfig.channel);
#endif

Also, the fputc() declaration does nothing on my code.
The original is:
int putc(int c, FILE *stream)
{
// HIF_UART_DATA = c;
return c;
}

I changed it to:
int putc(int c, FILE *stream)
{
if(c == '\n')
{
putc('\r', 0);
}
while(!(UCSR0A&(1<<UDRE0))){};//wait while previous byte is completed
UDR0 = c;   // Transmit data
return c;
}

I guess it should work with only
int putc(int c, FILE *stream)
{
HIF_UART_DATA = c;
return c;
}
but that gave me an error, HIF_UART_DATA not defined. I know it is in
hif_uart.h (line 61 for ATmegaRFA1) but isn't found during compilation
for me.
I could use just
int putc(int c, FILE *stream)
{
UDR0 = c;
return c;
}
but I've already tested the longer code and has worked so far.

I guess (for now) I only have one question, why can't my compiler find
the definition of HIF_UART_DATA?


Thanks for everything!


On Mon, Dec 22, 2014 at 10:28 AM, Axel Wachtler <address@hidden
<mailto:address@hidden>> wrote:

    ¡Mucha
    <http://dict.leo.org/esde/index_de.html#/search=%C2%A1Mucha&searchLoc=0&resultOrder=basic&multiwordShowSingle=on>
    suerte
    <http://dict.leo.org/esde/index_de.html#/search=suerte&searchLoc=0&resultOrder=basic&multiwordShowSingle=on>!
    con mas preguntas, soy online las proximas dias.
    Hasta luego, Axel..
    *Gesendet:* Montag, 22. Dezember 2014 um 14:10 Uhr
    *Von:* "Tomás Glaria" <address@hidden <mailto:address@hidden>>
    *An:* "Axel Wachtler" <address@hidden
    <mailto:address@hidden>>
    *Cc:* address@hidden <mailto:address@hiddenorg>
    *Betreff:* Re: Re: [uracoli-devel] error in UART baudrate?
    Well forget it, I have no idea where I got my uracoli code.
    It's obviously not the last version of it.
    I'll update and recheck everything.
    Thanks.
    On Mon, Dec 22, 2014 at 10:02 AM, Tomás Glaria <address@hidden
    <http://address@hidden>> wrote:

        I did change those values, but didn't work for me.
        I'll give it another try, maybe I changed something before.
        I'm using 0.4.2
        I'm using git, I guess I'll just download the zip file and see
        if the last version works.
        On Mon, Dec 22, 2014 at 9:56 AM, Axel Wachtler
        <address@hidden <http://address@hidden>> wrote:

            To get a snapshot of the repo, see here:
            http://hg.savannah.gnu.org/hgweb/uracoli/
            Here is the changeset  that fixes the issue:
            http://hg.savannah.gnu.org/hgweb/uracoli/rev/3a2eab26ae97
            but well ... this one was already in 2012 ... which version
            you use?
            Axel.
            *Gesendet:* Montag, 22. Dezember 2014 um 13:27 Uhr
            *Von:* "Tomás Glaria" <address@hidden
            <http://address@hidden>>
            *An:* "Axel Wachtler" <address@hidden
            <http://address@hidden>>
            *Cc:* address@hidden <http://address@hiddenorg>
            *Betreff:* Re: [uracoli-devel] error in UART baudrate?

            I'll try to quote to make it clearly what I'm answering to:

                    Me:
                     >>>The problem lies, according to me, that when you
                    call the macro inside
                    >>>the function, the baudrate variable is a 16bit variable so the value 65535
                    >>>is 0xffff and the value 65536 is 0x0000 (should be 0x10000 but it's truncated)

                Axel:
                 >As for uint16_t br in HIF_UART_INIT: br is not the
                baudrate, br is the
                 >value for the UBRRxH and  UBRRxL register. According
                to the data sheet
                 >the value for UBRR (br) has a range of 0 ... 4095 -
                the higher values it
                 >gets for lower baud rates.

            Me:
            I meant the 'baudrate value', not the 'encoded value'.
            In the code I see:
            #define ENCODE_BAUDRATE(br) ((F_CPU)/((br)*16l)-1)
            inline void HIF_UART_INIT(uint16_t baudrate)
            {
                 uint16_t br;
                 br = ENCODE_BAUDRATE(baudrate);
                 /* Set baud rate */
                 if ( br & 0x8000 )
                 {
                     HIF_UART_STATUS = _BV(U2X0);  //Enable 2x speed
                     br &= ~0x8000;
                 }
                 UBRR1H = (uint8_t)(br>>8);
                 UBRR1L = (uint8_t) br;
            ....
            }
            The second line is the interesting one, the definition on
            the HIF_UART_INIT() function uses an uint16_t variable type.
            Which means that the ENCODE_BAUDRATE(br) macro is using a
            16bit variable as an input.
            When I call the function with the value 0xfffF,
            HIF_UART_INIT(0xffff), I'm actually calling
            the ENCODE_BAUDRATE macro as: ENCODE_BAUDRATE(0xFFFF)
            But when I call the function with the value 0x10000,
            HIF_UART_INIT(0x10000), I'm actually calling
            the ENCODE_BAUDRATE macro as: ENCODE_BAUDRATE(0x0000)
            Am I wrong here?
            (and yes, the br variable inside the HIF_UART_INIT()
            function is the output of the ENCODE_BAUDRATE macre and
            should overflow under any circumstance)
             >I just tried 250kbps/16MHz on Radiofaro - together with a
            python terminal (sterm.py) it worked.
             >However this was with the current Mercurial version, but
            with the last release 0.4.2, I failed the
             >same way like you. (250kbs fit better to the 16MHz).
            Could you give me a link to the mercurial version?
            I might find the differences that are causing the serial
            communication error.
            On Fri, Dec 19, 2014 at 5:31 PM, Axel Wachtler
            <address@hidden <http://address@hidden>> wrote:

                Hi Tomás,

                I just tried 250kbps/16MHz on Radiofaro - together with
                a python terminal (sterm.py) it worked. However this was
                with the current Mercurial version, but with the last
                release 0.4.2, I failed the same way like you. (250kbs
                fit better to the 16MHz).

                I could not yet find the code change that is causing the
                repair,
                some lines in hif_uart.h had changed ... but they need
                some review.

                If you don't want to start with scons, I can roll you a
                package from the current snapshot.

                Next release needs some more time, we added some sensor
                stuff to the
                lib, that is not yet completely documented.

                Cheers, Axel.


                Am 19.12.2014 um 14:13 schrieb Axel Wachtler:

                    Just a short response, ... for testing the UART, you
                    can use xmpl_hif.c,
                    with 16MHz and Megarfa1 the rate 57600bps is proven
                    and tested.
                    Having this running will be a solid starting point
                    before pushing it
                    more to the limit.
                    As for uint16_t br in HIF_UART_INIT: br is not the
                    baudrate, br is the
                    value for the UBRRxH and  UBRRxL register. According
                    to the data sheet
                    the value for UBRR (br) has a range of 0 ... 4095 -
                    the higher values it
                    gets for lower baud rates.
                    In the code the MSB of br is set, if U2X is used,
                    that bit is masked out
                    before writing UBRR.
                    Let's hear, how it goes with the UART and standard
                    baudrates on your
                    project.
                    Cheers, Axel.

        --
        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.



--
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]