Grasping at the OUTA[] command and what it means...
Kaos Kidd
Posts: 614
Ok... I know this may sound silly, but...
·What I'm trying to fingure out is do I have to convert·a decimal number to binary before I assign it to the outa pins.
I just can't wait until my dev board is completed... then I wouldn't be asking... I'd be doing!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·
'Understanding the following from the manual : ' P0 ~ P7 are Outputs. ' Temp = %11111111 ' OUTA[noparse][[/noparse]0..7] := Temp ' P0~P7 would all be high... 'Now the question... '#1: 'After executing the following... var byte Temp Temp = 5 'Give some value to assign to the outputs OUTA[noparse][[/noparse]0..7] := Temp 'assign Temp's bits to the outputs P0~P7 (should be P0 ~ P7 = %0000101) '#2: 'After executing the following... var byte temp Temp = 15 'Max out a 4 bit number OUTA[noparse][[/noparse]0..3] := Temp 'Only assign the lower 4 bits to the outputs... P0~P3 should = %1111 Temp = 11 'Some number to out put... OUTA[noparse][[/noparse]0..3] := Temp 'Only assign the lower 4 bits to the outputs... P0~p3 should = %1011 '#3: REPEAT Index 0 TO 15 'Count from 0 to 15 OUTA[noparse][[/noparse]0..3] := Index 'Put the count as binary onto the IO pins P0~P3 (for something else to read!) WAITCNT(2_000 + CNT) 'Wait for the something else to read the data... OUTA[noparse][[/noparse]0..3] := 6 'Put the number 6, binary %0110 on P0~P3
·What I'm trying to fingure out is do I have to convert·a decimal number to binary before I assign it to the outa pins.
I just can't wait until my dev board is completed... then I wouldn't be asking... I'd be doing!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·
Comments
·· Values can be specified in Binary, Decimal or Hex...In the memory they are all in Binary anyway so it doesn't matter.· It just depends on your readability.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
(Remember some time ago I was asking for a register type object... well, now it really doesn't matter... two questions answered for the price of one!)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·
· dira[noparse][[/noparse]8..4]~~····················' make P4-P8 outputs
· repeat
··· outa[noparse][[/noparse]8..4] := counter++·······' output counter
··· waitcnt(clkfreq / 4 + cnt)··· ' wait 1/4 second·
Notice the order bits in the brackets -- this is important.· If I'd used [noparse][[/noparse]4..8] the LSB would actually be moved the the MSB LED (this can be useful in some apps).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
In my example I used 0~7 expecting a bit for bit copy... where as your example was reversed 8..4
Oh, and I like your short hand for a 1/4 a second... neat...
And, according to the docs,
Temp := Out[noparse][[/noparse]0..7] would put that bit pattern into Temp... but again, I'd have to verify if I'v got the order reversed or not... simple enough to test.
Oh, I just cant wait!!! Two more little thinggies and my Dev board is done... YES!!!... then it's play time...
I'v been through all the printed matierals from the web site, in "fast glance, get to see it" order...
Now it's time for the "full and detailed" and "lets try it"
Thanks Jon... And Chris...
Shucks, my first APP worth noting is going to have a lot of "contruibiting programmers" listed in it!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1+1=10
See, it's these little things that make it so exciting, and fun.
I would hope someone posted this stuff into the thread tips & tricks and gotchyas (or something like that...)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·