Dip switch with 4 bits: DIP | Time ------------------------------- 0000 | 1ms 0001 | 2ms 0010 | 3ms 0011 | 4ms ;============================================ Assuming that you have the dip sw on PortB. Don't forget to use pull-downs on inputs !! that are floating when dip sw contacts are open !! movf portb,w ;get value of dip sw movwf dtime ;into variable ;possibly mask non-switch bits movlw b'00001111' andwf dtime,f ;eg dip sw on only b0 to b3 ;------------------------------------- ;possibly test for dtime = 00 if you don't want a 256ms delay movf dtime,f btfss status,z ;z=1 if dtime=00 ;........valid non-00 switch value, use it, goto rest of program ;........invalid switch value, ie = 00, goto somewhere else ;-------------------------------------- movf dtime,w ;get original (stays intact for other routines) movwf c_dtime ;copy it call msdelay ;call 1ms delay "dtime" times decfsz c_dtime,f ;destroy copy goto $-2 ;........ rest of code ;===================================== ;1ms delay - call 100us delay 10 times msdelay movlw 0xf6 movwf cnt1 call delay100 incfsz cnt1,f ;count up to 00 goto $-2 ;call 100us again return ;100us delay at 217ns instruction cycle (18.432MHz, my example) delay100 movlw 0x62 ;use Stopwatch to optimise for 100us movwf cnt2 incfsz cnt2,f ;count up to 00 goto $-1 return -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.