[Tinyos-devel] Msp430SpiNoDmaP.nc bug ?

Grégoire Menuel gregoire.menuel at gmail.com
Wed Oct 31 05:23:22 PDT 2007

Hi !
I'm new with TinyOS (and also with embedded development) so what I
will be saying may be inaccurate.

I'm not sure I understand how the continueOp function in
Msp430SpiNoDmaP.nc works.

According to the code TinyOS send the first byte on the Usart port,
then send another, and only then read the response on the Usart port.
Won't we lose the response to the first sent byte ? Shouldn't we do a
Usart.rx() before sending another byte ?

When using the TinyOS code and trying to read from the SPI port using
the SpiPacket interface I only get one character over two, and this
one is present in double (for example if I should read ABCD from the
SPI port I will get BBDD). I'm not working on an actual platform but
on a simulator of the platform, so maybe there is a bug in a

However the following patch seems to fix the behaviour :

cvs diff: Diffing .
Index: Msp430SpiNoDmaP.nc
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Msp430SpiNoDmaP.nc,v
retrieving revision 1.4
diff -u -r1.4 Msp430SpiNoDmaP.nc
--- Msp430SpiNoDmaP.nc  12 Dec 2006 18:23:11 -0000      1.4
+++ Msp430SpiNoDmaP.nc  31 Oct 2007 12:17:43 -0000
@@ -132,12 +132,12 @@
       while ( ++m_pos < end ) {
         while( !call Usart.isTxIntrPending() );
         call Usart.clrTxIntr();
-        call Usart.tx( m_tx_buf ? m_tx_buf[ m_pos ] : 0 );
         while( !call Usart.isRxIntrPending() );
         call Usart.clrRxIntr();
         tmp = call Usart.rx();
         if ( m_rx_buf )
           m_rx_buf[ m_pos - 1 ] = tmp;
+      call Usart.tx( m_tx_buf ? m_tx_buf[ m_pos ] : 0 );

Does this patch seem correct ?

Grégoire Menuel
Jabber : omega at im.apinc.org
Clé GPG : 1024D/D3BF3B20

More information about the Tinyos-devel mailing list