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 #216 background imageLoading...
Page #216 background image
216
Code Example
SPI.h
#include <msp430.h>
unsigned char SPI_transfer(unsigned char data_out);
SPI.c
#include "SPI.h"
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;
}
MAX72xx.h
#include <MSP430.h>
#include "delay.h"
#include "SPI.h"
#define HW_SPI_DIR P1DIR
#define HW_SPI_OUT P1OUT
#define HW_SPI_IN P1IN
#define CS_pin BIT4
#define CS_DIR_OUT() do{HW_SPI_DIR |= CS_pin;}while(0)
#define CS_DIR_IN() do{HW_SPI_DIR &= ~CS_pin;}while(0)
#define CS_HIGH() do{HW_SPI_OUT |= CS_pin;}while(0)
#define CS_LOW() do{HW_SPI_OUT &= ~CS_pin;}while(0)
#define NOP 0x00
#define DIG0 0x01
#define DIG1 0x02
#define DIG2 0x03
#define DIG3 0x04
#define DIG4 0x05
#define DIG5 0x06
#define DIG6 0x07
#define DIG7 0x08
#define decode_mode_reg 0x09
#define intensity_reg 0x0A

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