Sigma-delta/TV_text problem
Help, someone,
For some reason this code doesn't quite work the way expected. Appears the ∑-∂ A2D works, because it supplies variable values back to Spin. And if the ' djnz hpix,#:loop' line uses ':initloop' instead the TV_text output works, but no output with :loop.
I took the ∑-∂ code from AN001, and that worked fine. But after I added the 40 sample loop it didn't. Anyone spot what's not right?
Pin group 12 is used for TV_text.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
For some reason this code doesn't quite work the way expected. Appears the ∑-∂ A2D works, because it supplies variable values back to Spin. And if the ' djnz hpix,#:loop' line uses ':initloop' instead the TV_text output works, but no output with :loop.
I took the ∑-∂ code from AN001, and that worked fine. But after I added the 40 sample loop it didn't. Anyone spot what's not right?
'* Sigma-delta A-D converter for HPulse sensor signal
DAT org 0 '
'entry ' --- Debugger Kernel add this at 'entry' --- MUST BE LAST COG IF USE 'PASD'
' long $34FC1202,$6CE81201,$83C120B,$8BC0E0A,$E87C0E03,$8BC0E0A
' long $EC7C0E05,$A0BC1207,$5C7C0003,$5C7C0003,$7FFC,$7FF8
' --------------------------------------------------------------
A2D or DIRA,Msk8 ' make A8 an output
or DIRA,asm_dira ' make A2 (pin 3)(ADC) an output
movs CTRA,#adcpin ' POS w/FEEDBACK code ???
movd CTRA,#fbpin '
movi CTRA,#%01001_000
mov FRQA,#1
mov asm_cnt,cnt
add asm_cnt,asm_cycles
:initLoop mov hpix,#40 'count 40 character/width of screen
mov ptr,PAR ' init ptr to begin of locations
andn OUTA,Msk8 ' set marker LO TEMP
nop ' extra wide to view start
or OUTA,Msk8 ' set marker HI
:loop WAITCNT asm_cnt,asm_cycles ' wait for next cnt value
andn OUTA,Msk8 ' set marker LO TEMP
or OUTA,Msk8 ' set marker HI
mov asm_sample,PHSA
sub asm_sample,asm_old ' WHAT'S THIS DOING ????
add asm_old,asm_sample
' wrlong asm_sample,PAR ' write value to RAM
wrlong asm_sample,ptr ' store a sample
add ptr,#4 ' increment to next long
djnz hpix,#:initloop ' WHY NO TV OUT W/ ':loop'
jmp #:initLoop
'
' Initialized data
asm_cycles long |< bits - 1 ' sample time
asm_dira long |< fbpin ' output mask
Msk8 LONG |<8 ' TEMP - for time marker on A8
' Uninitialized data
ptr RES 40 ' holds pointer to PAR, for 40 long samples
hpix RES 1 ' #samples counter
asm_cnt RES 1
asm_old RES 1
asm_sample RES 1
FIT 496
Pin group 12 is used for TV_text.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Comments
What does par get initialized with? It needs to be the address of a long array in the hub that's at least 40 longs long. Your ptr array does not exist in hub memory at all, BTW, since you've used res to define it. What I'm getting at is this: if par is initialized with @ptr, writing 40 longs to that address in the hub is going to clobber a lot of stuff that that "array" overlaps, possibly including some of the video stuff.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 9/10/2009 2:12:37 AM GMT
Thanks Phil. I think you've pointed out the error of my ways; forgot to make an array at where par points. Too close to the 'forest'; "what trees?"
Yes, that way what was missing, the array, therefore it was overwriting some other variables. 'New eyes' on a listing makes a huge difference, plus different experience to recognize the missing stuff.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Post Edited (Harley) : 9/10/2009 5:54:28 PM GMT