Having trouble with the VGA Text driver
Copper
Posts: 48
This is only my second post, and while I know quite a bit more than I did when I made my first post, I'd still say I'm "new to programming." Just FYI.
Currently I'm working on writing a simple "debug terminal" for some synth code I found, using the VGA_Text driver that came with the Propeller Tool v1.3. Unfortunately, I'm having some trouble configuring the counter modules on my various cogs.
this (above) is what I get with the "synth cog" commented out.
and this is what I get with the "synth cog" left in.
I imagine there is something more I need to be doing to correctly configure my counter modules. But my "potentiometer cog" works fine (with two counters configured for pos detection on an RC Decay circuit).
Currently I'm working on writing a simple "debug terminal" for some synth code I found, using the VGA_Text driver that came with the Propeller Tool v1.3. Unfortunately, I'm having some trouble configuring the counter modules on my various cogs.
this (above) is what I get with the "synth cog" commented out.
and this is what I get with the "synth cog" left in.
I imagine there is something more I need to be doing to correctly configure my counter modules. But my "potentiometer cog" works fine (with two counters configured for pos detection on an RC Decay circuit).
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ text : "vga_text" VAR long stack[20] DAT pot1 long 0 pot2 long 0 frequency long 0 cogA byte 0 cogB byte 0 PUB Main cogA:= cognew(get_pot, @stack[0]) cogB:= cognew(re_synth, @stack[10]) text.start(16) repeat text.str(string(13, " Debug...", 13, 13, " pot1==", 13, " Bin==")) text.bin(pot1,16) text.str(string(13, " Dec==")) text.dec(pot1) text.str(string(13, 13, " pot2==", 13, " Bin==")) text.bin(pot2,16) text.str(string(13, " Dec==")) text.dec(pot2) text.str(string(13, 13, " frequency==")) text.dec(frequency) text.str(string(1)) PUB re_synth | x repeat x:=0 x|=(pot1>>8 + pot2>>3) frequency:=x Synth("A", 4, x) 'Synth({Counter"A" or Counter"B"},Pin, Freq) PUB Synth(CTR_AB, Pin, Freq) | s, d, ctr, frq Freq := Freq #> 0 <# 128_000_000 'limit frequency range if Freq < 500_000 'if 0 to 499_999 Hz, ctr := constant(100 << 26) 'set NCO mode ( desired mode 100 shifted 26bits left into ctr-mode register [30..26] ) s := 1 '..shift = 1 else 'if 500_000 to 128_000_000 Hz, ctr := constant(010 << 26) '..set PLL mode d := >|((Freq - 1) / 1_000_000) 'determine PLLDIV s := 4 - d 'determine shift ctr |= d << 23 'set PLLDIV frq := frqfraction(Freq, CLKFREQ, s) 'Compute FRQA/FRQB value ctr |= Pin 'set PINA to complete CTRA/CTRB value if CTR_AB == "A" CTRA := ctr 'set CTRA FRQA := frq 'set FRQA DIRA[Pin]~~ 'make pin output if CTR_AB == "B" CTRB := ctr 'set CTRB FRQB := frq 'set FRQB DIRA[Pin]~~ 'make pin output PUB frqfraction(a, b, shift) : f if shift > 0 'if shift, pre-shift a or b left a <<= shift 'to maintain significant bits while if shift < 0 'insuring proper result b <<= -shift repeat 32 'perform long division of a/b f <<= 1 if a => b a -= b f++ a <<= 1 pub get_pot ctra[30..26] := 000 ' Set mode to "POS detector" ctra[5..0] := 3 ' Set APIN to 17 (P17) frqa := 1 ' Increment phsa by 1 for each clock tick ctrb[30..26] := 000 ' Set mode to "POS detector" ctrb[5..0] := 2 ' Set APIN to 16 (P16) frqb := 1 ' Increment phsa by 1 for each clock tick repeat ' Charge RC circuit. dira[3] := outa[3] := 1 ' Set pin to output-high waitcnt(clkfreq/50_000 + cnt) ' Wait for circuit to charge ' Start RC decay measurement. It's automatic after this... phsa~ ' Clear the phsa register dira[3]~ ' Pin to input stops charging circuit waitcnt(clkfreq/50+cnt) 'Wait for counter module to measure decay automatically pot1 := (phsa - 624) #> 0 dira[2] := outa[2] := 1 ' Set pin to output-high waitcnt(clkfreq/50_000 + cnt) ' Wait for circuit to charge ' Start RC decay measurement. It's automatic after this... phsb~ ' Clear the phsa register dira[2]~ ' Pin to input stops charging circuit waitcnt(clkfreq/50+cnt) 'Wait for counter module to measure decay automatically pot2 := (phsb - 624) #> 0Thanks for any suggestions.
Comments
Usually, I give at least 100...
hmmm...