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 #224 background imageLoading...
Page #224 background image
224
/* Disable USI */
USICTL0 |= USISWRST;
/*
* USI Control Register 0
*
* ~USIPE7 -- USI function disabled
* USIPE6 -- USI function enabled
* USIPE5 -- USI function enabled
* ~USILSB -- MSB first
* USIMST -- Master mode
* ~USIGE -- Output latch enable depends on shift clock
* USIOE -- Output enabled
* USISWRST -- USI logic held in reset state
*
* Note: ~<BIT> indicates that <BIT> has value zero
*/
USICTL0 = USIPE6 | USIPE5 | USIMST | USIOE | USISWRST;
/*
* USI Clock Control Register
*
* USIDIV_3 -- Divide by 8
* USISSEL_2 -- SMCLK
* USICKPL -- Inactive state is high
* ~USISWCLK -- Input clock is low
*
* Note: ~USISWCLK indicates that USISWCLK has value zero
*/
USICKCTL = USIDIV_3 | USISSEL_2 | USICKPL;
/* Enable USI */
USICTL0 &= ~USISWRST;
The function below does the actual SPI data transfer. It both transmits and receives data over SPI bus.
Data to be transmitted is loaded in USISRL register. USI bit counter is loaded with the number of bits
to transfer, here 8. In the hardware end, this counter is decremented with data being shifted and clock
signal being generated on each decrement. Since SPI bus is a circular bus, reading USISRL register back
returns received data. Note slave select pin is not used here as it is used in MAX7219 source file.
unsigned char SPI_transfer(unsigned char data_out)
{
unsigned char data_in = 0;
USISRL = data_out; // Load shift register with data byte to be TXed
USICNT = 8; // Load bit-counter to send/receive data byte
while (!(USIIFG & USICTL1)); // Loop until data byte transmitted
data_in = USISRL; // Read out the received data
return data_in;
}
The rest of the code is the implementation of MAX7219 driver and how to use it to create patterns in
the dot-matrix display. When started, the display scrolls the letters of the word “MICROARENA- the

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