EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

SPI and UART simultaneously

Started by linked82 May 6, 2007
Hi guys,

It's sunday and I'm experiencing my first problems with mixing SPI and
UART in the MSP430F135 chip. My circuit have this micro connected to a
DAC (SPI) and RS232 (UART) in the port 3. Same device (USART0) but
different pins, so no problem in theoy. When I went to the practice, I
wrote my program and discovered that the data that was sent to the SPI
pins, also was send to the UART pins, even being different pins. I've
not checked the reciprocal case. Any clue about how to avoid this issue?

Thanks in advance.

PD: I've tried to disable the UART in the P3SEL bits 4 & 5 pins but
this is not very professional, because the line goes down and a break
condition appears if I don't pull the P3OUT bit 4... :-S

Beginning Microcontrollers with the MSP430

Rather Sunday than Monday. Using the P3SEL bits for switching the
functions between the port pins is ok, remembering to set the
appropriate P3OUT and P3DIR bits somewhere in the previous
initialisation. Here's an example for the UART Tx.

/*
* Pin Port Function Type Special Functions
* 28 P3.0 STE0 i/o Slave transmit enable - USART0/SPI mode
* 29 P3.1 SIMO0 i/o Slave in/master out - USART0/SPI mode
* 30 P3.2 SOMI0 i/o Slave out/master in - USART0/SPI mode
* 31 P3.3 UCLK0 i/o USART0 clock: external input -
UART or SPI mode, output - SPI mode
* 32 P3.4 UTXD0 i/o Transmit data out - USART0/UART mode
* 33 P3.5 URXD0 i/o Receive data in - USART0/UART mode
* 34 P3.6 UTXD1 i/o Transmit data out - USART1/UART mode
* 35 P3.7 URXD1 i/o Receive data in - USART1/UART mode
*/

eg:
// Uart init, force mark ('1') when Uart disconnected from pins
P3OUT |= ( UTXD1_PIN );
P3DIR &= ~( UTXD1_PIN );
...
// Disconnect hardware UART Rx & Tx pins to physical port pins
P3SEL &= ~( UTXD1_PIN );
...
// Connect up hardware SPI Rx & Tx pins to physical port pins
P3SEL |= ( STXD1_PIN );
...

Hugh

At 11:40 AM 5/6/2007, you wrote:
Hi guys,

It's sunday and I'm experiencing my first problems with mixing SPI and
UART in the MSP430F135 chip. My circuit have this micro connected to a
DAC (SPI) and RS232 (UART) in the port 3. Same device (USART0) but
different pins, so no problem in theoy. When I went to the practice, I
wrote my program and discovered that the data that was sent to the SPI
pins, also was send to the UART pins, even being different pins. I've
not checked the reciprocal case. Any clue about how to avoid this issue?

Thanks in advance.

PD: I've tried to disable the UART in the P3SEL bits 4 & 5 pins but
this is not very professional, because the line goes down and a break
condition appears if I don't pull the P3OUT bit 4... :-S
You cannot use the same USART for SPI and UART at the same time,
according to the user's guide. Your chip has only one USART, so you
could switch between both modes.

Regards,
Adriano.

Hugh Molesworth wrote:

> Rather Sunday than Monday. Using the P3SEL bits for switching the
> functions between the port pins is ok, remembering to set the
> appropriate P3OUT and P3DIR bits somewhere in the previous
> initialisation. Here's an example for the UART Tx.
>
> /*
> * Pin Port Function Type Special Functions
> * 28 P3.0 STE0 i/o Slave transmit enable - USART0/SPI mode
> * 29 P3.1 SIMO0 i/o Slave in/master out - USART0/SPI mode
> * 30 P3.2 SOMI0 i/o Slave out/master in - USART0/SPI mode
> * 31 P3.3 UCLK0 i/o USART0 clock: external input -
> UART or SPI mode, output - SPI mode
> * 32 P3.4 UTXD0 i/o Transmit data out - USART0/UART mode
> * 33 P3.5 URXD0 i/o Receive data in - USART0/UART mode
> * 34 P3.6 UTXD1 i/o Transmit data out - USART1/UART mode
> * 35 P3.7 URXD1 i/o Receive data in - USART1/UART mode
> */
>
> eg:
> // Uart init, force mark ('1') when Uart disconnected from pins
> P3OUT |= ( UTXD1_PIN );
> P3DIR &= ~( UTXD1_PIN );
> ...
> // Disconnect hardware UART Rx & Tx pins to physical port pins
> P3SEL &= ~( UTXD1_PIN );
> ...
> // Connect up hardware SPI Rx & Tx pins to physical port pins
> P3SEL |= ( STXD1_PIN );
> ...
>
> Hugh
>
> At 11:40 AM 5/6/2007, you wrote:
> Hi guys,
>
> It's sunday and I'm experiencing my first problems with mixing SPI and
> UART in the MSP430F135 chip. My circuit have this micro connected to a
> DAC (SPI) and RS232 (UART) in the port 3. Same device (USART0) but
> different pins, so no problem in theoy. When I went to the practice, I
> wrote my program and discovered that the data that was sent to the SPI
> pins, also was send to the UART pins, even being different pins. I've
> not checked the reciprocal case. Any clue about how to avoid this issue?
>
> Thanks in advance.
>
> PD: I've tried to disable the UART in the P3SEL bits 4 & 5 pins but
> this is not very professional, because the line goes down and a break
> condition appears if I don't pull the P3OUT bit 4... :-S
> --
> Esta mensagem foi verificada pelo sistema de antivus e
> acredita-se estar livre de perigo.

--

Esta mensagem foi verificada pelo sistema de antivus e

acredita-se estar livre de perigo.
I suppose you know that to go between SPI and UART mode you have to
completely reconfigure the USART...

If you've done that, and the data is going to the wrong pins, then the
question is - how would you know? Surely as part of the change of
function you'd want to put the pins in IO mode and set them to whatever
looks like "quiet"

David

The 2024 Embedded Online Conference