Time "?" running 100Khz on a waitcnt
I am hitting my head against the wall trying to calculate the speed of this loop.
I want to run it around 100Khz for an IC. My prop is running at 80Mhz
My thinking is that I am running at [noparse][[/noparse] 80Mhz / 1000 = 80khz] = seconds at 12.5uS. Is this right?
So running at 100Khz I thought that I would change to this
Please inform me if I am making a mistake.
Thanks
I want to run it around 100Khz for an IC. My prop is running at 80Mhz
PUB ShiftIn (Dpin, Cpin, Mode, Bits) : Value | InBit dira[noparse][[/noparse] Dpin ]~ outa[noparse][[/noparse] Cpin ]:=0 dira[noparse][[/noparse] Cpin ]~~ InBit~ Value:=0 REPEAT Bits !outa[noparse][[/noparse] Cpin ] !outa[noparse][[/noparse] Cpin ] InBit:= ina[noparse][[/noparse] Dpin ] Value := (Value << 1) + InBit [b]waitcnt(1000 + cnt)[/b]
My thinking is that I am running at [noparse][[/noparse] 80Mhz / 1000 = 80khz] = seconds at 12.5uS. Is this right?
So running at 100Khz I thought that I would change to this
[b]waitcnt(800 + cnt)[/b]
Please inform me if I am making a mistake.
Thanks
Comments
You could time the critical section with something like this...
Post Edited (Brian Fairchild) : 4/27/2009 4:36:24 PM GMT
you forget that both assignments need some time as well.
Before starting the loop you should do a measurement without any code in between and subtract that from the measurements later on.
ClockStart:=cnt
ClockEnd:=cnt
MeasurementRuntime:=ClockEnd-ClockStart
@Zap-o:
Just remove the waitcnt and see how fast it is then.That's closest you can get to 100kHz using SPIN.
You should remove the InBit. It's an additional assignment which only consumes time.