Microchip
直播中

王敏

7年用户 245经验值
私信 关注
[问答]

I2C无法在PIC12LF1840上工作

我正在与PIC12LF1840微控制器工作,并有困难使I2C工作。我用MPLAB代码配置器生成代码。当我探测我的时钟线(当调用I2C.MistMraveWrad)时,不管我做什么,电压大约稳定在1.1伏特。我正在提供3.3V的电路。我正在使用过去在PIC16LF18325微控制器上使用的功能代码。这是PIN寄存器。我使用RA1为SCLK,RA2为SDA,RA0为EASART TX,RA4为ADC输入。LATA=0x06;TrISA=0x3f;ANSELA=0x10;WPUA= 0x00;有什么想法可能是错的?为什么我看到1.1伏稳定在我的时钟线,即使我叫I2C功能?

以上来自于百度翻译


      以下为原文

    I am working with the PIC12LF1840 Microcontroller and having trouble getting the I2C to work. I generated code with MPLAB code configurator. When I probe my clock line (when calling I2C_MasterWrite) I see the voltage is steady at roughly 1.1 volts no matter what I do. I am supplying the circuit with 3.3V.

I am resuing functioning code I had used on a PIC16LF18325 microcontroller in the past. Here are the pin registers. I am using RA1 for SCLK,  RA2 for SDA, RA0 for EUSART Tx, and RA4 for an ADC input.

LATA = 0x06;
TRISA = 0x3F;
ANSELA = 0x10;
WPUA = 0x00;

Any idea what could be wrong? Why am I seeing 1.1 volts steady on my clock line even though I am calling I2C functions?

回帖(3)

王焕树

2019-2-12 13:05:41
我假设你只是用一个伏特计来观察这个引脚。它很可能是时钟很快,你只是看到平均电压。你能得到一个范围来观察信号吗?你确信你的PULUPS与SDA和SCL有正确的连接吗?您是以全速运行代码,还是使用调试器(CIPIT3、ICD3等)来执行代码?

以上来自于百度翻译


      以下为原文

    I assume you are just observing the pin with a voltmeter.
It's probably clocking rapidly, and you are just seeing the average voltage.
Can you get a scope to watch the signal?
 
Are you sure you have pullups connected correctly to SDA and SCL?
Are you running the code at full speed, or stepping through it with a debugger (PICkit3, ICD3, etc)
 
举报

曹光辉

2019-2-12 13:23:39
我正在使用一个范围来观察信号。当设备用PICTIT3编程时,我可以看到时钟线以良好的锐利信号进入VCC /接地。编程完成后,我只看到这1.12伏。我不使用任何BW限制或类似的探针上的那种。我可以用同样的探针读取EUSAT信号,没有问题。我用SKK和SLK都用10KOHM上拉。我也在全速运行代码(没有调试器)

以上来自于百度翻译


      以下为原文

    I am using a scope to watch the signal. When the device programs with the pickit3, I can see the clock line going to VCC/Ground with nice sharp signals. After the programming is done, I am just seeing this 1.12 volts.
 
I am not using any sort of BW limit or anything like that on the probe. I can read the EUSART signal with the same probe no problems. 
 
I am using a 10kohm pull-up for both SDA and SCLK. I am also running the code at full speed (no debugger)
 
举报

李铭鑫

2019-2-12 13:34:09
HI,在运行测试时将PICIT 3从PIC12断开。I2C通信依赖于电阻上拉,为I2C时钟和数据线建立高电平信号。PIKIT 3在ICSP时钟和数据线上有电阻下拉,4.7 KOHM。这个8引脚器件具有I2C和编程工具共享。相同的时钟引脚。通过拾取3连接,上拉和下拉电阻形成一个分压器,给出1.1个电压。I2C是一个“先听后说”的协议,因此当时钟引脚上没有合适的高逻辑电平时,I2C硬件将拒绝信号启动条件。迈西尔

以上来自于百度翻译


      以下为原文

    Hi,
Disconnect the PICkit 3 from PIC12 when running your test.
 
I2C communication depend on resistive pull-up to establish  High level signal for I2C Clock and Data lines.
PICkit 3 have resistive pull-down on ICSP Clock and Data lines, 4.7 kOhm.
 
This 8 pin device have I2C and Programming tool sharing the same clock pin.
With PICkit 3 connected, pull-up and pull-down resistors form a voltage divider giving 1.1 Volt.
 
I2C is a 'listen before you talk' protocol, so when there is not a proper high logic level on the clock pin,
I2C hardware will refuse to signal Start condition.
 
   Mysil
举报

更多回帖

发帖
×
20
完善资料,
赚取积分