* Answered * The second bit of code does not run
Pliers
Posts: 280
I'm trying to get a second COG running a counter.
The first cog launches and the counter works, the second cog does not work.
I think the code is self explanatory.
If you are not familiar with View Port, some of the stuff might seem strange.
The problem is how I'm launching the second COG, I think.
The first cog launches and the counter works, the second cog does not work.
I think the code is self explanatory.
If you are not familiar with View Port, some of the stuff might seem strange.
The problem is how I'm launching the second COG, I think.
Con _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long parameter1 long parameter2 long frame[400] 'stores measurements of INA port OBJ ' include 2 ViewPort objects: vp : "Conduit" ' transfers data to/from PC qs : "QuickSample" 'samples INA continuously in 1 cog- up to 20Msps Pub go vp.register(qs.sampleINA(@frame,1)) 'sample INA into <frame> array optional_configure_viewport 'optionally configure viewport's interface vp.share(@parameter1,@parameter2) 'share the <freq> variable parameter2 :=80 ' 80 percent duty cycle parameter1 :=50 ' 50 percent duty cycle cognew(@entry, @parameter1) 'Starting a new cog in assembly code. cognew(@entry2, @parameter2) 'Starting a second cog in assembly code. repeat pub optional_configure_viewport vp.config(string("var:io(bits=[mine[0..5]]),Parameter,Parameter2")) vp.config(string("start:lsa")) vp.config(string("dso:timescale=10ms")) vp.config(string("lsa:view=io,trigger=io[0]r,timescale=500ns")) vp.config(string("edit:Parameter(mode=text),Parameter2(mode=text)")) Dat org entry mov dira, diraval 'set APIN to output mov ctra, ctraval 'establish counter A mode a Apin mov frqa, #1 'set counter to increment by 1 mov time, cnt 'record current time add time, period 'establish next period :loop rdlong value, par 'get an up to date pulse width waitcnt time, period 'wait until next period neg phsa, value 'back up phsa so that it trips "value" cycles from now jmp #:loop entry2 mov dira, diraval2 'set APIN to output mov ctra, ctraval2 'establish counter A mode a Apin mov frqa, #1 'set counter to increment by 1 mov time2, cnt 'record current time add time2, period2 'establish next period :loop2 rdlong value2, par 'get an up to date pulse width waitcnt time2, period2 'wait until next period neg phsa, value2 'back up phsa so that it trips "value" cycles from now jmp #:loop2 diraval long |< 0 ' APIN = 0 ctraval long %00100 << 26 + 0 ' NCO/PWM APIN = 0 period long 100 ' 800 khz period (_clkfreq/period) diraval2 long |< 2 ' APIN = 2 ctraval2 long %00100 << 26 + 2 ' NCO/PWM APIN = 2 period2 long 100 ' 800 khz period (_clkfreq/period) time2 res 1 value2 res 1 time res 1 value res 1
Comments
Thank you very very much.