[Tinyos-help] Tmote UART0 RX?

Ronald Peterson rapjr at cs.dartmouth.edu
Tue Aug 8 18:42:29 PDT 2006


I have it working.  There were several things needed:

    * Make the POT_SHDN/UART0 pin an input using
"TOSH_MAKE_AD524X_SD_INPUT();" (needed since I am
using an Invent which already uses pin 33 of the msp430
for the POT_SHDN line.  This also makes the accelerometer
and light sensor unusable while serial data is being
received by the Invent, but if you time things right they
may still be usable.)
    * In ResourceCmd.granted() enable Rx interrupts with
UartControl.enableRxIntr().
    * I then loop looking for the first byte of GPS data:
     while(data != '$') {
       data = call UartControl.rx();
     }
This is nonblocking read so it will often return the same
byte 20 or 30 times in a row, and can't be used to actually
read the serial data.
    * When I find the start byte, I exit ResourceCmd.granted()
WITHOUT releasing the resource.
    * Implement an event handler:
      interface HPLUSARTFeedback as UartFeedback;
      async event result_t UartFeedback.rxDone(uint8_t rxdata) { }
This gets called when an interrupt is generated for each
character received.  Concatenate the bytes to form a string.
    * When I've received all the bytes I want, release the
resource.  Since the GPS sends data every two seconds, this
could leave enough time to send radio messages.  You could
also call TOSH_MAKE_AD524X_SD_OUTPUT() now if you want to
immediately try to the read the photodiode or accelerometers.

    Ron


Joe Polastre wrote:
> Hi Ron,
> 
>  First of all, SP only controls UART1 which is connected to USB.
> 
>  For UART0, you should check out our support page:
> http://www.moteiv.com/community/Boomerang_UART0_Sample
> 
>  Once you acquire the resource, where it says "do work here", you can
> read and write bytes to and from HPLUSART0.
> 
> -Joe
> 
> On 8/2/06, Ronald Peterson <rapjr at lux.cs.dartmouth.edu> wrote:
> 
>>
>> Hi,
>>
>>    I'm looking for an example of -reading- data from
>> the Tmote (Sky or Invent) UART0 serial port.  I found the
>> code that writes to it, but after looking through the SP
>> source, UART0 components, and trying a variety of experiments
>> I can't seem to read any bytes.  Is bus arbitration required
>> for reading?
>>
>>    Ron
>>
>> _______________________________________________
>> Tinyos-help mailing list
>> Tinyos-help at Millennium.Berkeley.EDU
>> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
> 



More information about the Tinyos-help mailing list