EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Problems with MSP430 as slave in SPI mode

Started by sudhakar_b_v February 25, 2005
I've a dual processor board with NE64 and MSP430F149; they are 
supposed to communicate using SPI, with MSP430 as the slave. The 
Msp430 uses USART1 as the SPI and I programmed the USART1 registers 
for interrupt-enabled SPI communication as an SPI slave (Global 
interrupts are also enabled). However, the MSP430 is never 
interrupted even though the NE64 keeps sending data. I've kept the 
baud rate quite low and for now I'm interested in seeing 
communication being established more than the correctness of the 
data. Where may I've gone wrong? Thank you.

PS - I've also checked the clock(around 7kHz), data and STE(active 
low during data transfers) signals on an oscilloscope and didn't 
notice anything out of place.

Regards,
Sudhakar





Beginning Microcontrollers with the MSP430

--- In msp430@msp4..., "sudhakar_b_v" <venkata.bulusu@h...> 
wrote:
> 
> I've a dual processor board with NE64 and MSP430F149; they are 
> supposed to communicate using SPI, with MSP430 as the slave. The 
> Msp430 uses USART1 as the SPI and I programmed the USART1 registers 
> for interrupt-enabled SPI communication as an SPI slave (Global 
> interrupts are also enabled). However, the MSP430 is never 
> interrupted even though the NE64 keeps sending data. I've kept the 
> baud rate quite low and for now I'm interested in seeing 
> communication being established more than the correctness of the 
> data. Where may I've gone wrong? Thank you.
> 
> PS - I've also checked the clock(around 7kHz), data and STE(active 
> low during data transfers) signals on an oscilloscope and didn't 
> notice anything out of place.
> 
> Regards,
> Sudhakar

The MSP430 is now getting regular interrupts; I had made a small 
error in the code, my apologies. However, each time it's interrupted, 
the data read is 0xFFFF, though the data on the pin seems ok. Any 
help is appreciated. Thank you.

Regards,
Sudhakar 




Have you checked clock phase and polarity configurations, Sudhakar? You 
have to tell MSP in what edge of the clock signal it should sample data.

Regards,
Adriano.

sudhakar_b_v wrote:
> 
> --- In msp430@msp4..., "sudhakar_b_v" <venkata.bulusu@h...>

> wrote:
> 
>>I've a dual processor board with NE64 and MSP430F149; they are 
>>supposed to communicate using SPI, with MSP430 as the slave. The 
>>Msp430 uses USART1 as the SPI and I programmed the USART1 registers 
>>for interrupt-enabled SPI communication as an SPI slave (Global 
>>interrupts are also enabled). However, the MSP430 is never 
>>interrupted even though the NE64 keeps sending data. I've kept the 
>>baud rate quite low and for now I'm interested in seeing 
>>communication being established more than the correctness of the 
>>data. Where may I've gone wrong? Thank you.
>>
>>PS - I've also checked the clock(around 7kHz), data and STE(active 
>>low during data transfers) signals on an oscilloscope and didn't 
>>notice anything out of place.
>>
>>Regards,
>>Sudhakar
> 
> 
> The MSP430 is now getting regular interrupts; I had made a small 
> error in the code, my apologies. However, each time it's interrupted, 
> the data read is 0xFFFF, though the data on the pin seems ok. Any 
> help is appreciated. Thank you.
> 
> Regards,
> Sudhakar 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 

Hi Adriano
Thanks for your reply. Yeah, I've configured the registers so that 
the clock is active high and there's no phase delay. Here's the code -

#define RESET_USART1()    U1CTL |= SWRST
#define RELEASE_USART1()  U1CTL &= ~SWRST
#define ENABLE_SPI1()     ME2 |= USPIE1
#define DISABLE_SPI1()    ME2 &= ~USPIE1
 
char rxBuf;
 
void initSPI1()
{
    WDTCTL = WDTPW+WDTHOLD;
     
    /* Configure port5 */
    P5SEL |= 0x0e;  
    P5DIR |= 0x02;   
    
    U1CTL = SWRST; 
    U1CTL |= CHAR;  // CHAR 8-bit Data
    U1CTL |= SYNC;  // SYNC SPI Mode.
    U1CTL &= ~MM;   // Slave Mode.////
    
    U1TCTL = 0x00; 
    U1RCTL = 0x00;
    
    U1MCTL=0x00;        // This should be zero always.
    
    rxBuf = U1RXBUF;
    
    U1TXBUF = 0x22;
    
    ENABLE_SPI1();
    RELEASE_USART1();
 
    IE2 |= URXIE1+UTXIE1;
    
    for(i=0xfff;i>0;i--);
    {
    }
    
    _EINT();
}



