Re: Use of IIC on PIC24FJ64GA002
ric and BobAGI,
Thank you both for your feedback, I truly appreciate it.
In the following discussion, "Data Sheet" refers to the PIC24FJ64GA004 Data Sheet (DS39881E)
1) JTAG is disabled. That is, bit 14 of Config Word 1 = 0 (See Data Sheet, REGISTER 24-1)
2) As for switching to Digital Mode, I had not done that so I went ahead and switched to Digital Mode on all bits, at least I think I did; AD1PCFG = 0xffff; (See Data Sheet, REGISTER 25-5), please correct me if I'm mistaken here. At any rate, I still have same problem, SCL is Stuck At Zero and SDA is Stuck at One.
I believe there may be an issue with the specific PIC24FJ64GA002 IC I have, which I will explain at the bottom. First however I would appreciate, if you have the time, to see if my thinking outlined below is correct. (NOTE: The issue with the PIC24FJ64GA002 IC does not appear to apply to I2C2 which is why I switched from I2C1 to I2C2.)
Since the intention is for the PIC24FJ64GA002 to serve as an IIC Master, the SCL pin should always be an output, and the SDA pin would either be an output when sending data such as an IIC address, or an input when receiving data from the IIC sensor. In looking at Figure 10-1 of the "Data Sheet", and contemplating SCL, I would assume that Output Enable of the Tri-State driver would always be enabled for SCL, and that the Output Data going to the Tri-State driver would be the Peripheral Output Data, specifically the SCL stream. The I/O pin for SCL2 would be pin 7 of the PIC24FJ64GA002 (See pg. 2 of Data Sheet).
When contemplating SDA, and again looking at Figure 10-1, when SDA is sending data such as an IIC address, the Output Enable would enable the Tri-State driver and the Peripheral Output Data (i.e., IIC address) would be routed to the Tri-State driver input. When SDA is receiving data such as data from an IIC Temperature sensor, the Output Enable would be set so that the Tri-State drive is in "Tri-State" i.e., high impedance, and the data in I/O pin is routed thru Schmidt Trigger to Input Data then on to "Peripheral Input Data". The I/O pin for SDA2 would be pin 6 of the PIC24FJ64GA002 (See pg. 2 of Data Sheet).
Now, in looking at Figure 10-1 of the Data Sheet, I'm of an opinion that the "Peripheral Module Enable" bit going to the Multiplexers will, in essence be set for the Peripheral operation when I2C2CON bit 15 is set to 1, See REGISTER 16-1 of Data Sheet. The Data Sheet indicates that when this bit is set to 1, Enable I2C2 module and configure the SDA2 and SCL2 pins as serial ports, that is pins 6 & 7 respectively.
Well, I mentioned that there may be an issue with the PIC24FJ64GA002 that I have. Apparently I have an early version of the chip. A "PIC24FJ64GA004 Family Silicon Errata and Data Sheet Clarification" has been issued (DS80000470J). However, this document indicates to me that I2C2 does not have the problem. So, I'm still stuck as I cant get I2C2 to function.
Any input would be appreciated.
PS: I plan to order new PIC24FJ64GA002 IC's, however as I mention above I don't think the potential IC issue pertains I2C2, and if so, I will still be stuck.