Hi Scott! On Wed, 24 Apr 2002, Scott Dattalo wrote: > ; delay table - or you could check the low four bits > ; as shown below > > movf temp,W > sublw 0x0f > addwf pcl,f > > nop > nop Yes, I thought about that, but since I'm putting the assembler inline with C it would take someone smarter than me to figure out how to do it safely. Likely it'd cross a page boundary and I'd be falling in midair. > delay13 > call delay4 > delay9: > call delay4 > delay5 > nop > delay4 > return Yes, this is the kind of thing I was hoping for, keep it coming... > Another variation similar to your solution can be found in: > > http://www.dattalo.com/technical/software/pic/pwm256.txt > > Look specifically at the "end_pulse" routine. (Actually, there several > phase delay tricks in this code.) several is an understatement - where's that can of Pepsi I was guzzling? > For example, here's a portion of it that will give you 5-bit > single-cycle resolution pulse with 11 cycles of overhead. > > BTFSC pw,4 ;01;01; > CALL delay17 ;02;02 > ep1 BTFSC pw,3 ;03;19 > CALL delay9 ;04;20 > BTFSC pw,2 ;05;29 > CALL delay5 ;06;30 > ep2 BTFSS pw,1 ;07;35 > goto $+3 ;08;36 > NOP ; ;37 > GOTO $+1 ; ;38 > ep3 BTFSS pw,0 ;10;40 > BCF PWM ;11;sk > BCF PWM ;12;42 > Nice. > Turning this into a 4-bit delay is straight forward. > > There are also tricks like this: > > movf countLO,w > sublw 0x8 > andlw 7 > addwf > > bsf porta,0 > bsf porta,0 > bsf porta,0 > bsf porta,0 > > bsf porta,0 > bsf porta,0 > bsf porta,0 > bsf porta,0 > This I am not following. How do jump into this nest of bsf's? Thanks! Best regards, Bob -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.