HI all,
am trying to interface MSP430G2553 controller with pcf8574 I/O expander IC.but am not getting the o/p.My attempt was to send a particular bit pattern from MSP controller to the PCF8574 and show the bit pattern on the LEDs connected to the 8 port pins
#include "msp430g2553.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
// Set up a 16MHz main clock
DCOCTL = CALDCO_16MHZ;
BCSCTL1 = CALBC1_16MHZ;
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST+UCMODE_3+UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2+UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 160; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x40; // Set slave address
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0TXIE; // Enable TX interrupt
while (1)
{
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
//__bis_SR_register(CPUOFF + GIE); // CPU off, interrupts
//while (UCB0CTL1 & UCTXSTT); // Loop until I2C STT is sent
//UCB0CTL1 |= UCTXSTP; // I2C stop condition after 1st TX
}
}
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
//static unsigned char data=0x0A;
UCB0TXBUF = 0xAA;
}