Ah, good catch. How about the following fix? 0.) In HplAtml128UartP.nc, make TXCIE off but TXEN on by default in stdcontrol. 1.) In HplAtml128UartP.nc, fix enableTxIntr and disableTxIntr to control TXCIE rather than TXEN (This should leave no interface changes). 2.) In Atm128UartP, UARTStream should call enableTxIntr() and disableTxIntr() when done rather than having UARTByte doing it byte-by-byte. (amortize the overhead over multiple bytes)
Jeff, thanks for bringing this up. :) alec -----Original Message----- From: Philip Levis [mailto:[EMAIL PROTECTED] Sent: Thursday, December 07, 2006 2:06 PM To: Jeff King; Alec Woo; Jonathan Hui Cc: TinyOS help Subject: Re: [Tinyos-help] UartByte.send locks up? On Dec 7, 2006, at 1:52 PM, Jeff King wrote: > Jeff King wrote: >> Has anyone tried using the new UartByte interface in the TinyOS >> 2.0 release? Sending and receiving serial data using UartStream >> works fine, but the blocking UartByte.send never unblocks: > > I've tracked this down to two problems. First, the TXCIE (TX > Complete Interrupt Enable) bit in UCSRnB needs to disabled before > UartByte.send() calls HplUart.tx() (and can be re-enabled before > send() returns). However, the second problem is that the > enableTxIntr() and disableTxIntr() commands implemented in > HplAtm128UartP.nc don't set the TXCIE bit, but rather the TXEN > (Transmitter Enable). When TXCIE is disabled, data can still be > transmitted, but no interrupt occurs onces the transmission > completes. When TXEN is disabled, nothing can transmit at all. > > My solution was to add the following in the uart interface (/tos/ > chips/atm128/HplAtm128Uart.nc) > async command error_t enableTxCIE(); > async command error_t disableTxCIE(); > > Implementing the new commands in /tos/chips/atm128/HplArm128UartP.nc: > async command error_t HplUart0.enableTxCIE() { > SET_BIT(UCSR0B, TXCIE); > return SUCCESS; > } > > async command error_t HplUart0.disableTxCIE() { > CLR_BIT(UCSR0B, TXCIE); > return SUCCESS; > } > > async command error_t HplUart1.enableTxCIE() { > SET_BIT(UCSR1B, TXCIE); > return SUCCESS; > } > > async command error_t HplUart1.disableTxCIE() { > CLR_BIT(UCSR1B, TXCIE); > return SUCCESS; > } > > And then calling the new commands in the UartByte.send() > implementation in /tos/chips/atm128/Atm128UartP.nc: > > async command error_t UartByte.send( uint8_t byte ){ > call HplUart.disableTxCIE(); > call HplUart.tx( byte ); > while ( !call HplUart.isTxEmpty() ); > call HplUart.enableTxCIE(); > return SUCCESS; > } > _____ Alec, Jonathan, can you verify this? Phil _______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
