|
本帖最后由 miaoguoqiang 于 2015-9-9 14:38 编辑
最近在调试MSP430G2553硬件IIC从机 ,无法进入接收中断和起始信号的中断。
按照官方的代码调试也进不去中断。主机部分是用的模拟IIC主机与从机通信的,模拟IIC主机程序能够正常操作EEPROM等时钟芯片。
初始化部分,P16 P17都加了10k上拉电阻
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
- P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0
- UCB0CTL1 |= UCSWRST; // Enable SW reset
- UCB0CTL0 = UCMODE_3 + UCSYNC; // I2C Slave, synchronous mode
- UCB0I2COA = 0x48; // Own Address is 048h
- UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
- UCB0I2CIE |= UCSTPIE + UCSTTIE; // Enable STT and STP interrupt
- IE2 |= UCB0RXIE; // Enable RX interrupt
- while (1)
- {
- PRxData = (unsigned char *)RxBuffer; // Start of RX buffer
- RXByteCtr = 0; // Clear RX byte count
- __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
- // Remain in LPM0 until master
- // finishes TX
- __no_operation(); // Set breakpoint >>here<< and read
- } // read out the RxData buffer
- }
复制代码
中断程序<在中断中加入断点,调试无法进入>
- //------------------------------------------------------------------------------
- // The USCI_B0 data ISR is used to move received data from the I2C master
- // to the MSP430 memory.
- //------------------------------------------------------------------------------
- #pragma vector = USCIAB0TX_VECTOR
- __interrupt void USCIAB0TX_ISR(void)
- {
- *PRxData++ = UCB0RXBUF; // Move RX data to address PRxData
- RXByteCtr++; // Increment RX byte count
- }
- //------------------------------------------------------------------------------
- // The USCI_B0 state ISR is used to wake up the CPU from LPM0 in order to
- // process the received data in the main program. LPM0 is only exit in case
- // of a (re-)start or stop condition when actual data was received.
- //------------------------------------------------------------------------------
- #pragma vector = USCIAB0RX_VECTOR
- __interrupt void USCIAB0RX_ISR(void)
- {
- UCB0STAT &= ~(UCSTPIFG + UCSTTIFG); // Clear interrupt flags
- if (RXByteCtr) // Check RX byte counter
- __bic_SR_register_on_exit(CPUOFF); // Exit LPM0 if data was
- } // received
复制代码
有调试过的请指教一下。 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!
|