--- In msp430@msp4..., Adriano <adriano@n...> wrote:
> 
> Have you checked clock phase and polarity configurations, Sudhakar? 
You 
> have to tell MSP in what edge of the clock signal
it should sample 
data.
> 
> Regards,
> Adriano.
> 
> sudhakar_b_v wrote:
> > 
> > --- In msp430@msp4..., "sudhakar_b_v" 
<venkata.bulusu@h...> 
> > wrote:
> > 
> >>I've a dual processor board with NE64 and MSP430F149; they are

> >>supposed to communicate using SPI, with MSP430 as the slave. The 
> >>Msp430 uses USART1 as the SPI and I programmed the USART1 
registers 
> >>for interrupt-enabled SPI communication as
an SPI slave (Global 
> >>interrupts are also enabled). However, the MSP430 is never 
> >>interrupted even though the NE64 keeps sending data. I've kept

the 
> >>baud rate quite low and for now I'm
interested in seeing 
> >>communication being established more than the correctness of the 
> >>data. Where may I've gone wrong? Thank you.
> >>
> >>PS - I've also checked the clock(around 7kHz), data and STE
(active 
> >>low during data transfers) signals on an
oscilloscope and didn't 
> >>notice anything out of place.
> >>
> >>Regards,
> >>Sudhakar
> > 
> > 
> > The MSP430 is now getting regular interrupts; I had made a small 
> > error in the code, my apologies. However, each time it's 
interrupted, 
> > the data read is 0xFFFF, though the data on
the pin seems ok. Any 
> > help is appreciated. Thank you.
> > 
> > Regards,
> > Sudhakar 
> > 
> > 
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> >




Your procedure is ok, Sudhakar, but it seems that you have configured 
UCLK1 pin as output. As the MSP is a slave, it must be an input. Maybe 
that can solve your problem.

Regards,
Adriano.

sudhakar_b_v wrote:
> 
> Hi Adriano
> Thanks for your reply. Yeah, I've configured the registers so that 
> the clock is active high and there's no phase delay. Here's the
code -
> 
> #define RESET_USART1()    U1CTL |= SWRST
> #define RELEASE_USART1()  U1CTL &= ~SWRST
> #define ENABLE_SPI1()     ME2 |= USPIE1
> #define DISABLE_SPI1()    ME2 &= ~USPIE1
>  
> char rxBuf;
>  
> void initSPI1()
> {
>     WDTCTL = WDTPW+WDTHOLD;
>      
>     /* Configure port5 */
>     P5SEL |= 0x0e;  
>     P5DIR |= 0x02;   
>     
>     U1CTL = SWRST; 
>     U1CTL |= CHAR;  // CHAR 8-bit Data
>     U1CTL |= SYNC;  // SYNC SPI Mode.
>     U1CTL &= ~MM;   // Slave Mode.////
>     
>     U1TCTL = 0x00; 
>     U1RCTL = 0x00;
>     
>     U1MCTL=0x00;        // This should be zero always.
>     
>     rxBuf = U1RXBUF;
>     
>     U1TXBUF = 0x22;
>     
>     ENABLE_SPI1();
>     RELEASE_USART1();
>  
>     IE2 |= URXIE1+UTXIE1;
>     
>     for(i=0xfff;i>0;i--);
>     {
>     }
>     
>     _EINT();
> }
> 
> 
> 
> --- In msp430@msp4..., Adriano <adriano@n...> wrote:
> 
>>Have you checked clock phase and polarity configurations, Sudhakar? 
> 
> You 
> 
>>have to tell MSP in what edge of the clock signal it should sample 
> 
> data.
> 
>>Regards,
>>Adriano.
>>
>>sudhakar_b_v wrote:
>>
>>>--- In msp430@msp4..., "sudhakar_b_v" 
> 
> <venkata.bulusu@h...> 
> 
>>>wrote:
>>>
>>>
>>>>I've a dual processor board with NE64 and MSP430F149; they
are 
>>>>supposed to communicate using SPI, with MSP430 as the slave. The

>>>>Msp430 uses USART1 as the SPI and I programmed the USART1 
> 
> registers 
> 
>>>>for interrupt-enabled SPI communication as an SPI slave (Global 
>>>>interrupts are also enabled). However, the MSP430 is never 
>>>>interrupted even though the NE64 keeps sending data. I've
kept 
> 
> the 
> 
>>>>baud rate quite low and for now I'm interested in seeing 
>>>>communication being established more than the correctness of the

