Professional Documents
Culture Documents
//
|
| |
|
|
//
+--|Vss SCL|<-+------|P1.6/UCB0SCL P1.0|---> LED
//
\|/ ------|
|
//
// D. Dang
// Texas Instruments Inc.
// February 2011
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include <msp430g2553.h>
#include "uart.h"
unsigned int RxByteCtr;
unsigned int RxWord;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT0;
P1SEL |= BIT6 + BIT7;
P1SEL2|= BIT6 + BIT7;
UCB0CTL1 |= UCSWRST;
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;
UCB0CTL1 = UCSSEL_2 + UCSWRST;
UCB0BR0 = 12;
UCB0BR1 = 0;
UCB0I2CSA = 0x23;
UCB0CTL1 &= ~UCSWRST;
IE2 |= UCB0RXIE;
TACTL = TASSEL_2 + MC_2;
uart_init();
while (1)
{
RxByteCtr = 2;
UCB0CTL1 |= UCTXSTT;
__bis_SR_register(CPUOFF + GIE);
//
//
//
//
//
//
//
//
Stop WDT
P1.0 output
Assign I2C pins to USCI_B0
Assign I2C pins to USCI_B0
Enable SW reset
I2C Master, synchronous mode
Use SMCLK, keep SW reset
fSCL = SMCLK/12 = ~100kHz
//
//
//
//
//
//
//
//
// uart_putc(RxWord) ;
uart_put_num(RxWord,0,0);
uart_puts("\r\n");
// printf(RxWord);
// uart_puts(RxWord) ;
__delay_cycles(100000);
P1OUT |= 0x01;
__disable_interrupt();
TACCTL0 |= CCIE;
__bis_SR_register(CPUOFF + GIE);
TACCTL0 &= ~CCIE;
// Yes, P1.0 = 1
//
//
//
//
//
}
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TA0_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF);
}
// Exit LPM0