Can my BS2 do this or do I need another chip?
ERM
Posts: 34
Hello all,
I'm going to be real basic about this.· How can I do both these programs below at the same time without any interuption.
Led 1:
high 1
pause 50
low 1
pause 50
high 2
pause 50
low 2
pause 50
goto Led 1
and
Led 2:
high 1
pause 50
low 1
pause 50
high 1
pause 50
low 1
pause 50
high 2
pause 50
low 2
pause 50
high 2
pause 50
low 2
pause 50
goto Led 2
Any ideas or will I need another chip that can put these commands seperately into the different slots on the EEPROM?· Thank in advance
I'm going to be real basic about this.· How can I do both these programs below at the same time without any interuption.
Led 1:
high 1
pause 50
low 1
pause 50
high 2
pause 50
low 2
pause 50
goto Led 1
and
Led 2:
high 1
pause 50
low 1
pause 50
high 1
pause 50
low 1
pause 50
high 2
pause 50
low 2
pause 50
high 2
pause 50
low 2
pause 50
goto Led 2
Any ideas or will I need another chip that can put these commands seperately into the different slots on the EEPROM?· Thank in advance
Comments
·· It's not possible since both programs use the same I/O pins.· If there were different pins being used, this might be possible.· But two programs or tasks cannot access the same pin at the same time.· Now, while the BASIC Stamp is a single-tasking micro, it is possible to turn on/off multi pins at the same time.· But they need to be on different pins first.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
as the first high low combo is trying to turn on the same pin you only need 1 of the loops to do it
Chris, I don't know but when you say " it is possible to turn on/off multi pins at the same time" is true on a micro scale of time would not each instruction to turn on each pin take a few clock cycles? Is there a way to flip all pins on/off from the pbasic code? or would you have to have direct access to the latching bits on the PIC? I was reading some assembler code for the atmel chips and that's where I saw the latching register I think it was called that.
[noparse][[/noparse]/code]
Led 1:
high 1
pause 50
low 1
pause 50
high 2
high 1
pause 50
low 2
low 1
pause 50
high 1
high 2
pause 50
low 1
low 2
pause 50
high 2
pause 50
low 2
pause 50
goto Led 1
[noparse][[/noparse]code]
·· Say you want to turn on P0 and P3 at the same time, and a half second later turn those off and turn on P1 and P2.· As long as your DIRS register was already setup with the appropriate pins made an output, the you could do the following...
··This technique can work for all 16 I/O pins.· Likewise groups of pins can be read at the same time.· If you still don't understand, let me know and I will post a better example.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Set all pins high would be...
·· But you must first have the corresponding direction register setup properly.· If you run the following program...
You'll notice nothing will happen...However, if you run the following...
Then you get the desired results.· It works the same way for inputs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
if you are working with just 2 or 3 pins 0-2 for example and you wanted to leave pin 3 in its current state you would have to either read its state (in or outupt mode) and set the bit to the same if using the DIRA=%1111 or use three statements DIR0=%1 etc...
Is it common practice when using OUTS and OUTA etc to use the direction register once at the start of a loop or section of code or just plug both in every time. I guess what I am saying is can anything from outside your code change the direction register once you set it?
EDIT on above post bits 5,6,7, and 8 should read bits 4,5,6 and 7
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com