![Very Happy :D](./images/smilies/biggrin.gif)
Skulle behöva hjälp att programmera en pic16 för 7 segments 8st
tid & år har pickit 3 men fixar inte.
M.v.h
Christer
****** TMR0 INTERRUPT ROUTINE, THIS DOES THE DISPLAY CHARLIEPLEXING
*
T0IRQ LOD INTSAV.T0A,A SAVE REGS
SWN A=STATUS
LOD INTSAV.T0STAT,A
LOD A,IADRES
LOD INTSAV.T0IADR,A
CLF BSELA SET BANK0
STZ TMR1L STOP TIMER1 (DISPLAY INTENSITY) FROM INTERRUPT
CLF T0IF CLEAR DISPLAY RELATED INTFLAGS
CLF T1IF
SEF GIE MASTER IRQ ENABLE
* HANDLE RECEIVER RESET TIMEOUTS
CLF GIE STOP RX DURING PARTIAL RESET
SFC RX.RESET TIME TO RESET RECEIVER?
JMP .NORES NO
STZ RX.FLAGS RESET FLAGS
STZ RX.INPNT RESET INPUT POINTER
STZ RX.SHIFT INIT SHIFT TO COUNT BITS
INC RX.SHIFT
STZ RX.CRC RESET CRC
.NORES CLF RX.RESET FLAG RESET NXT TIME IF NO ACTIVITY
SEF GIE
STZ PORTC TURN OFF DISPLAY TO STOP GHOSTING
LOD A,#$04
AND PORTA,A
CLF CY SHIFT DIGIT SCAN BIT
ROR DISPLY.CBIT
TFZ DISPLY.CBIT ALL DIGITS DONE?
SFS Z
JMP .NOINIT NO-DON'T INIT
INC DISPLY.BTIMER INC BLINK TIMER, PLACED HERE TO GET 1/8 PERIOD
LOD A,#DISPLY.START INIT DIGIT POS^
LOD DISPLY.CDIGIT,A
SMB DISPLY.CBIT,7 INIT DIGIT SCAN BIT
.NOINIT DEC DISPLY.CDIGIT NXT DIGIT POS
LOD A,DISPLY.CDIGIT GET DIGIT POS
LOD IADRES,A ADDRESS DIGIT
STZ DISPLY.PORTA INIT BUILD OF PORTA DATA
* GET AND INSERT CHARLIEPLEX BIT
LOD A,DISPLY.CBIT GET CHARLIEPLEX POSITION
AND A,IDATA MASK OUT CHARLIEPLEX BIT
ADD A,#-1 PUT CHARLIEPLEX BIT INTO CY
* INSERT CBIT INTO PORTA BITS AND FINALIZE THEM
ROR DISPLY.PORTA INSERT CHARLIEPLEX BIT FROM CY
ROR DISPLY.PORTA SHIFT IT INTO POSITION
SWN DISPLY.PORTA CHARLIEPLEX BIT INTO BIT3
ROR A=DISPLY.CBIT GET CBIT ONE TO THE RIGHT
AND A,#$60 MASK OUT FOR DIGITS WITH ANODE IN PORTA
ORR DISPLY.PORTA,A OR IN INTO PORTA BITS
ROR DISPLY.PORTA PORTA BITS ARE NOW READY
* SET TRIS REGISTERS
SEF BSELA BANK1
LOD A,DISPLY.CBIT GET CBIT..
EOR A,#-1 ..INVERTED
AND A,IDATA GET DISPLAY DATA WITH CHARLIEPLEX BIT CLEARED
LOD TRISC,A SET TRISC, UPPER 2 BITS ARE DONT CARE
LOD DISPLY.PAD,A PUT BITS HERE FOR SHIFT
ROR DISPLY.PAD PUT THEM INTO POSITION
ROR A=DISPLY.PAD
AND A,#$30 MASK OUT
ORR A,#$0C THOSE BITS ARE INPUTS = TRIS BITS ALWAYS SET
LOD TRISA,A SET TRISA, JUST BITS 5,6 CONTAINS DATA
CLF BSELA BANK0
* DO BLINK
LOD A,DISPLY.CBIT GET DIGIT MASK
AND A,DISPLY.BFLAGS BLINK THIS DIGIT?
SFS Z
JMP .NOBLK NO-ALWAYS TURN ON
LOD A,DISPLY.BTIMER GET BLINK TIMER
AND A,#$30 ASYMMETRICAL BLINK
SFC Z
JMP .BLKOFF NO TURNON FOR BLINK DARK PERIOD
* TURN ON DISPLAY BY SETTING DATA BITS
.NOBLK LOD A,DISPLY.PORTA GET PREPARED PORTA DATA
LOD PORTA,A SET THIS FIRST TO AVOID CHARLIEPLEX BIT GHOSTING
LOD A,DISPLY.CBIT CBIT IS PORTC DATA
LOD PORTC,A
* DO INTENSITY CONTROL
.BLKOFF LOD A,#-1 SET INTENSITY TIMER
LOD TMR1H,A
LOD A,DISPLY.INTENS
LOD TMR1L,A
.DONE LOD A,INTSAV.T0IADR RESTORE REGS
LOD IADRES,A
SWN A=INTSAV.T0STAT
LOD STATUS,A
SWN INTSAV.T0A
SWN A=INTSAV.T0A
RTI IRQRTN DONE
*** TIMER 1 INTERRUPT, INTENSITY CONTROL
*
T1IRQ LOD INTSAV.T1A,A SAVE REGS
SWN A=STATUS
LOD INTSAV.T1STAT,A
CLF BSELA SET BANK0
CLF T1IF
LOD A,DISPLY.CBIT GET CHARLIEPLEX BIT
AND A,#$3F NO GHOSTING, ANODE BIT IN PORTC?
SFS Z
STZ PORTC YES-TURN OFF THIS FIRST
STZ PORTA TURN OFF DISPLAY
STZ PORTC
SWN A=INTSAV.T1STAT RESTORE REGS
LOD STATUS,A
SWN INTSAV.T1A
SWN A=INTSAV.T1A
RTI IRQRTN DONE