I need to understand this.
Ron Sutcliffe
Posts: 420
A few days ago I was writing some driver code in Forth for the HX512K card which I have connected toa·demo board and could not get it would to work has I would have expected.
So I decided to write this Spin code below. No bit twiddling just simple writes to a register.
The Card initializes OK but the state machine does not reflect the state set by the low order nibble. It always comes comes up in the same state. (AKA $F nibble) Just the same has my forth driver
My PASM Driver works ok so I know that the hardware is OK. (but is it ?)
I don’t have access to a scope, but there must be a positive excursion during the register write cycle on Pins 0..3 Its the only explanation I can think of.
It would be nice to get an angle on this. It occured to me that I could even write a very compact piece of driver code for the HX512K that would fit nicely into the Zicog.
Ron
Comments
-Phil
outa[noparse][[/noparse]0..31]:= $03000008
to
outa[noparse][[/noparse]31..0]:= $03000008
The byte which contains $03 is written to pins 0-7 AND in opposite order in the first case.
The byte which contains $03 is written to pins 31-24 in expected order in the second case.
Same is true for dira[noparse][[/noparse] ... ].
So, according to your comment in the SPIN I'd guess that you've chosen the wrong order. Use outa[noparse][[/noparse]31..0] instead. This is logically correct, as the most significant bit in the number is on the left. So, the left part of the range (31..) maps to that representation.
Hope this helped and was clear enough to understand.
Ok, here is the new Spin code. The result is the same.· The CPLD is still seeing $F on the prop pins 0..7 on the rising edge of clock (Pin 26)
Spin code· outa [noparse][[/noparse]27..0] := $400_0008 but the· CPLD sees $400 _000F····
Hope this makes sense or have I missed something else again ?
Ron
Post Edited (Ron Sutcliffe) : 11/30/2009 12:22:29 PM GMT
That may help you to step through the logic. He has both Spin and Pasm source.
I have this also.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
PIN 24 is ctrl _0 and Pin 25 is ctrl_1········
Clk is on Pin 26 and data is latched in a positive going edge.
Standard HX512K hydra mem board but·using Prop Demo Board.· My PASM Driver works fine
Hence we have dira[noparse][[/noparse]27..0]:= $700_000F set pin outputs
To set the machine state (0..$F) on pins 0..7
I am trying to do that without bit twiddling with a mask. So the idea was to do a outa[noparse][[/noparse]27..0]:= $400_0000 but........
I am sure that the problem is a result of writing the data on pins 0..7· ($00) whilst
writing the clock pulse to pin 26 ·at the same time·AKA outa[noparse][[/noparse]27..0]:= $400_0000
The result is that $FF appears on pins 0..7·if ·the DIRA register had been previously set AKA DIRA[noparse][[/noparse]27..0]:= $700_00FF
Any further thoughts ?
Ron
Ron
Post Edited (Ron Sutcliffe) : 11/30/2009 1:24:14 PM GMT
I understand now. Thanks for the clarification.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Ron
outa := $03000008
Is the code you need in the end SPIN or PASM and your currently only testing with SPIN? If it's PASM you can use the
movs outa, #8
or outa, clk_mask
andn outa, clk_mask
... or to make it even faster, setup a counter to create the clock signal and have several movs in a row.
PASM
I was thinking in terms of a simpe table of longs to drive the CPLD. Keeping code to a minimum, but I can only do that if I can clk and load in a single write to the outa register. I will look at your the idea of running the clk in the table driver.
Ron