小弟初学5529,另一个I2C硬件是,查了用户手册从机地址是110111M,我烧了个I2C的小程序到5529,可是那边怎么都显示不出数据,程序如下:
#include <msp430.h>
const unsigned char Sine_Tab[] = {0x40,0xF6, 0x40,};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
P3SEL|=0x03; // Assign I2C pins to USCI_B0 // 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 = 0x6f; // Set slave address
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UCB0IE|=UCTXIE; // Enable TX ready interrupt
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
while(1){
int i;
for(i=0;i<3;i++){
UCB0TXBUF=Sine_Tab;
}
}
}
// USCI_B0 Data ISR
#pragma vector =USCI_B0_VECTOR
__interrupt void USCI_B0_ISR(void)
{
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>