Need help with the DAT block and calling data from it
eagletalontim
Posts: 1,399
I currently have a 7 segment display that will show numbers 1 - 9. Since I am converting from the SX language to the Propeller language, I need a little boost I have found some code that shows the DAT area being used kind of like the DATA area on the SX. I am trying to make certain pins outputs when a number is called by storing the sequence in the DAT area. For some reason, I cannot get it working correctly. Can someone help me understand this a little better.
Here is the basic function of how I have it :
Here is the basic function of how I have it :
' the variable tmp is set inside a sub which will be the number which needs to be displayed (1-9) outa[noparse][[/noparse]16..22]~ 'toggle pins off dira[noparse][[/noparse]16..22]~~ 'Ensure the are outputs outa[noparse][[/noparse]16..22] := numbers[noparse][[/noparse]tmp - 1] ' set pins to 1/0 depending on numbers[noparse][[/noparse]#]???? DAT numbers long %100_0000, %010_0000, %110_0000, %100_0000 'these are random sequences just for testing purposes.
Comments
And I don't understand why you use [noparse][[/noparse]tmp -1] as index. If tmp is an integer ( like tmp := 5 ) then your range of tmp will be 0 to 9. That's already the right index.
If tmp is a ascii encoded number ( like tmp := "0" ), then you need to subtract $30 or "0" as then the range of tmp will be "0" to "9" which is $30 to $39 as hex integer-value.
You should always provide the whole code. In many posts the initial problem description contained code which was correct because the problem was hidden in other parts. Extracted code already contains assumptions about the problem of the extractor. But the less experience you have the more you can go wrong with your assumptions.
Post Edited (MagIO2) : 11/11/2009 7:39:33 AM GMT
But seriously, if you have to rip off you should at least create a working reproducer. I can embed your snippet in a piece of code where it works, so obviously your ripped of code must be the problem.
Post Edited (MagIO2) : 11/12/2009 6:58:53 AM GMT