Can you post all the code? I suppose you cut and paste a part of it, right?
Ioannis
Can you post all the code? I suppose you cut and paste a part of it, right?
Ioannis
Code:PORTA = 1 PORTB = 0 KEY VAR BYTE KEY1 VAR BYTE ADR VAR BYTE SYMBOL SCLK = PORTB.0 SYMBOL SDAT = PORTB.1 SYMBOL RELY = PORTB.3 SYMBOL STRT = PORTA.0 START: IF STRT = 0 THEN GOSUB SCAN ENDIF GOTO START SCAN: FOR ADR = 0 TO 7 I2CREAD SDAT,SCLK,$A0,ADR,[KEY] PAUSE 10 READ ADR,KEY1 PAUSE 10 NEXT ADR IF UNLCK = 0 THEN I2CWRITE SDAT,SCLK,$A0,ADR,[KEY1] PAUSE 1000 IF (KEY = KEY1) THEN HIGH RELY PAUSE 1000 LOW RELY ENDIF RETURN END DATA @0,14,21,47,56,02,11,22,33 this is wat i have in the external eeprom 24c02 "14,21,47,56,02,11,22,33 the same data i want my code to compare it.when it similare with the internal data it toggle relay or led if not similare it dont please help this wat i want to do but im sure there another way bcz this isnt working it does compare sometimes even the data not similare it toggle the led IF (KEY = KEY1) THEN
You simply put the IF/THEN in the wrong place. It must be within the FOR/NEXT loop.
I don't see the setting for the TRIS registers.
Al.
Code:PORTA = 0 PORTB = 0 TrisA = %00000001 ' ???????????????? TrisB = %00000000 ' ??????????????? KEY VAR BYTE KEY1 VAR BYTE ADR VAR BYTE SYMBOL SCLK = PORTB.0 SYMBOL SDAT = PORTB.1 SYMBOL RELY = PORTB.3 SYMBOL STRT = PORTA.0 START: PAUSE 10 IF STRT = 0 THEN GOSUB SCAN ENDIF GOTO START SCAN: FOR ADR = 0 TO 7 I2CREAD SDAT,SCLK,$A0,ADR,[KEY] PAUSE 10 READ ADR,KEY1 PAUSE 10 IF KEY = KEY1 THEN HIGH RELY PAUSE 1000 LOW RELY Pause 1000 ENDIF NEXT ADR RETURN END DATA @0,14,21,47,56,02,11,22,33
Last edited by aratti; - 28th October 2009 at 23:04.
All progress began with an idea
ty arrati for help
Last edited by Mus.me; - 29th October 2009 at 01:50.
ty for reply still the problem it toggle the rely even i change the data in ext epprom or in pic eeprom it still doing error im sure there other way to compare variables .plz need more help how to compare variables i want to do this project for doorlock so i will have 24c02 in my keys ty aratti
Code:SCAN: FOR ADR = 0 TO 7 NEXT ADR I2CREAD SDAT,SCLK,$A0,ADR,[KEY] 'same data as data eeprom PAUSE 10 READ ADR,KEY1 ' same data as external eeprom 24c02 PAUSE 100 IF (KEY = KEY1) THEN , here is the problem it does hight rely even i put diffirent data in key and key1 HIGH RELY PAUSE 1000 LOW RELY ENDIF
Last edited by Mus.me; - 29th October 2009 at 01:54.
It works i cahnged somethings but the problem i have is it compare just the 7th byte when u change other bytes from 0 to 6 it doesnt detect them but when i change the 7th byte it say error that means it compares it with the 7th byte in the external eeprom NEDD help please .......
IT DOES COMPARE 33 AND 33 BUT NOT OTHER 7 BYTE WHY ?Code:DATA @0,$14,$21,$47,$56,$02,$11,$22,$33 EXTERNAL EEPROM = $14,$21,$47,$56,$02,$11,$22,$33
Last edited by Mus.me; - 29th October 2009 at 05:45.
Simply because you have still left out of the FOR/NEXT loop the compare instruction!IT DOES COMPARE 33 AND 33 BUT NOT OTHER 7 BYTE WHY ?
See my correction to your last code posted or just copy and paste the code in post #5 (the one with my correction in read) and try it.Code:SCAN: FOR ADR = 0 TO 7 I2CREAD SDAT,SCLK,$A0,ADR,[KEY] 'same data as data eeprom PAUSE 10 READ ADR,KEY1 ' same data as external eeprom 24c02 PAUSE 100 IF (KEY = KEY1) THEN , here is the problem it does hight rely even i put diffirent data in key and key1 HIGH RELY PAUSE 1000 LOW RELY ENDIF NEXT ADR
Al.
Last edited by aratti; - 29th October 2009 at 08:05.
All progress began with an idea
Sorry for the late reply but we had our national holiday.
Well, what type of EEPROM are you using?
Ioannis
Bookmarks