This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我copy TI的官方例程,例程是驱动8571的,但是我把5571的A0端接地,把地址改成0X98,却进不去中断。还有就是不懂这句话什么意思UCB0TXBUF = 0x010; // Write DAC control byte,新手,请大神们多多指教。鞠躬,鞠躬,鞠躬
#include <msp430.h>
const unsigned char Sine_Tab[6] = {0x100,0x78,0x56,0x21,0x32,0x96};
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
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 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x98; // Set slave address
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0TXIE; // Enable TX ready interrupt
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
UCB0TXBUF = 0x010; // Write DAC control byte
// _enable_interrupts();
while(1)
{
__bis_SR_register(CPUOFF + GIE);
}
}
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
static unsigned char ByteCtr=0;
UCB0TXBUF = Sine_Tab[ByteCtr++]; // Transmit data byte
ByteCtr &= 0x1f; // Do not exceed table
}