I am using MB but i dont think thats related as this seems to be a chip issue
My issue is I2C wont do anything! im getting nothing on the Logic analyzer.
My Setup:
using ASDA1 and ASCL1 pins to talk to a 24SC01 EEProm
Have 2.2K pullups on both lines
Have Setup Fuse set for A pins
Set all pins as Digital
Set both pins (B8 and A9) as inputs
Int the I2C1
As you can see in the code i have tried all sorts of other config bits that normally i have never needed to set to try and resolve the issue to no avail
Interesting Observations and tests:
- It works from a easypic Fusion V7 board jumpering the 2 pins to my board and disable i2C on my dsPic, this confirms the circuit on my board is good, i tried 3 different I2C ports from this easypic board all worked great
the Fusion board had a dsPIC33EP512MU810 Processor, its running essentially the same code bar the odd chip difference. - The SCL line on my board reads low when i Init the I2C??? the pin is high on the scope and Logic analyzer, but if i read PortB.8 it is 0 PortA.9 is 1 ?? this is confusing as i dont see why it should read low when the pin is high.
- If i use the Built in I2C Read then it hangs, im using some non hanging code in this forum to stop it hanging, but both work fine in test #1
- SPI and any other function i have tested so far works on this chip
This is the latest code for the EEprom
Code: Select all
Sub Procedure SetupEE(Dim Node as byte)
LatA.9 = 1
LatB.8 = 1
TRISA.9 = 1
TRISB.8 = 1
Delay_100ms()
CVR1CON.6=0 'Ensure Voltage Ref is disconnected from pin
pmd1.7=0 'enable I2C1 module
I2C1Con.9=1 'DISABle Slew rate control
I2C1Con.8=0 'SMEN SMBus Disable
I2C1Con.11=0 'Disable IPMIEN
I2C1_Init(100000) ' initialize I2C communication
NodeAddress = node
end sub
sub procedure EEWriteByte(dim DataAddress as byte,Dim Value as byte)
TRISC.2 = 0 'Set Write Protection to output
Latc.2 = 0 '0= can write to EEPROM
NodeAddress = 160
I2C1_Start() ' issue I2C start signal
I2C1_Write(NodeAddress) ' send byte via I2C (device address + W)
I2C1_Write(DataAddress) ' send byte (address of EEPROM location)
I2C1_Write(Value) ' send data (data to be written)
I2C1_Stop() ' issue I2C stop signal
'Delay_100ms()
end sub
sub Function EEReadByte(dim DataAddress as byte) as byte
NodeAddress = 160
I2C1_Start() ' issue I2C start signal
I2C1_Write(NodeAddress) ' send byte via I2C (device address + W)
I2C1_Write(DataAddress) ' send byte (data address)
I2C1_Restart() ' issue I2C signal repeated start
I2C1_Write(NodeAddress+1) ' send byte (device address + R)
result = I2C1_Read(1) ' Read the data (NO acknowledge)
I2C1_Stop() ' issue I2C stop signal
end sub
Code: Select all
Sub Procedure SetupEE(Dim Node as byte)
I2C1_Init(100000) ' initialize I2C communication
NodeAddress = node
end sub