thank you very much joe for helping me .have a great day .
Hello malwww,
If you have been following other threads, you have seen a similar one to yours. If you are using byte variables only then use lookup instead of lookup2 as the code is 1/3 as big and you can use a table of up to 255 choices. Lookup2 gives only 85 choices, which can be byte or word variables.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
hi joe thank you again for explaining to me ,i have another question please if you dont mind...i i want to write atring (lookup) to the external eeprom then i read it and send it out just to get more ideas bcz im new in pbp ,but its easy to lern than asm. have a great weekend joe
'' I2CREAD and I2WRITE Commands
Include "modedefs.bas"
DEFINE I2C_SLOW 1
DEFINE SHIFT_PAUSEUS 1000
SDO VAR PortB.0
SCLK var PortB.1
SCLK = 8
SO con 0
DPIN var PORTA.0
CPIN var PORTA.1
B0 var byte
B1 var byte
B2 var byte
B3 var byte
n var byte
portB = 0
TRISB = 0
'for n = 0 to 15
lookup n,[252,96,218,242,102,182,190,224,254,246],b0 ' numbers from 0 to 9
For B2 = 0 To 15
I2CWRITE DPIN,CPIN,$A0,b2,[str B0\8]
Pause 20
Next B2
'next n
loop: For B3 = 0 To 15
I2CREAD DPIN,CPIN,$A0,B3,[B1]
pause 1000
SHiftOUT SDO,SCLK,0,[b1]
'
Next B3
Goto loop
end
i wrote this code but it doesnt shiftout the numbers from 0 to 9 like i have in the string .but it works good with last programe you fixed for me .see u joe
Last edited by malwww; - 10th May 2009 at 09:10.
Code:'' I2CREAD and I2WRITE Commands Include "modedefs.bas" DEFINE I2C_SLOW 1 DEFINE SHIFT_PAUSEUS 1000 SDO VAR PortB.0 SCLK var PortB.1 SCLK = 8 SO con 0 DPIN var PORTA.0 CPIN var PORTA.1 B0 var byte B1 var byte B2 var byte B3 var byte n var byte portB = 0 TRISB = 0 'for n = 0 to 15 <font color = red>' commented out </font color> <font color=green>you have setup your variables, and stored nothing in them yet, and are proceeding to lookup the value of "n" which is unknown to you,</font color> lookup n,[252,96,218,242,102,182,190,224,254,246],b0 ' numbers from 0 to 9 <font color=green>'the following loop will output the value stored in "n" filtered through the lookup table 15 times, always the same number,in each eeprom location. why the str modifier? Seems to me the numbers in the lookup table are not string values, as they would be arranged between quotation marks like so "252","96" . . .</font color> For B2 = 0 To 15 I2CWRITE DPIN,CPIN,$A0,b2,[str B0\8] Pause 20 Next B2 'next n loop: For B3 = 0 To 15 I2CREAD DPIN,CPIN,$A0,B3,[B1] pause 1000 SHiftOUT SDO,SCLK,0,[b1] ' Next B3 Goto loop endare you seeing what you need to change ?i wrote this code but it doesnt shiftout the numbers from 0 to 9 like i have in the string .but it works good with last programe you fixed for me .see u joe
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
I DIDNT UNDERSTAND GOOD JOE, DO I HAVE TO PUT QUOTATIONS?
BCZ I HAVE A PROBLEM TO WRITE IN THE EEPROM ,WHEN I READ THEM IT SHOW MW DEFFIRENT DATA,I STORED THOSE NUMBERS IN THE EEPROM USING THE PROGRAMER WHEN I READ THEM IT WORKS GOOD ,THE PROBLEM I HAVE IS TO WRITE TO THE EEPROM AND WHEN I WRITE JUST 1 NUMBER IT WORKS GOOD ,
lookup n,[252,96,218,242,102,182,190,224,254,246],b0 ' numbers from 0 to 9
For B2 = 0 To 9
I2CWRITE DPIN,CPIN,$A0,b2,[str B0\8]
Pause 20
Next B2
THANK YOU FOR HELPING ME JOE,
[thank you joe got it now it works have a great day ...
' I2CREAD and I2WRITE Commands
Include "modedefs.bas"
DEFINE SHIFT_PAUSEUS 1000
SDO VAR PortB.0
SCLK var PortB.1
SCLK = 8
DPIN var PORTA.0
CPIN var PORTA.1
B0 var byte
B1 var byte
B2 var byte
N var byte
portB = 0
TRISB = 0
pause 100
For B2 = 0 To 9
lookup b2,[252,96,218,242,102,182,190,224,254,246],b0
I2CWRITE DPIN,CPIN,$A0,b2,[ b0]
Pause 20
Next B2
loop: For B3 = 0 To 9
I2CREAD DPIN,CPIN,$A0,b3,[B1]
pause 1000
SHiftOUT SDO,SCLK,0,[b1]
'
Next B3
Goto loop
end
Last edited by malwww; - 10th May 2009 at 23:05.
GOOD ! Glad you have it working the way You want it.
Now I am curious, what are you making? I am guessing
you intend to do more than store 0 - 9 in the eeprom.
There are dozens of examples here to do something similar
to what you have in mind, whatever it is. Google can search
just this forum if you use this link.
http://www.google.com/custom?hl=en&c...ch&sitesearch=
just check the check box that says, Search picbasic.co.uk. and you are set.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks