techristian
Member level 1
- Joined
- Apr 3, 2013
- Messages
- 41
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Windsor, Ontario
- Activity points
- 1,612
Ok
The code below works fine with the internal oscillator. However with an external crystal the RA6 and RA7 pins are used. No problem right. Just use PORTD or PORTE. Well I was using the TRIS command (against recommendations) and it works fine for PORT A,B AND C. TRIS 5 ,TRIS6 OR TRIS7....but these extra ports MUST be configured in the NEW WAY.
MPASM DOES NOT recognize the RP0 or RP1 symbols and they are not in the include file for the 16F1784 . Yes there is the new BANKSEL command.
Anyway the code below DOES work with no crystal and counts from 00 hex to FF hex on 2 7 segment displays BUT I WANT TO TRY AND USE PORT D INSTEAD OF PORT A to leave OSC1 AND OSC2 pins available for a crystal.
The code below works fine with the internal oscillator. However with an external crystal the RA6 and RA7 pins are used. No problem right. Just use PORTD or PORTE. Well I was using the TRIS command (against recommendations) and it works fine for PORT A,B AND C. TRIS 5 ,TRIS6 OR TRIS7....but these extra ports MUST be configured in the NEW WAY.
MPASM DOES NOT recognize the RP0 or RP1 symbols and they are not in the include file for the 16F1784 . Yes there is the new BANKSEL command.
Anyway the code below DOES work with no crystal and counts from 00 hex to FF hex on 2 7 segment displays BUT I WANT TO TRY AND USE PORT D INSTEAD OF PORT A to leave OSC1 AND OSC2 pins available for a crystal.
Code:
#include <p16f1784.inc>
;CONFIG1
; __config 0x3FE4
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
; CONFIG2
; __config 0x3FFF
__CONFIG _CONFIG2, _WRT_OFF & _VCAPEN_OFF & _PLLEN_ON & _STVREN_ON & _BORV_LO & _LPBOR_OFF & _LVP_ON
delay equ 0x7e
BIGdelay equ 0x7f
NUMBER equ 0x7c ; if over 80h or greater next bank
temp equ 0x7d
org 0x0000
goto start
org 0x004
goto dummyINT
start
movlw b'00000000' ;MOVE ZERO TO ACC "W"orking register
movwf NUMBER
movwf temp
BANKSEL 1
TRIS 7 ;since 0 in w register then porta and portc outputs
TRIS 5
BANKSEL 0
loop
incf NUMBER,1
movf NUMBER,0
movwf temp ;copy number to temp here
movlw b'00001111' ;least signifigant digit mask
andwf temp,0
CALL hexTable
movwf PORTC ;DISPLAY LOW DIGIT
movf NUMBER,0
movwf temp
movlw b'11110000' ;high bit mask
andwf temp, 1
LSRF temp, 1
LSRF temp, 1
LSRF temp, 1
LSRF temp, 0 ;shift right 3 times store in W
CALL hexTable
next2 movwf PORTA
call PAUSE
;loop forever
goto loop
hexTable BRW
RETLW b'01110111' ;0
RETLW b'01000001' ;1
RETLW b'00111011' ;2
RETLW b'01101011' ;3
RETLW b'01001101' ;4
RETLW b'01101110' ;5
RETLW b'01111110' ;6
RETLW b'01000011' ;7
RETLW b'01111111' ;8
RETLW b'01001111' ;9
RETLW b'01011111' ;A
RETLW b'01111100' ;B
RETLW b'00110110' ;C
RETLW b'01111001' ;D
RETLW b'00111110' ;E
RETLW b'00011110' ;F
PAUSE movlw 0x40
MOVWF BIGdelay
D250 movlw 0xFE
movwf delay
l250 decfsz delay,f
goto l250
DECFSZ BIGdelay,f
GOTO D250
return
dummyINT retfie
end