hello GUSSE,
i got a BONUS now. the led is on (pin2 only) and flash
i lookk for error in teh program and let u knoow later
thanks for your help
hello GUSSE,
i got a BONUS now. the led is on (pin2 only) and flash
i lookk for error in teh program and let u knoow later
thanks for your help
HI Gusse,
the modifications were made.
as indicated.
defined OSC 4 ;no effect: ( INTCLOUT is set in the fuse window)
SDA PORTA.3
SCL PORRT.4
......
R_SDA & R_SCL: 4.5k
a led on portb flashed is due to error that i cannot see where it comes from
not write nor read. i assume EEPROM???
Hi MInhle,
Below is very simple I2C write and read test script.
If write and read are successfully executed then LED will blink for 0.5s.Code:<code><font color="#000000">CMCON = 7 TRISA = %11000000 TRISB = %00000000 SDA <b>VAR </b>PortA.3 SCL <b>VAR </b>PortA.4 LED <b>VAR </b>PortB.0 <font color="#000080"><i>'Indicator LED (change if needed) </i></font>I2CDeviceEEprom <b>VAR BYTE </b>I2CAddressEEprom <b>VAR WORD </b>TEMP1 <b>VAR BYTE </b>TEMP2 <b>VAR BYTE </b>I2CDeviceEEprom=$A0 <font color="#000080"><i>'DeviceID 10100000 = $A0 = %1010 A2=0, A1=0, A0=0 R/W=0 </i></font><b>DEFINE </b>OSC 4 Main: I2CAddressEEprom = 0 TEMP1 = 1 <b>GOSUB </b>Write_I2C <b>PAUSE </b>10 <b>GOSUB </b>Read_I2C <b>IF </b>TEMP1 = TEMP2 <b>THEN HIGH </b>LED <font color="#000080"><i>'If OK then 0.5s LED blink </i></font><b>PAUSE </b>500 <b>LOW </b>LED <b>ELSE HIGH </b>LED <font color="#000080"><i>'If FAIL then 2s LED blink </i></font><b>PAUSE </b>2000 <b>LOW </b>LED <b>ENDIF GOTO </b>Main Write_I2C: <b>I2CWRITE </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ TEMP1 ] <b>RETURN </b>Read_I2C: <b>I2CREAD </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ TEMP2 ] <b>RETURN END </b></code>
2s LED blink will be an indication of fail.
BR,
-Gusse-
hello Gusse,
I copy you program. run ---> the light is solid.,
i tr to put direcly data into EEProm, the out put is whatever,,,
i.e.
i = 0 ; data address
b0 = $2a ; data to be stored
i2cwrite .......... i, [b0]
b0 = 0
i2cread .........i,[b0]
run ----> whatever... output (BONUS ONLY)
i have to replace the EEPROm
thanks for your time
regards,
Hi,
Sorry, I had one bug there. One pause missing.
Now it will blink.Code:<code><font color="#000000">CMCON = 7 TRISA = %11000000 TRISB = %00000000 SDA <b>VAR </b>PortA.3 SCL <b>VAR </b>PortA.4 LED <b>VAR </b>PortB.0 <font color="#000080"><i>'Indicator LED (change if needed) </i></font>I2CDeviceEEprom <b>VAR BYTE </b>I2CAddressEEprom <b>VAR WORD </b>TEMP1 <b>VAR BYTE </b>TEMP2 <b>VAR BYTE </b>I2CDeviceEEprom=$A0 <font color="#000080"><i>'DeviceID 10100000 = $A0 = %1010 A2=0, A1=0, A0=0 R/W=0 </i></font><b>DEFINE </b>OSC 4 Main: I2CAddressEEprom = 0 TEMP1 = 1 <b>GOSUB </b>Write_I2C <b>PAUSE </b>10 <b>GOSUB </b>Read_I2C <b>IF </b>TEMP1 = TEMP2 <b>THEN HIGH </b>LED <font color="#000080"><i>'If OK then 0.5s LED blink </i></font><b>PAUSE </b>500 <b>LOW </b>LED <b>ELSE HIGH </b>LED <font color="#000080"><i>'If FAIL then 2s LED blink </i></font><b>PAUSE </b>2000 <b>LOW </b>LED <b>ENDIF</b> <b>PAUSE </b>1000 <font color="#000080"><i>'PAUSE ADDED</i></font> <b>GOTO </b>Main Write_I2C: <b>I2CWRITE </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ TEMP1 ] <b>RETURN </b>Read_I2C: <b>I2CREAD </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ TEMP2 ] <b>RETURN END </b></code>
BR,
-Gusse-
Hello Gusse,
thanks for your help,
the eeprom is wrong. I replace a another one. it is ok now.
and the R_SCL and R_SDA are either 13K or 3,3 k the light intensity and frequency does not change (by naked eyes)
thanks again
Minh le
Hello Gusse,
actually it is not necessary to " define OSC 4" it is defined in fuse ("INTCLOUT.."
the 24lc256 it takes only 5ms to write
thanks
regards
Bookmarks