[Tinyos-devel] Proposal for a change to the HplMsp430Usart.nc interface
Eric Decker
cire831 at gmail.com
Thu May 29 17:45:04 PDT 2008
And corresponding Private files.
Background: The MamMark marine tag is close to a TelosB platform. One of
the differences is the addition of a GPS, direct connect serial port, Radio,
and SD (mass storage) all sitting on USART 1.
Primarily the GPS runs at 115200 using the SiRF binary protocol. Under
certain circumstances (we run out of power, we have a solar cell so it can
come back) the GPS will revert to NMEA at 4800.
Bottom line is I need to change baud rate. I could have two different
configurations (although the only difference is the UBR and UMCTL fields)
and rearbitrate but that seems cumbersome. Another way is to call the UART
configurator directly with the different configuration. But that too seems
odd when all I want to do is hit the UBR and UMCTL registers.with a
different configuration (somewhat wasteful).
I could call Usart.setUbr and Usart.setMctl directly but there is a problem
with this. It turns out that just changing the registers doesn't actually
change what the h/w does. For the change to take effect the USART has to be
reset (SWRST -> 1 -> 0). This also has the side effect of disabling
interrupts for the USART (IEx is modified). In other words if setUbr and/or
setUmctl are used you definitely had better know what the chip is going to
do (a reasonable assumption given the low level wacking). Using the
sequence setUbr, setMctl, resetUsart(TRUE), resetUsart(FALSE) doesn't work
because resetUsart(TRUE) loses any mode bits previously set (it forces U1CTL
= SWRST).
So what I'd propose is the following:
1) add setBaud(uint16_t ubr, uint8_t umctl) to the interface.
2) Usart.setBaud does the following:
async command void Usart.setBaud(uint16_t ubr, uint8_t umctl) {
atomic {
U1CTL |= SWRST;
U1BR0 = ubr & 0x00FF;
U1BR1 = (ubr >> 8) & 0x00FF;
U1MCTL = umctl;
CLR_FLAG(U1CTL, SWRST);
}
}
It encapsulates the chip needing a reset with out changing any of its modes.
(Usart.resetUsart(TRUE) explicitly sets U1CTL = SWRST which wipes the
mode).
Note the caller of Usart.setBaud needs to call Usart.enableIntr to reenable
for whatever they are doing if desired.
If setBaud is added I would deprecate setUbr and setMctl. setBaud is easier
to use.
I know there are approaches using the existing Msp430 core to make this
work. I think this is cleaner and easier to use. So I thought I'd put it
out there.
thoughts,
eric
--
Eric B. Decker
Senior (over 50 :-) Researcher
Autonomous Systems Lab
Jack Baskin School of Engineering
UCSC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-devel/attachments/20080529/46ad2ec5/attachment.htm
More information about the Tinyos-devel
mailing list