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.

I2C通信UCB1

我使用I2C进行通信,UCB0正常,通过port mapping功能使用UCB1时发现,只要端口功能一打开(PSEL置1),时钟和数据信号就开始缓慢的拉低(都接了上拉电阻)。

  • 两路代码基本一样,下面是port mapping 的代码
    void Port_Mapping(void)
    {
    __disable_interrupt(); // Disable Interrupts before altering Port Mapping registers
    PMAPPWD = 0x02D52; // Enable Write-access to modify port mapping registers
    #ifdef PORT_MAP_RECFG
    PMAPCTL = PMAPRECFG; // Allow reconfiguration during runtime
    #endif
    P4MAP1 = PM_UCB1SDA;
    P4MAP2 = PM_UCB1CLK;
    PMAPPWD = 0; // Disable Write-Access to modify port mapping registers
    #ifdef PORT_MAP_EINT
    __enable_interrupt(); // Re-enable all interrupts
    #endif
    }
    调用Port_Mapping后,进行 P4OUT |= 0x06; 就会出现时钟和数据信号缓慢拉低的情况,并且无法检测到时钟信号和数据信号
    正常的UCB0在完成I2C配置前都保持高电平,只有检测到起始位UCB0CTL1 |= UCTR + UCTXSTT;后才出现时钟信号和数据信号
  • 有人在吗?求问大神这是什么问题?port mapping用PWM波输出测试过,是没有问题的,只有将port mapping成I2C的时钟和数据引脚就不行了?请问这是单片机内部有其他的代码在占用I2C的总线?还是什么别的原因?
  • 问题找到了,是两个引脚上连接的上拉电阻有问题,正常10K,用万用表测有7M,换回10K的上拉电阻问题得到解决
  • 很高兴您能解决问题并分享答案!

    很抱歉,之前有休假,所以未能及时回复您的帖子