EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #240 background imageLoading...
Page #240 background image
240
while(UCA0STAT & UCBUSY);
}
unsigned char SPI_read(void)
{
unsigned char rx_data = 0;
while(!(IFG2 & UCA0RXIFG));
rx_data = UCA0RXBUF;
while(UCA0STAT & UCBUSY);
return rx_data;
}
unsigned char SPI_transfer(unsigned char tx_data)
{
unsigned char rx_data = 0;
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = tx_data;
while(UCA0STAT & UCBUSY);
while(!(IFG2 & UCA0RXIFG));
rx_data = UCA0RXBUF;
while(UCA0STAT & UCBUSY);
return rx_data;
}
The SPI read and write processes are simplest to understand. Before starting communication,
respective data transaction interrupt flags are polled. Note that these flags are needed even if we
don’t use USCI interrupts. Once polled okay, data is sent from MSP430 device in SPI write mode or
received while in read mode. Then we have to check if data has been fully received/transmitted by
asserting the USCI busy flag. Lastly the USCI SPI transfer function is a mixture of both SPI read and
write functions.
The code here is used to read a MPL115A1 barometric pressure sensor and display atmospheric
pressure-temperature data. MPL115A1 uses full-duplex SPI communication medium to communicate
with its host device and here MSP430’s USCI_A0 in SPI mode is employed to achieved that.

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals