Well, it doesn't take long to learn that THIS is the resource pool. Many of you have motivated me (through your posts) to get into PICs, and I must say I enjoy it ... until I got stuck. I've programmed in BASIC and even assembly for other chips, but this is my first PIC program. Could someone tell me if they see a glaring error that I'm overlooking (I tend to do that when I'm too close to it). I have a program that's supposed to multiplex some characters across 5 7-segment displays for about a second, change to another set of characters for about a second, go blank for another second, then repeat. What my program *actually* does is show the first set of characters and briefly flicker about every second or two. It's like it's resetting itself, and never gets to the second set of characters. I'd like to use TMR0 for the 1 second intervals, but didn't fully understand how to implement it, so I'm using the variable loops. Do I have an unintentional reset? list p=16F84 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _XT_OSC ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The labels following the directive are located in the respective .inc file. ;***** VARIABLE DEFINITIONS PCL EQU 0x02 ; PCL RAM address PortA EQU 0x05 ; PortA RAM address PortB EQU 0x06 ; PortB RAM address TrisA EQU 0x85 ; TRISA RAM address TrisB EQU 0x86 ; TRISB RAM address Status EQU 0x03 ; Status RAM address Z EQU 0x02 ; Status Z Flag = Bit 2 RP0 EQU 0x05 ; Status RP0 bit = Bit 5 DelayL EQU 0x0C ; Delay register LOW byte DelayM EQU 0x0D ; Delay register MID byte DelayH EQU 0x0E ; Delay register HIGH byte Pointer EQU 0x0F ; Display data pointer DispNum EQU 0x10 ; Selected display variable Outer EQU 0x11 ; Outer loop variable Inner EQU 0x12 ; Inner loop variable ;********************************************************************** ; ------------- ; PROGRAM START ; ------------- Main: org 0x00 ; Start address = 0000 (hex) clrf PortA ; Make sure all displays are off clrf PortB ; Make sure all segments are off bsf Status,RP0 ; Set RP0 for RAM page 1 clrf TrisA ; All PortA = outputs clrf TrisB ; All PortB = outputs bcf Status,RP0 ; Set RP0 for RAM page 0 bcf Status,0 ; Reset the Carry bit movlw 0x02 ; Set the Inner loop movwf Inner movlw d'05' ; Set w = 5 movwf Outer ; Set Outer = 5 (move w to Outer) Show1: decfsz Inner ; Decrement Inner loop goto First1 ; Z = 1, enter display routine decfsz Outer ; Z = 0, decrement the Outer loop goto First1 ; Z = 1, enter display routine ; Z = 0, exit the loop clrf PortA ; Make sure all displays are off clrf PortB ; including the first one movlw 0x02 ; Set the Inner loop movwf Inner movlw d'16' ; Set w = 16 movwf Outer ; Set Outer = 16 (move w to Outer) Show2: decfsz Inner ; Decrement Inner loop goto First2 ; Z = 1, enter display routine decfsz Outer ; Z = 0, decrement the Outer loop goto First2 ; Z = 1, enter display routine ; Z = 0, exit the loop Blank: clrf PortA ; Make sure all displays are off clrf PortB ; including the first one Call Delay2 ; Wait for 1 second movlw 0x02 ; Set the Inner loop movwf Inner movlw d'16' ; Set w = 16 movwf Outer ; Set Outer = 16 (move w to Outer) Goto Show1 ; Repeat the display loop First1: clrf Pointer ; Reset the pointer to 0 clrf DispNum ; Reset the display number movf Pointer,w ; Put Pointer into W call DataTable1 ; Put digit value in W movwf PortB ; Now, display the new digit bsf PortB,0x07 ; Enable the first display call Delay1 ; Brief pause bcf PortB,0x07 ; Disable the display incf Pointer ; Add 1 to Pointer value incf DispNum ; Make DispNum = 1 More1: movf Pointer,w ; Put Pointer into W call DataTable1 ; Put digit value in W movwf PortB ; Now, display the new digit movf DispNum,w ; Put DispNum value in W movwf PortA ; Enable the next display call Delay1 ; Brief pause clrf PortA ; Disable the display incf Pointer ; Add 1 to Pointer value rlf DispNum ; Rotate the DispNum value left movlw d'16' ; See if DispNum value has rotated too far xorwf DispNum,w ; to keep the range from pin 0 - 3 btfsc Status,Z ; Test the Zero bit goto Show1 ; Z = 0, back to main loop goto More1 ; Z = 1, next display of current loop First2: clrf Pointer ; Reset the pointer to 0 clrf DispNum ; Reset the display number movf Pointer,w ; Put Pointer into W call DataTable2 ; Put digit value in W movwf PortB ; Now, display the new digit bsf PortB,0x07 ; Enable the first display call Delay1 ; Brief pause bcf PortB,0x07 ; Disable the display incf Pointer ; Add 1 to Pointer value incf DispNum ; Make DispNum = 1 More2: movf Pointer,w ; Put Pointer into W call DataTable2 ; Put digit value in W movwf PortB ; Now, display the new digit movf DispNum,w ; Put DispNum value in W movwf PortA ; Enable the next display call Delay1 ; Brief pause clrf PortA ; Disable the display incf Pointer ; Add 1 to Pointer value rlf DispNum ; Rotate the DispNum value left movlw d'16' ; See if DispNum value has rotated too far xorwf DispNum,w ; to keep the range from pin 0 - 3 btfsc Status,Z ; Test the Zero bit goto Show2 ; Z = 0, back to main loop goto More2 ; Z = 1, next display of current loop ; ----------------------------- ; SUBROUTINE: waste time (<3 ms) ; ----------------------------- Delay1: clrf DelayL ; Clear DelayL to 0 movlw 0x05 ; Set DelayM = '5' movwf DelayM Wait1: decfsz DelayL ; Subtract 1 from DelayL goto Wait1 ; If not 0, goto Wait1 decfsz DelayM ; Subtract 1 from DelayM goto Wait1 ; If not 0, goto Wait1 return ; Finish the delay ; -------------------------------------- ; SUBROUTINE: waste more time (1 second) ; -------------------------------------- Delay2: clrf DelayL ; Clear DelayL to 0 clrf DelayM ; Clear DelayM to 0 movlw 0x0A ; Set DelayH = '10' movwf DelayH Wait2: decfsz DelayL ; Subtract 1 from DelayL goto Wait2 ; If not 0, goto Wait2 decfsz DelayM ; Subtract 1 from DelayM goto Wait2 ; If not 0, goto Wait2 decfsz DelayH ; Subtract 1 from DelayH goto Wait2 ; If not 0, goto Wait2 return ; Finish the delay ; ----------------------------------------- ; SUBROUTINE: lookup table for display data ; ----------------------------------------- ; Bit 0 = Segment A ; Bit 1 = Segment B ; Bit 2 = Segment C ; Bit 3 = Segment D ; Bit 4 = Segment E ; Bit 5 = Segment F ; Bit 6 = Segment G ; Bit 7 = No connection DataTable1: addwf PCL ; Add W value to PCL retlw b'01110110' ; First symbol, first display retlw b'00111101' ; Second symbol, first display retlw b'01011011' ; Third symbol, first display retlw b'00111111' ; Fourth symbol, first display retlw b'01101001' ; Fifth symbol, first display DataTable2: addwf PCL ; Add W value to PCL retlw b'01000110' ; First symbol, second display retlw b'00101100' ; Second symbol, second display retlw b'00011001' ; Third symbol, second display retlw b'00110011' ; Fourth symbol, second display retlw b'01001001' ; Fifth symbol, second display END By the way, I DID borrow some of the code (I read someone else post the "Why reinvent the wheel?" theory). I altered variables much of the code for my application. When I ran it in MPLAB's simulator (using NOPs for the delays), it seemed to run OK. But my programmed chips are running as explained at top. Thanks in advance, ATM __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body