EmbeddedRelated.com
Forums

Discontinuties in SPI transmission

Started by frb78 June 24, 2004
Hi,
I'm currently designing a little RF transceiver and I have a little 
probleme with SPI transmission. I try to sent many consecutive 8 bit 
words to a device but between each transmission of the U0TXBUF (8 
bit), a delay of about 2 cycle clock [@ baud rate, which is very slow 
(8khz) compare to the MCLK (750khz)] occurs. I use interrupt from 
USART0TX_VECTOR to refresh the U0TXBUF. Can someone explain this?

P.S. I included my code below (I use MSPGCC)

--------------
#include <signal.h>
#include <msp430x14x.h>

int main(void){

  // Stop watchdog timer
  WDTCTL = WDTPW + WDTHOLD;

  // Set Basic Clock Module
  DCOCTL = DCO0 + DCO1;
  BCSCTL1 = XT2OFF + DIVA_0 + RSEL2;
  BCSCTL2 = 0x00;

  // Output MCLK to pin 48
  P5DIR = 0x10;
  P5SEL = 0x10;

  // Set USART0 - 3-pin SPI mode
  P3SEL = 0x0E;
  P3DIR = 0x0A;
  U0CTL = SWRST;
  U0CTL = SWRST + CHAR + SYNC + MM;  // Master SPI mode
  U0TCTL = SSEL0 + STC;              // ACLK and 3-pin mode
  U0BR0 = 0x04;                      // Baud rate = 8192
  U0BR1 = 0x00;
  U0MCTL = 0x00;

  // Enable the SPI port and interrupt
  ME1 = USPIE0;
  U0CTL &= 0xFE;
  IE1 = UTXIE0;
  _EINT();

  // Start transmission
  U0TXBUF = 0xAA;

  while(1){}

  return 0;

}

interrupt(UART0TX_VECTOR) transmit(void){
  U0TXBUF = 0xAA;
}
----------------------


Beginning Microcontrollers with the MSP430

Hi frb78,

I'm afraid you can't send or receive continuous bit streams with SPI. 
There will always be a "gap" between consecutive bytes (but I only 
measured 1 bit period).
It's a hardware "feature", at least on an 'F148 -
didn't try others, 
but I think all MSP USARTs are the same.
See also:
http://groups.yahoo.com/group/msp430/message/4321

Wolfgang


--- In msp430@msp4..., "frb78" <Frb78@y...> wrote:
> Hi,
> I'm currently designing a little RF transceiver and I have a little 
> probleme with SPI transmission. I try to sent many consecutive 8 
bit 
> words to a device but between each transmission of
the U0TXBUF (8 
> bit), a delay of about 2 cycle clock [@ baud rate, which is very 
slow 
> (8khz) compare to the MCLK (750khz)] occurs. I use
interrupt from 
> USART0TX_VECTOR to refresh the U0TXBUF. Can someone explain this?
> 
> P.S. I included my code below (I use MSPGCC)
> 
> --------------
> #include <signal.h>
> #include <msp430x14x.h>
> 
> int main(void){
> 
>   // Stop watchdog timer
>   WDTCTL = WDTPW + WDTHOLD;
> 
>   // Set Basic Clock Module
>   DCOCTL = DCO0 + DCO1;
>   BCSCTL1 = XT2OFF + DIVA_0 + RSEL2;
>   BCSCTL2 = 0x00;
> 
>   // Output MCLK to pin 48
>   P5DIR = 0x10;
>   P5SEL = 0x10;
> 
>   // Set USART0 - 3-pin SPI mode
>   P3SEL = 0x0E;
>   P3DIR = 0x0A;
>   U0CTL = SWRST;
>   U0CTL = SWRST + CHAR + SYNC + MM;  // Master SPI mode
>   U0TCTL = SSEL0 + STC;              // ACLK and 3-pin mode
>   U0BR0 = 0x04;                      // Baud rate = 8192
>   U0BR1 = 0x00;
>   U0MCTL = 0x00;
> 
>   // Enable the SPI port and interrupt
>   ME1 = USPIE0;
>   U0CTL &= 0xFE;
>   IE1 = UTXIE0;
>   _EINT();
> 
>   // Start transmission
>   U0TXBUF = 0xAA;
> 
>   while(1){}
> 
>   return 0;
> 
> }
> 
> interrupt(UART0TX_VECTOR) transmit(void){
>   U0TXBUF = 0xAA;
> }
> ----------------------


Hi,

i have measured the transfer rate of MMCs/SDCs connected via SPI at 4 MHz and
got only 30 kByte/s - much less then the limit of 500 kByte/s (=4 Mio Bit/s).

But you can do transmission without gaps with other busses, e. g. I2S, but i
only have seen them with an hardware interface and  DMA.

Rolf


msp430@msp4... schrieb am 25.06.04 10:28:30:
> 
> Hi frb78,
> 
> I'm afraid you can't send or receive continuous bit streams with
SPI. 
> There will always be a "gap" between consecutive bytes (but I
only 
> measured 1 bit period).
> It's a hardware "feature", at least on an 'F148 -
didn't try others, 
> but I think all MSP USARTs are the same.
> See also:
> http://groups.yahoo.com/group/msp430/message/4321
> 
> Wolfgang
> 
> 
> --- In msp430@msp4..., "frb78" <Frb78@y...> wrote:
> > Hi,
> > I'm currently designing a little RF transceiver and I have a
little 
> > probleme with SPI transmission. I try to sent many consecutive 8 
> bit 
> > words to a device but between each transmission of the U0TXBUF (8 
> > bit), a delay of about 2 cycle clock [@ baud rate, which is very 
> slow 
> > (8khz) compare to the MCLK (750khz)] occurs. I use interrupt from 
> > USART0TX_VECTOR to refresh the U0TXBUF. Can someone explain this?
> > 
> > P.S. I included my code below (I use MSPGCC)
> > 
> > --------------
> > #include <signal.h>
> > #include <msp430x14x.h>
> > 
> > int main(void){
> > 
> >   // Stop watchdog timer
> >   WDTCTL = WDTPW + WDTHOLD;
> > 
> >   // Set Basic Clock Module
> >   DCOCTL = DCO0 + DCO1;
> >   BCSCTL1 = XT2OFF + DIVA_0 + RSEL2;
> >   BCSCTL2 = 0x00;
> > 
> >   // Output MCLK to pin 48
> >   P5DIR = 0x10;
> >   P5SEL = 0x10;
> > 
> >   // Set USART0 - 3-pin SPI mode
> >   P3SEL = 0x0E;
> >   P3DIR = 0x0A;
> >   U0CTL = SWRST;
> >   U0CTL = SWRST + CHAR + SYNC + MM;  // Master SPI mode
> >   U0TCTL = SSEL0 + STC;              // ACLK and 3-pin mode
> >   U0BR0 = 0x04;                      // Baud rate = 8192
> >   U0BR1 = 0x00;
> >   U0MCTL = 0x00;
> > 
> >   // Enable the SPI port and interrupt
> >   ME1 = USPIE0;
> >   U0CTL &= 0xFE;
> >   IE1 = UTXIE0;
> >   _EINT();
> > 
> >   // Start transmission
> >   U0TXBUF = 0xAA;
> > 
> >   while(1){}
> > 
> >   return 0;
> > 
> > }
> > 
> > interrupt(UART0TX_VECTOR) transmit(void){
> >   U0TXBUF = 0xAA;
> > }
> > ----------------------
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
>