--17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Description: E-Mail Body Text Content-Disposition: inline The first bit of code I wrote, after doing the equivalent of "hello world", was to multiplex 4 7-segment LED displays. I wrote code which should start by showing all zeroes on the display and count up from 0000 to FFFF and roll over, repeating infinately. As it is, the code I wrote will count from 0000 to 000F, then start at all zeroes again. I tried running it in MPLAB's debugger, but the debugger runs straight through the code, from top to bottom, and seems to be ignoring any and all CALLs and GOTOs that are placed in it. The watchlist updates none of the defined variables (EQUs) that I can tell. In short, I haven't got a clue what is going on when I try and use the debugger. I'm hoping that I am missing something simple, but I have no idea so am asking for help in determening what is wrong. The physical layout is that each 7-segment LED display is of the common anode type. A transistor is connected between +5VDC and the anode of each display. These transistors are activated by a logic low, in turn activating that display. The segments a-g are wired together by segment type, a is connected to all the other a segments, then go through a 330 ohm resistor and then to the PIC16F628. The segments are also activated by a logic low. I apologize for the code attached. It evolved from just displaying all segments on each 7-segment display and cycling slowly through them, to it's current state, by building and modifying the code. Thank you, Sabachka -- sabachka-piclist@oddmagic.net "The average consumer doesn't understand what they're giving up when they block cookies . . . Today's invasion of privacy is tomorrow's convenience." -- Stefan Tornquist, marketing director at Bluestreak.com Inc -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Description: 7-segment LED Display Test Program Content-Disposition: attachment; filename="digittest.asm" LIST P=16F628 ; Use the PIC16F628 #include "P16F628.INC" ; Include header file __config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF Loop1 EQU 0x20 ; Loop1 and Loop2 are used in Loop2 EQU 0x21 ; the delay routine RghtDsp EQU 0x22 ; Holds the value to display on ; the right hand pair of LEDs LeftDsp EQU 0x23 ; Holds the value to display on ; the left hand pair of LEDs CountW EQU 0x24 ; stand alone delay counter ORG 0x000 ; Program starts at 0x000 CLRF PORTA ; Initialize port A CLRF PORTB ; Initialize port B BSF STATUS,RP0 ; RAM bank 1 CLRF TRISA ; All pins port A output CLRF TRISB ; All pins port B output BCF STATUS,RP0 ; RAM bank 0 MOVLW 0x07 MOVWF CMCON ; Comparators off, all pins digital I/O MOVLW 0xFF MOVWF PORTA ; Bring all PORTA pins high to turn off ; all of the transistors, in turn, turning off all of the LED ; displays MOVLW 0x00 ; Initialize the variables to zero MOVWF RghtDsp ; which probably doesn't need to be MOVWF LeftDsp ; done, but until I'm told otherwise I MOVWF CountW ; will keep the habit. ; --------- ; MAIN LOOP ; --------- Main CALL Display DECFSZ CountW,F ; Decrement the counter. On zero, skip GOTO Main ; the goto. This works as a crude delay ; without getting in the way of the call to the display routine INCFSZ RghtDsp,F ; Have the right side count up from 0 to GOTO Main ; FF, when it rolls over, skip the goto INCF LeftDsp,F ; and increment the left side to emulate ; appropriate increase of the value as if it were a 16-bit word ; instead of an 8-bit word GOTO Main ; return to main and run an endless loop ; ---------------- ; DISPLAY FUNCTION ; ---------------- ; Outputs the values held in RgthDsp and LeftDsp to the 7-segment LED ; displays attached to the microprocessor. Display MOVLW 0x0F ; Look only at the low nibble as it ANDWF RghtDsp, W ; holds the value for the right LED ; of the right pair of LEDs CALL LEDdisp MOVWF PORTB BCF PORTA, 0 ; Turn on LED Display ones digit CALL delay1 CLRF PORTB ; Turn off all segments to prevent ghosting BSF PORTA, 0 ; Turn off LED Display ones digit MOVLW 0xF0 ; Look only at the high nibble as it ANDWF RghtDsp, W ; holds the value for the left LED ; of the right pair of LEDs CALL LEDdisp MOVWF PORTB ; Turn off all segments to prevent ghosting BCF PORTA, 1 ; Turn on LED Display tens digit CALL delay1 CLRF PORTB ; Turn off all segments to prevent ghosting BSF PORTA, 1 ; Turn off LED Display tens digit MOVLW 0x0F ANDWF LeftDsp, W CALL LEDdisp MOVWF PORTB BCF PORTA, 2 ; Turn on LED Display hundreds digit CALL delay1 CLRF PORTB ; Turn off all segments to prevent ghosting BSF PORTA, 2 ; Turn off LED Display hundreds digit MOVLW 0xF0 ANDWF LeftDsp, W CALL LEDdisp MOVWF PORTB BCF PORTA, 3 ; Turn on LED Display thousands digit CALL delay1 CLRF PORTB ; Turn off all segments to prevent ghosting BSF PORTA, 3 ; Turn off LED Display thousands digit RETURN ; -------------- ; DELAY ROUTINES ; -------------- delay1 MOVLW 0x01 ; Delay 1 ms MOVWF Loop1 Outer MOVLW 0xC8 MOVWF Loop2 Inner NOP NOP DECFSZ Loop2,F GOTO Inner ; Inner loop = 5 usec. DECFSZ Loop1,F GOTO Outer RETURN ; -------------------------- ; LED CHARACTER LOOKUP TABLE ; -------------------------- ; 'Decodes' the value in W and returns the proper value to display the ; digit on a 7-segment LED. Not that a low, or zero, turns a segment on ; while a high, or 1 turns the segment off. LEDdisp ADDWF PCL, F ; Offset added to PCL RETLW b'11000000' ; 0 RETLW b'11111001' ; 1 RETLW b'10100100' ; 2 RETLW b'10110000' ; 3 RETLW b'10011001' ; 4 RETLW b'10010010' ; 5 RETLW b'10000010' ; 6 RETLW b'11111000' ; 7 RETLW b'10000000' ; 8 RETLW b'10010000' ; 9 RETLW b'10001000' ; A RETLW b'10000011' ; b RETLW b'10100111' ; c RETLW b'10100001' ; d RETLW b'10000110' ; E RETLW b'10001110' ; F ; -------------- ; END OF PROGRAM ; -------------- ; Exciting, isn't it? ;) END -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics --17pEHd4RhPHOinZp--