Hello This is a sample of a program that is not working. I want to read a potentiometer and display the results via LED s. The program displays the results, but the overflow does not work. The LED display 255, then appear to roll over. It should read a max of 250. I have tried 8 variations without success. Could someone please tell me what I am missing. I can sleep when I can't solve a problem. Thank you Nichole #INCLUDE <16C84REG.H> TITLE "MEASURE POT ON LED, SHOW OVERFLOW=250" LIST P = 16F84 ; FILE NAME POTCAL8.ASM ; Clock = 4MHz -> 1 instruction takes 1us ; PULSE1 equ 0Ch ; pulse time high CNTR PULSE2 equ 0Dh ; pulse time high CNTR HB equ 0EH ; Heart Beat High BUTC equ 0FH ; button loop cntr PULSE1S equ 10h ; pulse time high STORE PULSE2S equ 11h ; pulse time high STORE DELAY1 equ 12h ; 1 ms count DELAY2 equ 13h ; # ms /4 of low time DATAPRT equ 14H ; data port CTRLPRT equ 15H ; control port BUT1FLG equ 16H ; button 1 pressed flag BUT2FLG equ 17H ; button 2 pressed flag BUT1CNT equ 18H ; button 1 COUNTER BUT2CNT equ 19H ; button 2 COUNTER PULSE1PS1 equ 1Ah ; pulse time high STORE PULSE2PS1 equ 1Bh ; pulse time high STORE PULSE1PS2 equ 1Ch ; pulse time high STORE PULSE2PS2 equ 1Dh ; pulse time high STORE ;******************************************************************** ;*******************************; ; MAIN ENTRY POINT ; ;*******************************; ORG 0X000 GOTO START ;*******************************; ; INTERRUPT SERVICE CODE ; ;*******************************; ORG 0X004 RETFIE ;return from interrupt ;*******************************; ; SETUP PORTS Etc. ; ;*******************************; START MOVLW B'10000111' OPTION ;set up the OPTION,Disable Bpullup ; MOVLW B'00000000' MOVWF 0BH ;Set up the INTCON register ; MOVLW B'00000000' TRIS PORTA ;setup port A BITs 0-3 as OUTPUT MOVWF PORTA ;clear port A MOVLW B'00000000' TRIS PORTB ;setup port B BITs 0-1 as output ;*******************************; ; FIRST SERVO ; ;*******************************; BEGIN MOVFW PULSE1S ;LOAD Pulse Store MOVWF PULSE1 ;LOAD Pulse DISPLAY MOVWF PORTB ;DISPLAY PULSE1 8 LED=COUNT IN b' ;***********************************; ; READ POTS B0-B1 ; ;***********************************; MOVLW B'00000000' TRIS PORTA ;setup port A BITs 0-1 as output CLRF PULSE1S ;Clear previous value CAP_C BSF PORTA,0 ;START CAPACITOR CHARGE NOP ;Time to charge MOVLW b'11111111' ;Set PortA,0 to input TRIS PORTA ;Teach portA MEAS1 CLRWDT BTFSS PORTA,0 ;Test A0 skip if 1 RETURN ; INCFSZ PULSE1S,F ;Inc pulse1s skip if 0 GOTO MEAS1 ; MOVLW 0FAH ;LOAD MAX PULSE=250 SUBWF PULSE1S, w ;Subtract current value from it BTFSS STATUS, C ;If carry = 1, result is positive GOTO BEGIN ;No it is not -> goto down MOVLW 0FAH ;Load Maximum Pulse Width MOVWF PULSE1S ;Store it in the position Value location FINAL GOTO BEGIN ;restart the MAIN Programme loop ;*********************************; ; DUNO HOW WE GOT HERE ; ;*********************************; ERROR_ SLEEP ; END ;The End