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.

tm4c123g launchpad i2c 的问题

Other Parts Discussed in Thread: TM4C123GH6PM

程序如下,是照着TivaWare的example改的,请帮我看看有什么问题

我想用示波器观察SCL(PB2)的波形,可是在我接上示波器并按RESET键,从示波器里看不到任何波形,是不是没有配置好?同时我在CCS5.4的debug中单步运行,想查看寄存器,可是所有寄存器均显示unable to read  请问这是什么情况?  如何能判断我的I2C配置成功并且可以发送数据了呢 ?? 

#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/i2c.h"
#include "driverlib/udma.h"
#include "driverlib/adc.h"

int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);// sysclock is 40Mhz
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeI2C(GPIO_PORTB_BASE,GPIO_PIN_2|GPIO_PIN_3);//Configure the I2C pins
//add2lines
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);// Enable the I2C3 Moudle
I2CMasterEnable(I2C0_BASE);
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), true);//400Kbps

I2CMasterSlaveAddrSet(I2C0_BASE, 0x44, false);//Specify slave address,Master read from the slave
I2CMasterDataPut(I2C0_BASE,'Q');// Place the character to be sent in the data register
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);// Initiate send of character from Master to Slave

// Delay until transmission completes
while(I2CMasterBusBusy(I2C0_BASE))
{
}
}