I used the comments to the original $TOSDIR/chips/atm128/Atm128UartP.nc
to calculate the m_byte_time for 230400.
----------
command error_t Init.init() {
 if (PLATFORM_BAUDRATE == 19200UL)
   m_byte_time = 200; // 1 TMicor ~= 2.12 us, one byte = 417us ~= 200
 else if (PLATFORM_BAUDRATE == 57600UL)
   m_byte_time = 68;  // 1 TMicor ~= 2.12 us, one byte = 138us ~= 65
----------

For your 1200 bit/s it should be:
 else if (PLATFORM_BAUDRATE == 1200UL)
   m_byte_time = 3145; // 1 TMicor ~= 2.12 us, one byte = 6667us ~= 3145

Best wishes,
Andrey



Li, Zhen Li wrote:
> Hi Andrey:
> 
> Thanks for the help.
> 
> But I'm still a little confused about the bard rate setting stuff.
> 
> Right now I found 4 files maybe related to bardrate setting as: hardware.h, 
> Atm128Uart.h, atm128UartP.nc and HplAtm128UartP.nc.
> 
> The "hardware.h" locates in $TOSDIR/tos/platforms/micaz/, with an enum as: 
> PLATFORM_BAUDRATE = 57600L . Is it the general baudrate for both Uart0 and 
> Uart1? So if I change this value, does it mean that the baudrate for UART1 
> will also be changed?
> 
> The rest of the files located in $TOSDIR/tos/chips/atm128/. In the 
> Atm128Uart.h, there is also an enum which seems to reflect the real baudrate 
> regester's readings but I could not find where this values are used. In the 
> Atm128UartP.nc, there's a command as Init.init and it seems that the baudrate 
> is set roughly there also. And in the HplAtm128UartP.nc, there's a command as 
> Atm128Calibrate.baudrateRegister(PLATFORM_BAUDRATE) called with a returened 
> value as ubrr0. Then the UBRR0L and UBRR0H was renewed according to ubrr0.
> 
> So upon the four areas related to baudrate setting, which should I use?  And 
> can you give me some wiring example about using UART0 to receive bytes no 
> matter what baudrate it is in?
> 
> Thanks!
> 
> Zhen
> 
> 
> ________________________________________
> From: Andrey Gursky [EMAIL PROTECTED]
> Sent: Wednesday, October 15, 2008 12:55 PM
> To: Li, Zhen Li
> Cc: Tinyos-Help
> Subject: Re: [Tinyos-help] How to set baud rate on UART0
> 
> Li, Zhen Li wrote:
>> Hi
>>
>> Does anyone know how to set the baudrate in TinyOS 2.1 for MicaZ's or IRIS's 
>> UART0? I want to set the baudrate to 1200 and I know how to do the baudrate 
>> register's calculation but  don't know where to put those values. Also, how 
>> can I use the UART0 to read some bytes? Can anyone tell me something about 
>> the wiring?
>>
>> Thanks!
> 
> Hi Zhen!
> 
> In $TOSDIR/chips/atm128/HplAtm128UartP.nc there are functions to
> initialize UART0/1. The both use command
> call Atm128Calibrate.baudrateRegister(PLATFORM_BAUDRATE);
> with parameter that is defined in
> $TOSDIR/platforms/micaz/hardware.h
> (I assume IRIS uses also this definition from micaz and not from mica,
> because of the order of includes in $TOSDIR/platforms/iris/.platform)
> So you should alter this parameter only in hardware.h
> 
> In
> $TOSDIR/chips/atm128/Atm128UartP.nc
> the command Init.init()
> should be extended with new PLATFORM_BAUDRATE you want to use and the
> appropriate new calculated value m_byte_time.
> 
> 
> Hope I was not wrong. Best wishes,
> Andrey
> 
> 

_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to