>>>>data. Where may I've gone wrong? Thank you.
>>>>
>>>>PS - I've also checked the clock(around 7kHz), data and STE
> 
> (active 
> 
>>>>low during data transfers) signals on an oscilloscope and
didn't 
>>>>notice anything out of place.
>>>>
>>>>Regards,
>>>>Sudhakar
>>>
>>>
>>>The MSP430 is now getting regular interrupts; I had made a small 
>>>error in the code, my apologies. However, each time it's 
> 
> interrupted, 
> 
>>>the data read is 0xFFFF, though the data on the pin seems ok. Any 
>>>help is appreciated. Thank you.
>>>
>>>Regards,
>>>Sudhakar 
>>>
>>>
>>>
>>>
>>>
>>>.
>>>
>>> 
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>> 
>>>
>>>
>>>
> 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 

Yeah, the port settings were improper, but I corrected them later to
no effect. Thanks, anyway for your help.

Regards,
Sudhakar

--- In msp430@msp4..., Adriano <adriano@n...> wrote:
> 
> Your procedure is ok, Sudhakar, but it seems that you have configured 
> UCLK1 pin as output. As the MSP is a slave, it must be an input. Maybe 
> that can solve your problem.
> 
> Regards,
> Adriano.
> 
> sudhakar_b_v wrote:
> > 
> > Hi Adriano
> > Thanks for your reply. Yeah, I've configured the registers so
that 
> > the clock is active high and there's no phase delay. Here's
the code -
> > 
> > #define RESET_USART1()    U1CTL |= SWRST
> > #define RELEASE_USART1()  U1CTL &= ~SWRST
> > #define ENABLE_SPI1()     ME2 |= USPIE1
> > #define DISABLE_SPI1()    ME2 &= ~USPIE1
> >  
> > char rxBuf;
> >  
> > void initSPI1()
> > {
> >     WDTCTL = WDTPW+WDTHOLD;
> >      
> >     /* Configure port5 */
> >     P5SEL |= 0x0e;  
> >     P5DIR |= 0x02;   
> >     
> >     U1CTL = SWRST; 
> >     U1CTL |= CHAR;  // CHAR 8-bit Data
> >     U1CTL |= SYNC;  // SYNC SPI Mode.
> >     U1CTL &= ~MM;   // Slave Mode.////
> >     
> >     U1TCTL = 0x00; 
> >     U1RCTL = 0x00;
> >     
> >     U1MCTL=0x00;        // This should be zero always.
> >     
> >     rxBuf = U1RXBUF;
> >     
> >     U1TXBUF = 0x22;
> >     
> >     ENABLE_SPI1();
> >     RELEASE_USART1();
> >  
> >     IE2 |= URXIE1+UTXIE1;
> >     
> >     for(i=0xfff;i>0;i--);
> >     {
> >     }
> >     
> >     _EINT();
> > }
> > 
> > 
> > 
> > --- In msp430@msp4..., Adriano <adriano@n...> wrote:
> > 
> >>Have you checked clock phase and polarity configurations, Sudhakar?

> > 
> > You 
> > 
> >>have to tell MSP in what edge of the clock signal it should sample 
> > 
> > data.
> > 
> >>Regards,
> >>Adriano.
> >>
> >>sudhakar_b_v wrote:
> >>
> >>>--- In msp430@msp4..., "sudhakar_b_v" 
> > 
> > <venkata.bulusu@h...> 
> > 
> >>>wrote:
> >>>
> >>>
> >>>>I've a dual processor board with NE64 and MSP430F149;
they are 
> >>>>supposed to communicate using SPI, with MSP430 as the
slave. The 
> >>>>Msp430 uses USART1 as the SPI and I programmed the USART1 
> > 
> > registers 
> > 
> >>>>for interrupt-enabled SPI communication as an SPI slave
(Global 
> >>>>interrupts are also enabled). However, the MSP430 is never 
> >>>>interrupted even though the NE64 keeps sending data.
I've kept 
> > 
> > the 
> > 
> >>>>baud rate quite low and for now I'm interested in
seeing 
> >>>>communication being established more than the correctness
of the 
> >>>>data. Where may I've gone wrong? Thank you.
> >>>>
> >>>>PS - I've also checked the clock(around 7kHz), data
and STE
> > 
> > (active 
> > 
> >>>>low during data transfers) signals on an oscilloscope and
didn't 
> >>>>notice anything out of place.
> >>>>
> >>>>Regards,
> >>>>Sudhakar
> >>>
> >>>
> >>>The MSP430 is now getting regular interrupts; I had made a
small 
> >>>error in the code, my apologies. However, each time it's 
> > 
> > interrupted, 
> > 
> >>>the data read is 0xFFFF, though the data on the pin seems ok.
Any 
> >>>help is appreciated. Thank you.
> >>>
> >>>Regards,
> >>>Sudhakar 
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>.
> >>>
> >>> 
> >>>Yahoo! Groups Links
> >>>
> >>>
> >>>
> >>> 
> >>>
> >>>
> >>>
> > 
> > 
> > 
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> >





The 2024 Embedded Online Conference