LM3S9B96的i2c设置问题?

2019-03-24 16:10发布

各位用过的说说怎么设置,我设置的没有反应。              SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
             SysCtlPeripheralReset(SYSCTL_PERIPH_I2C1);
             SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
             GPIOPinConfigure(GPIO_PJ0_I2C1SCL);
             GPIOPinConfigure(GPIO_PJ1_I2C1SDA);
             GPIOPinTypeI2C(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1);
             i2c = (LM3SXXXX_STRUCT_I2C *)LM3SXXXX_BASE_I2C1_MASTER;
            
             //HWREG(I2C1_MASTER_BASE + I2C_O_MCR) |= 0x01; // Loopback mode
             I2CMasterInitExpClk(I2C1_MASTER_BASE, SysCtlClockGet(), false);// 100K
             I2CMasterSlaveAddrSet(I2C1_MASTER_BASE,
                                   0x90,
                                   false
                                   );
             I2CMasterEnable(I2C1_MASTER_BASE);
            
             // set for read TMP275
             I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
             I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);
             I2CMasterDataPut(I2C1_MASTER_BASE, 0x01);
             I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
             I2CMasterDataPut(I2C1_MASTER_BASE, 0x60);
             I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
            
             I2CMasterDisable(I2C1_MASTER_BASE);   读的时候是:     I2CMasterEnable(I2C1_MASTER_BASE);
   
    I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, 0x90, false);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    I2CMasterDataPut(I2C1_MASTER_BASE, 0x00);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
   
    I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, 0x91, false);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
    TempDataBuf[0] = I2CMasterDataGet(I2C1_MASTER_BASE);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
    TempDataBuf[1] = I2CMasterDataGet(I2C1_MASTER_BASE);
    I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
   
    I2CMasterDisable(I2C1_MASTER_BASE); 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
zyc1
1楼-- · 2019-03-24 21:53
你的I2C电路是如何连接的?我之前也是在用到I2C模块的时候,怎么写都没反应,后来同样程序在开发板上试可以对EEPROM进行读写,才发现SDA和SCL的上拉忘加,因为是开漏输出 加了以一切以后一切就ok了

一周热门 更多>

相关问题

    相关文章