Understanding DIRA and OUTA in multiple cogs
I thought I knew how to use dira and outa, but I am seeing some strange behavior in some code I am testing. So, let me pose this question.
If, in cog 1, I set all bits in dira to zero, and in cog 2 I set 1 or more bits of dira to '1', will writing 1's into outa of cog 1 affect any of the output pins?
Lucidman
Post Edited (lucidman) : 11/5/2007 2:02:07 AM GMT
If, in cog 1, I set all bits in dira to zero, and in cog 2 I set 1 or more bits of dira to '1', will writing 1's into outa of cog 1 affect any of the output pins?
Lucidman
Post Edited (lucidman) : 11/5/2007 2:02:07 AM GMT

Comments
-Phil
I took the uOLED-96-Prop-Demo_V4.spin demo program and modified it to launch a cog with some assembly code in it. The new cog would write some things to the four outputs P18, P19, P20 and P21. The problem is that it causes the graphics module to stop displaying what I commanded it to display, i.e it goes blank.
Here is the assembly code in the new cog that I started with.
org entry mov dira, setup_bits_a loop mov t1, t2 shl t1, #18 mov outa, t1 add t2, #1 jmp loop '33222222 22221111 11111100 00000000 '10987654 32109876 54321098 76543210 setup_bits_a long %00000000_00111100_00000000_00000000 t1 long 0 t2 long 0So I decided to try something strange. I set all the dira bits to zero, and it still causes the graphics module to go blank. Go figure!
org entry mov dira, #0 loop mov t1, t2 shl t1, #18 mov outa, t1 add t2, #1 jmp loop t1 long 0 t2 long 0·Furthermore, if I change the·code so it only writes zeroes to outa, it works fine, The screen does not go blank. Again, go figure.
I'm baffled.
Any ideas?
(not so) Lucidman
Thanks,
Lucidman
·
You da man!
That was the problem.
Thanks
Lucidman.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
When in doubt, refer to the datasheet! If you'll notice on the diagram of the cogs that shows the I/O chain, the output of each cog is conditioned by the direction register. If the direction register bit in the cog is zero, the output of the cog will be forced to zero regardless of the value in the output register.
Reading pays!