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
I still haven't figured out the banking and TRIS command, but somehow the program listed below actually works ! I will post a video to youtube of my first running PIC project but I'm not sure if I can put links up here.
Nevertheless , it is kludgy but the code is entirely mine. It counts in HEX from 0 to 15 on a SINGLE 7 segment display.
To answer the question "What was wrong before?"
1) Still not sure about the TRIS implementation but the above code works. Not sure about the banking either!
2) One big thing is the PAUSE routine that I wrote. The original delay was way too short and the LEDS weren't even lighting up.
So if I count clock cycles in my PAUSE subroutine I might actually figure out my CLOCK FREQUENCY !
DAN
Nevertheless , it is kludgy but the code is entirely mine. It counts in HEX from 0 to 15 on a SINGLE 7 segment display.
#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 0x3e
BIGdelay equ 0x3f
org 0x0000
goto start
org 0x004
goto dummyINT
start movlw b'00000000' ;MOVE ZERO TO ACC "W"orking register
BANKSEL 1
TRIS 7
movlw B'00000000' ;
BANKSEL 0
loop
movlw b'01110111' ;ZERO
movwf PORTC
call PAUSE
movlw b'01000001' ;one
movwf PORTC
call PAUSE
movlw b'00111011' ;TWO
movwf PORTC
call PAUSE
movlw b'01101011' ;three
movwf PORTC
call PAUSE
movlw b'01001101' ;4
movwf PORTC
call PAUSE
movlw b'01101110' ;5
movwf PORTC
call PAUSE
movlw b'01111110' ;6
movwf PORTC
call PAUSE
movlw b'01000011' ;7
movwf PORTC
call PAUSE
movlw b'01111111' ;EIGHT
movwf PORTC
call PAUSE
movlw b'01001111' ;9
movwf PORTC
call PAUSE
movlw b'01011111' ;A
movwf PORTC
call PAUSE
movlw b'01111100' ;B
movwf PORTC
call PAUSE
movlw b'00110110' ;C
movwf PORTC
call PAUSE
movlw b'01111001' ;D
movwf PORTC
call PAUSE
movlw b'00111110' ;E
movwf PORTC
call PAUSE
movlw b'00011110' ;F
movwf PORTC
call PAUSE
;loop forever
goto loop
PAUSE movlw 0xC0
MOVWF BIGdelay
D250 movlw 0xFE
movwf delay
l250 decfsz delay,f
goto l250
DECFSZ BIGdelay,f
GOTO D250
return
dummyINT retfie
end
To answer the question "What was wrong before?"
1) Still not sure about the TRIS implementation but the above code works. Not sure about the banking either!
2) One big thing is the PAUSE routine that I wrote. The original delay was way too short and the LEDS weren't even lighting up.
So if I count clock cycles in my PAUSE subroutine I might actually figure out my CLOCK FREQUENCY !
DAN
Last edited: