Hi Glen, I can't follow your code, It wraps around and the formatting makes it hard to read. But what little I can decipher I don't understand what you are trying to do with the "xorwf chksw" what you have looks like.... caltab CALL table ; use look up table MOVWF strttmr ; move value from table to strttmr XORWF chksw ; compare chksw value (switch value) BZ caltab table ADDWF PCL,f ; sw value : time : RETLW d'25' ; 00 : 250ms (switch RETLW d'50' ; 01 : 500ms (switch RETLW d'75' ; 10 : 750ms (switch RETLW d'100' ; 11 : 1000ms (switch What this will do is as follows, first time correct lookup value will be returned, and the table will be re-entered with the return value instead of the switch value, this will result in a jump past the end of the table with unpredictable results! :-( I would suggest the following. 1. Get the hardware working correctly first, you might have to put a pull down on RB3. 2. Constrain W as follows table ANDLW 0x03 ; ADDWF PCL,f ; sw value : time : RETLW d'25' ; 00 : 250ms (switch RETLW d'50' ; 01 : 500ms (switch RETLW d'75' ; 10 : 750ms (switch RETLW d'100' ; 11 : 1000ms (switch 3. Check for TMR0 overflow flag rather than looking at the timer value directly. Better yet handle the TMR0 overflow in an interrupt. ==============[ original message ]================ >hi & sorry again ! >i don't know how to get around this problem !! >i still can't get the table to work properly ! > >the table puts the first value into strttmr regardless of the switch >settings > >**how do i get the switch settings value to access the corresponding >value >in the lookup table & place it into strttmr? *** > >eg switch setting = 1 0 (rb0 = 1 , rb1 = 0 ) >table value at 10 = d'75' >put d'75' into strttmr >the problem area is in the section 'select switch setup ' >;************************ports setup**************************** >;********************************************************************** > clrf STATUS >;============= prescaler setup ===pullups enabled=========== > movlw b'00000111' ;scale 1:256 , pullups >enabled > OPTION >;********************************************************************** >;********************************************************************** >; ============= select switch setup ============== > ;code below is used for 2 switches > ; init strttmr from input pins > movf PORTB,w ;get values of RB0 & RB1 > andlw 0x03 ; extract out bits 0,1 of PORTB >(table sw value) > movwf chksw ;put rb0 & rb1 values in register >chksw > >caltab CALL table ; use look up table > movwf strttmr ;move selected value from table >to strttmr > xorwf chksw ;compare with chksw value >(switch value) > btfsc STATUS,Z ;if same , skip next instruction > > GOTO caltab >;******************TABLE TO GO IN SUB ROUTINES*********************** >table addwf PCL,f ;sw value : time : > retlw d'25' ; 00 : 250ms (switch >position 1) > retlw d'50' ; 01 : 500ms (switch >position 2) > retlw d'75' ; 10 : 750ms (switch >position 3) > retlw d'100' ; 11 : 1000ms (switch >position 4) >;********************************************************************** >;********************************************************************** >; ============== program start ============= > movlw 0x00 ;move 00 hex to register w > movwf PORTB ;move register w to PORTB >(clear PORTB) >;============= prescaler setup ===pullups disabled=========== > movlw b'10000111' ;scale 1:256 , pullups >disabled > OPTION >; ============= initialise timer setup ============== >initmr movlw .215 ;40 * .000256 = 10 ms > movwf TMR0 > >loop CALL chcycs ;check for zero crossing > CALL sttimer ;call initial time delay > CALL tog ;toggle outputs >; ============= check timer ============== > movf TMR0,w ;move f reg to w > btfsc STATUS,Z ;if !0 ,GOTO loop > GOTO loop > decfsz strttmr,f ;decrement strttmr by >1 > GOTO initmr ;go around for next delay > > ;drop thru to stop >stop GOTO stop >;======================delay sub-routines======================= >; > end > >thanks very much for your help because i'm LOST !! >glen Ray Gardiner ray@hdc.com.au