Are you sure you're programming your tag numbers in EEPROM at burn time? You should be
able to read back the .hex after programming to check.
Are you sure you're programming your tag numbers in EEPROM at burn time? You should be
able to read back the .hex after programming to check.
I donīt wrote the code before for storing on eeprom.
But maybe this could work
Error corrected... SorryCode:DATA @$00, $D7, $7C, $4B, $02, $2D, $C9, $80, $3A, $C4, $72 Loop VAR BYTE ReadTag VAR BYTE[2] Tag VAR WORD[5] TmpTag VAR BYTE[10] ConvTag VAR WORD ' -----[ Program Code ]---------------------------------------------------- FOR Loop= 0 TO 9 ' Reading Data from EEprom Adr: $00 -$09 READ Loop,TmpTag(Loop) NEXT Loop Main: LOW PORTB.3 ' activate the reader SERIN2 PORTB.2, T2400, [WAIT($0A,"100050"), STR ReadTag\2] HIGH PORTB.3 ' deactivate reader Check_List: FOR Loop = 0 TO 8 STEP 2 ' Calculate Word from HighByte + LowByte Tag(Loop/2) = TmpTag(Loop)*$100+TmpTag(Loop+1) NEXT Loop ConvTag = ReadTag(0)*$100+ReadTag(1) ' Conversion of ReadTag to WORD FOR Loop = 0 TO 4 ' Compare if ReadTag compares to Database in Eeprom IF ConvTag = Tag(Loop) THEN Tag_found NEXT Loop GOTO Bad_Char Bad_Char: ' try next tag '.... '.... GOTO main Tag_Found:
Last edited by Robson; - 25th August 2007 at 18:16.
I have simplified my program to isolate the issue. I believe it lies with the READ command. This is my simplified code.
At this point I am just trying to read a byte form the EEPROM and display it on the LCD just to prove it is being read. I see the EEPROM data in the EEPROM data window on my EPICWin programming software. So I guess it is writing the EEPROM data at burn time. However all I can debug on the LCD so far is just 0. This leads me to think that the problem is with the READ command. With the above example I would think that the LCD would display 2A or at least something other than just 0's.Code:CMCON = 7 DEFINE OSC 20 char VAR Byte ' character from table ' - LCD Stuff - i con 254 clrlcd con 1 cgram con 64 ddram con 128 n96n con $4054 pause 1000 serout2 portb.7,n96n,[i,clrlcd] pause 1 Tag1 DATA @$00,$10,$2A,$54,$FF,$7C Main: READ $02, char ' get tag data from table 'Debug to LCD serout2 portb.7,n96n,[i,clrlcd] pause 500 serout2 portb.7,n96n,[i,ddram+0] serout2 portb.7,n96n,[HEX char] serout2 portb.7,n96n,[i,ddram+6] serout2 portb.7,n96n,[DEC char] pause 1000 end
"Program/Verify Data" must be checked for it to write EEPROM data when programming.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1940&stc=1&d=118807518 2">
<br>
DT
I already have the "Program/Verify Data" option checked. Also if I Read the chip after Programming it, I do see the EEPROM data present in the Data EEPROM window. So it's definitely writing to the EEPROM. It's just not reading it for some reason.
Also some other things I tried just now was switching to the internal 4MHz resonator and trying a second chip in case it was a bad chip. Neither made any difference.
Ok, get this! I just tried using a 16F84A instead of the 16F628A using nearly the exact same code and it works! I just removed the CMCON = 7 and DEFINE OSC 20 and stuck a 4MHz resonator on the board. With the 84A the LCD reads out the proper values one after the other, 10,2A,54,FF,7C. So now it looks like there is either something weird happening when I compile or the 628A does not like this code. Any ideas? I'd rather not have to step down my chip for this and have to order more old 16F84A's.
Code:'CMCON = 7 'DEFINE OSC 20 char VAR Byte ' character from table loop var byte i con 254 clrlcd con 1 cgram con 64 ddram con 128 n96n con $4054 pause 1000 serout2 portb.7,n96n,[i,clrlcd] pause 1 DATA @$00,$10,$2A,$54,$FF,$7C Main: for loop = 0 to 4 READ loop, char ' get tag data from table 'Debug to LCD serout2 portb.7,n96n,[i,clrlcd] pause 500 serout2 portb.7,n96n,[i,ddram+0] serout2 portb.7,n96n,[HEX char] pause 1000 next end
Change this: READ (tagNum - 1 * 10 + idx), char ' get tag data from table
to this: (((tagNum - 1) * 10) + idx), char ' get tag data from table
Does it work now?
Bookmarks