Hi I did something like this, ages ago (Z-80, 8085 era). I just use one
byte with a circular counter. You just have to rotate and output one
particular bit (B0 ie.). I couldn't find nothing faster than this, Z80 has
rotates os shifts, I don't remember now, where the carry bit don't interfere
with operation, it makes the things even easier ( b0->b7 , b1 ->b2,....
b7->b6).
You just have to perform the rotation and output a particular bit. Hope
it helps.
Regards
Horta
{Quote hidden}> I've spent some time playing with an RC car controller and needed a very
> fast 2 channel PWM routine. Resolution was not important, so 8 steps (3
> bits) was fine.
>
> My first attempt which I'm sure can easily be bettered:
>
> clrf outport ; clear shadow register
> incf pwmcount,w ; increment pwm counter
> andlw 0x07 ; 8 step PWM, so roll counter over after 7
> movwf pwmcount
>
> movf pwmset1,w
> subwf pwmcount,w ; subtract setpoint from counter
> skpc
> bsf outport,0 ; result negative so turn on PWM output in
> shadow register
>
> movf pwmset2,w
> subwf pwmcount,w ; subtract setpoint from counter
> skpc
> bsf outport,1 ; result negative so turn on PWM output in
> shadow register
>
> So this gives a 4 cycle overhead for the counter and clearing the shadow
> register, and 4 cycles for each additonal channel. This actually gives
nine
{Quote hidden}
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads