PDA

View Full Version : Test program (way off)



yarisboy
11-07-2010, 10:05 PM
I wrote a test program using a DAT section in spin. When I ran it the first time I had garbage in all three displays. I changed the way I'm trying to get a memory location to shiftout and extinguished my displays. My first guess at least had bad results instead of none.

kuroneko
11-08-2010, 01:15 AM
I wrote a test program using a DAT section in spin. When I ran it the first time I had garbage in all three displays. I changed the way I'm trying to get a memory location to shiftout and extinguished my displays. My first guess at least had bad results instead of none.

It would actually help if you post code that compiles ;)


compile error, use e.g. SHIFTOUT(@DFIG[0],8)
your bit loop isn't sync'd to the clock so the bits are sent as fast as SPIN can manage
BYTE[PNTR][NBYT] will always access the byte after your array (NBYT is constant)
Are you intentionally destroying the array data while sending it (<< 1)?

yarisboy
11-08-2010, 02:25 AM
It would actually help if you post code that compiles ;)


compile error, use e.g. SHIFTOUT(@DFIG[0],8)
your bit loop isn't sync'd to the clock so the bits are sent as fast as SPIN can manage
BYTE[PNTR][NBYT] will always access the byte after your array (NBYT is constant)
Are you intentionally destroying the array data while sending it (<< 1)?

Thanks,
SC

JonnyMac
11-08-2010, 11:34 PM
Forgive me, but the SHIFTOUT method seems terribly convoluted. Is there a reason to use an external clock (external of the method, that is)? If a pure Spin method isn't fast enough then it may be better to write a custom output driver in PASM.

It looks like you want to output one or more bytes from an array, MSBPOST. If that's the case, this version of the method seems cleaner and easier to follow.


pub shiftout(pntr, count) | work

'' pntr : address of byte(s) to shift out
'' count : number of bytes to shift out
''
'' assumes E_PIN, C_PIN, and D_PIN are set as outputs

outa[E_PIN] := 0 ' enable
repeat count
work := byte[pntr++] ' get a byte
repeat 8
outa[C_PIN] := 1 ' create clock pulse
outa[C_PIN] := 0
outa[D_PIN] := work >> 7 ' MSB first
work <<= 1 ' next bit
' outa[D_PIN] := work ' LSB first
' work >>= 1

outa[E_PIN] := 1 ' disable

By the way, I did some testing a few months ago and found that"


outa[PIN] := 1
outa[PIN] := 0

... is faster than:


outa[PIN]~~
outa[PIN]~