TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430F5529: Use F5529 instead of F5969 as I2c master

Part Number:MSP430F5529

Hi, below is my program

I am trying to modify the I2c master program used for F5969 to be used for F5529, but the part about I2c setting in line 28, 34 and 89 keeps reporting undefined
Can you point out or fix the problem for me

Thanks and ragards
#include <msp430.h> 
#include <stdio.h>
#include <stdint.h>

volatile uint8_t TxCount, Control_Byte, i;
volatile uint8_t *PTxData;// Pointer to TX data
volatile uint8_t TxData[3], Msg1[]={1,2,3}, Msg2[]={4,5,6};

void main(void) {WDTCTL = WDTPW | WDTHOLD;//Stop watchdog timerPM5CTL0 &= ~LOCKLPM5; //Unlocks GPIO pins at power-upP1DIR |= BIT0 + BIT2 + BIT3 + BIT4 + BIT5 ;P3DIR |= BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7;P4SEL |= 0xFF; //Setup I2CP1OUT = BIT1; // Pull-up resistor on P1.1P1REN = BIT1; // Select pull-up mode for P1.1P1IES = BIT1; // P1.1 Hi/Lo edgeP1IFG = 0;// Clear all interrupt flagsP1IE = BIT1;  // P1.1 interrupt enabledP4OUT &= ~BIT7; //green LED offP1OUT &= ~BIT0; //red LED off// Configure the eUSCI_B0 module for I2C at 100 kHzUCB1CTLW0 |= UCSWRST;UCB1CTLW0 |=  UCSSEL__SMCLK + UCMST + UCTR + UCSYNC + UCMODE_3; //Select SMCLK, master, transmitter, synchronous, I2CUCB1BRW = 10;  //Divide SMCLK by 10 to get ~100 kHzUCB1I2CSA = 0x77; // FR2355 addressUCB1CTLW1 &= ~UCSWRST; // Clear resetUCB1IE |= UCTXIE11; //Enable I2C transmission interrupt__enable_interrupt(); //Enable global interrupts.Control_Byte=0x01;while(1){LPM4;//Wait for pushbutton interrupt in low power modeControl_Byte ^= BIT0; //Toggle control byteif(Control_Byte == 0x01){for(i=0;i<3;i++)TxData[i]=Msg1[i];P1OUT |= BIT0; //Red LED}else{for(i=0;i<3;i++)TxData[i]=Msg2[i];P4OUT |= BIT7; //Green LED on}PTxData = (uint8_t *)TxData; //Set pointer to start of TX arrayTxCount = 3; //Send bytes to slaveUCB1CTLW1 |= UCTXSTT; // Set to transmit and startLPM0;// Remain in LPM0 until all data transmittedwhile (UCB1CTLW1 & UCTXSTP);  // Ensure stop condition got sent__delay_cycles(10000);P1OUT &= ~BIT0; //LEDs offP4OUT &= ~BIT7;}
}

#pragma vector = USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{switch(__even_in_range(UCB0IV,30)){case 0: break;// Vector 0: No interruptscase 2: break;// Vector 2: ALIFGcase 4: break;// Vector 4: NACKIFGcase 6: break;// Vector 6: STTIFGcase 8: break;// Vector 8: STPIFGcase 10: break;// Vector 10: RXIFG3case 12: break;// Vector 12: TXIFG3case 14: break;// Vector 14: RXIFG2case 16: break;// Vector 16: TXIFG2case 18: break;// Vector 18: RXIFG1case 20: break;// Vector 20: TXIFG1case 22: break;// Vector 22: RXIFG0case 24:// Vector 24: TXIFG0if (TxCount)// Check if TX byte counter not empty{UCB1TXBUF = *PTxData++; // Load TX bufferTxCount--;// Decrement TX byte counter}else{UCB1CTL1 |= UCTXSTP; // I2C stop conditionUCB1IFG &= ~UCTXIFG1;  // Clear USCI_B0 TX int flagLPM0_EXIT;// Exit LPM0}break;case 26: break;// Vector 26: BCNTIFGcase 28: break;// Vector 28: clock low timeoutcase 30: break;// Vector 30: 9th bitdefault: break;}
}

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{P1IFG &= ~BIT1;  // Clear P1.1 IFGLPM4_EXIT;// Exit LPM4
}
Ben Qin:

你好,你可以查看msp430f5529.h吗?应该是定义问题。

,

Ben Qin:

line 28 :我编译了你的程序后并没有报错,应该是没问题,你可以查看下你头文件中的定义。

line 34 :头文件中并没有UCTXIE11这个定义,你可以直接使用UCTXIE。

line 89 :同样的,头文件中没有UCTXIFG1定义,你可以直接使用UCTXIFG。

,

LUN JUN YUAN:

非常感谢帮忙,修改过后line 34、line 89的未定义问题皆解决了,不过现在于line 32的Clear reset部分也显示了未定义,想请教这部分应如何修改

,

Ben Qin:

头文件中同样没有UCB1CTLW1该定义,根据你前面的程序,应该是UCB1CTLW0.

赞(0)
未经允许不得转载:TI中文支持网 » MSP430F5529: Use F5529 instead of F5969 as I2c master
分享到: 更多 (0)