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.
飞控请求的device address为0x16, 我在msp430中也已经设置相应的从机地址,如果不连接两个设备,示波器能读出飞控发出的信号(一直请求0x16地址),如果连接两个设备,则示波器显示无任何波形。
于是我用stm32模拟飞控作为主机请求msp430,发出的也是0x16地址,msp430能正常通信, (示波器显示正常的波形,时序速度一致)。
用飞控请求另一个完全正确的设备(仍然是0x16地址),能正常通信。
其中,msp430,我没外挂任何上拉电阻之类的,因为stm32能正常通信,所以应该不是上拉电阻的问题。飞控烧写的是官方的固件,应该也没问题。
所以最后判断可能是msp430出错,但是毫无头绪,请问有可能是哪里出错了吗?
您好,我的初始化代码如下,使用的是P1组6,7引脚,REN我置零置一的效果时一样的。
void initGPIO()
{
//P1OUT &= ~BIT0; // Clear P1.0 output latch ~ LED
P1REN |= BIT6 | BIT7; //R up
P1SEL1 |= BIT6 | BIT7; // I2C pins
PM5CTL0 &= ~LOCKLPM5;
}
void initI2C()
{
UCB0CTLW0 = UCSWRST; // Software reset enabled
UCB0CTLW0 |= UCMODE_3 | UCSYNC; // I2C mode, sync mode
UCB0I2COA0 = SLAVE_ADDR | UCOAEN;; // Own Address and enable
UCB0CTLW0 &= ~UCSWRST; // clear reset register
UCB0IE |= UCRXIE;
UCB0IE |= UCSTPIE;
}
void initClockTo16MHz()
{
// Configure one FRAM waitstate as required by the device datasheet for MCLK
// operation beyond 8MHz _before_ configuring the clock system.
FRCTL0 = FRCTLPW | NWAITS_1;
// Clock System Setup
CSCTL0_H = CSKEY >> 8; // 解锁 CS registers
CSCTL1 = DCORSEL | DCOFSEL_4; // Set DCO to 16MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL0_H = 0; // 锁 CS registerss
}
从机使能中断在例程里这这样配置的
UCB0IE |= UCTXIE0 | UCSTPIE; // transmit,stop interrupt enable