English
Language : 

TCA7408EVM Datasheet, PDF (5/14 Pages) Texas Instruments – Works with MSP430 Launchpad
www.ti.com
MSP430 Code
4.1.1 TC5405 Overview
As shown in Figure 1, a ten bit serial transfer is required to set the five outputs on the TCA5405. The first
four bits, 0101 (S0-S3), act as a start flag for the TCA5405. S0 is a start bit and S1-S3 are the clock sense
bits for the TCA5405. The next five bits (D4-D0) are the data bits associated with each of the outputs. The
tenth bit returns the serial line back to high to ready the TCA5405 for the next input.
In the source code there are two methods to handle this communication. These functions are located in
Single_Wire.c
1. Use a GPIO (general purpose input/output) and a clock delay to emulate S0-D0.
2. Use one of the MSP430 timers to change the output at a specified bit interval.
4.1.2 bit_bang_TCA5405_byte(unsigned char byte)
The function bi_bang_TCA5405_byte(unsigned char byte) will emulate the required ten bits for
communication with the TCA5405. This function works very simply by driving a GPIO pin to high or low
and utilizing the _delay_cycles() function to hold the value. After each assert on the GPIO pin a
_delay_cycles(16) is called to wait roughly 2 microseconds before the next bit. The section that handles
the data bits (D4-D0) only uses a _delay_cycles(10) function; this is to adjust for the time spent on if
statements.
4.1.3 send_TCA5405_byte
The function send_TCA5405_byte(unsigned char byte) along with 5405_Timer_ISR() implements the
required serial data by using one of the MSP430 timers. When a byte is sent to send_TCA5405_byte(),
the function adds the start flag (S0-S3) to the beginning and the stop bit (1) to the end (LSB), stores the
new value to a global variable, and enables the timer interrupts. After a set number of clock cycles defined
by NEXT_BIT_TIME, 5405_Timer_ISR() is called and adjusts the output of the P2.0 accordingly.
NOTE: The start flag S0-S3 is hard coded into each of these methods
SCPU034 – December 2011
Submit Documentation Feedback
Copyright © 2011, Texas Instruments Incorporated
TCA7408EVM,TCA5405EVM
5