Could you point to an example of that?
me too
I have never had to do that and can find no mention of that short coming anywhere
anyways here is my take on the 7 seg display
if you have a chip with mssp why waste time and code space when the hardware can do it for you
I cheated a bit and did it in asm for speed and size gains
no nasty pauses , all gone
my displays are common anode so the data is inverted see comments
Code:
'****************************************************************
'* Name : 4 bit 7 segment display *
'* Author : RICHARD *
'* Notice : *
'* : *
'* Date : 18. 2. 2018 *
'* Version : 1.0 *
'* Notes : *
'* MCU : PIC 16F1825 @32MHZ *
'****************************************************************
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
goto overasm
asm
timer1 = TMR1L
seg_val
addwf PCL, F
retlw 0xc0;0B11000000 0
retlw 0xf9;0B11111001 1
retlw 0xa4;0B10100100 2
retlw 0xb0;0B10110000 3
retlw 0x99;0B10011001 4
retlw 0x92;0B10010010 5
retlw 0x82;0B10000010 6
retlw 0xf8;0B11111000 7
retlw 0x80;0B10000000 8
retlw 0x90;0B10010000 9
endasm
overasm:
DEFINE OSC 32 ; Use internal clock
ANSELC=0
SSP1CON1=$22
SSP1STAT=$40
OSCCON=$f0
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
TRISC = %11101010
LPIN var portc.4 ; Latch
DPIN var portc.2 ; Data SDO
CPIN var portc.0 ; Clock SCK
segment var byte
value var word
d_index var byte
buff var byte[5]
tmp var byte
d_pointer var byte
timer1 var word ext
timer1_reload con 1543 ;8mS
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _DISP, ASM, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
T1CON = $1
d_index=0
;---[simple counter 0 - to 9999]------------------------------------------------
Main:
for value = 0 to 9999
arraywrite buff ,[dec4 value]
pause 100
next value
value = 0
GOTO Main
;---[TMR1 - interrupt handler]--------------------------------------------------
DISP:
asm
MOVE?CT 0, T1CON, TMR1ON ; 1 stop timer
MOVLW LOW(_timer1_reload) ; 1 Add TimerReload to the
ADDWF TMR1L,F ; 1 value in Timer1
BTFSC STATUS,C ; 1/2
INCF TMR1H,F ; 1
MOVLW HIGH(_timer1_reload) ; 1
ADDWF TMR1H,F ; 1
MOVE?CT 1, T1CON, TMR1ON ; 1 start timer
MOVE?CB high _buff, FSR0H ;load highbyte
MOVE?CB low _buff, FSR0L ;load low byte
MOVE?BA _d_index
ADDWF FSR0L,F
MOVLW 0X30
SUBWF INDF0,W
L?CALL seg_val
MOVE?AB _segment
MOVE?BB _d_index ,_tmp
BANKSEL _tmp
MOVLW 1
ADDWF _tmp,F
BANKSEL _d_pointer
CLRF _d_pointer
BSF STATUS ,C
N_BIT
BANKSEL _d_pointer
RLF _d_pointer,F
BCF STATUS ,C
BANKSEL _tmp
DECFSZ _tmp,F
GOTO N_BIT
MOVLW 1
BANKSEL _d_index
ADDWF _d_index,F
MOVLW 3
ANDWF _d_index,F
BANKSEL LATC
BCF LATC ,4
BANKSEL PIR1
BCF PIR1,3
BANKSEL _segment
COMF _segment,W ;COMMENT USED TO INVERT DATA FOR COMMON ANODE DISPLAY
BANKSEL SSP1BUF
movwf SSP1BUF
BANKSEL PIR1
BTFSs PIR1,3
GOTO $-1
BANKSEL _d_pointer
COMF _d_pointer,W ; ;COMMENT USED FOR COMMON ANODE DISPLAY
BANKSEL PIR1
BCF PIR1,3
BANKSEL SSP1BUF
movwf SSP1BUF
BANKSEL PIR1
BTFSs PIR1,3
GOTO $-1
BANKSEL LATC
BSF LATC ,4
BANKSEL 0
INT_RETURN
endasm
Bookmarks