Hello everybody:
I'm having a this problem (see attached pics) using pic16f628's timer 1, when applied to a seven segments display.
As you can see in the second pic , the segments A and G don't show up. In the first pic I'm using a different program . Here's the current program :
What could be the problem?
t.i.a.
p.s. btw, I'm posting this thread using Opera browser. I cannot neither send a private message nor post a message (or thread) using firefox 2.0 anymore.
I'm having a this problem (see attached pics) using pic16f628's timer 1, when applied to a seven segments display.
As you can see in the second pic , the segments A and G don't show up. In the first pic I'm using a different program . Here's the current program :
Code:
; Timer using PIC16F628
list p=16f628A ; list directive to define processor
#include <p16f628A.inc> ; processor specific variable definitions
ERRORLEVEL 0, -302 ;suppress bank selection messages
__CONFIG _CP_OFF & _WDT_OFF & _BOREN_OFF & _PWRTE_OFF & _MCLRE_OFF & _LVP_OFF & _INTOSC_OSC_NOCLKOUT
cblock 0x20 ;start of general purpose registers
w_temp ;auxiliary for interrupt service
status_temp
J ; auxiliary variables
K ;
M ;
N ;
Dig1 ; Digit number one on displays
Dig2
Dig3
Dig4
endc
;=========================== MAIN =========================
;========================== PROGRAM =======================
org 0x00 ; processor reset vector
goto Main
org 0x04 ; Vector de interrupción.
goto InterruptService
Main:
movlw 0x07 ;Turn comparators off and
movwf CMCON ;enable pins for I/O functions
;------ Ports configuration
bsf STATUS, RP0 ;select bank 1
movlw b'00000001' ;set PortB <1:7> all outputs, PB0 as input
movwf TRISB
movlw b'00111100'
movwf TRISA ;set PortA <2:5> inputs, <0:1,6:7> outputs
bsf PIE1,0 ; TMR1 Overflow Interrupt Enable bit
bcf STATUS,RP0 ; select bank 0
clrf PORTA
movlw b'00111100' ;disables timer b0, internal clock b1, enable oscillator b3
movwf T1CON ;prescale 1:8 b5-b4
;bsf PORTA,4 ;two points clock
movlw 00h ; initialize counter
movwf Dig1
movwf Dig2
movwf Dig3
movwf Dig4
movlw b'11000000'
movwf INTCON ;enable global AND peripheral interrupts
bsf T1CON,0 ;start timer
Main_loop:
call Display
goto Main_loop
;------------------------------------------
; led conversion lookup table
led7
; in: number in W
; out: 7-seg code in W in format B'xgfedcba'
andlw B'00001111'
addwf PCL,f
; format B'agfedcbx'
retlw B'10111110' ;0
retlw B'00000110' ;1
retlw B'11011010' ;2
retlw B'11001110' ;3
retlw B'01100110' ;4
retlw B'11101100' ;5
retlw B'11111100' ;6
retlw B'10000110' ;7
retlw B'11111110' ;8
retlw B'11101110' ;9
;-------------------------------------------
; do some time by executing nested loops
shorttime:
movlw D'14'
movwf J
jloop:
movlw D'255' ; w = 255 decimal
movwf K ; K = w
kloop:
decfsz K,f ; K = K - 1 , skip next if zero
goto kloop
decfsz J,F
goto jloop
return
Display:
movlw D'17' ; D'17'
movwf M
mloop:
movf Dig1,W
call led7
movwf PORTB
bcf PORTA,7
bsf PORTA,0
call shorttime
movf Dig2,W
call led7
movwf PORTB
bcf PORTA,0
bsf PORTA,1
call shorttime
movf Dig3,W
call led7
movwf PORTB
bcf PORTA,1
bsf PORTA,6
call shorttime
movf Dig4,W
call led7
movwf PORTB
bcf PORTA,6
bsf PORTA,7
call shorttime
decfsz M,F
goto mloop
return
InterruptService:
movwf w_temp ;copy W to temp register could be in any bank
swapf STATUS,W ;swap status to be saved into W
bcf STATUS,RP0 ;change to bank 0 regardless of current bank
movwf status_temp ;save status to bank 0 register
bcf PIR1,0 ;clear register overflowed
incf Dig1,F ;checks if Dig1 > 10
movf Dig1,W
addlw -d'10'
btfss STATUS,Z
goto exit_int
clrf Dig1
incf Dig2,F ;checks if Dig2 > 6
movf Dig2,W
addlw -d'6'
btfss STATUS,Z
goto exit_int
clrf Dig2
incf Dig3,F ;checks if Dig3 > 10
movf Dig3,W
addlw -d'10'
btfss STATUS,Z
goto exit_int
clrf Dig3
incf Dig4,F ;checks if Dig3 > 6
movf Dig4,W
addlw -d'6'
btfss STATUS,Z
goto exit_int
clrf Dig4
exit_int:
swapf status_temp,W ;register into W, sets bank to original state
movwf STATUS ;move W into STATUS ;register
swapf w_temp,F ;swap W_TEMP
swapf w_temp,W ;swap W_TEMP into W
retfie
END ; directive 'end of program'
What could be the problem?
t.i.a.
p.s. btw, I'm posting this thread using Opera browser. I cannot neither send a private message nor post a message (or thread) using firefox 2.0 anymore.
Attachments
Last edited: