Maker Pro
Maker Pro

turning off timer1

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
So this is the code I'm using, nothing fancy, just a string of LED's lighting in sequence from one end to another. My problem is with pin13 (RB7/T1OSI/PGD). that LED won't light and I've tried turning it off and configuring it as an output but still nothing, I believe I'm pointing to the right register. Reading the datasheet it says that setting bit 0 to '1' disables timer1 and setting it to '0' clears it. I've tried both but I still can't get an output on pin13:



list p=16F627A ; list directive to define processor
#include <p16F627A.inc> ; processor specific variable definitions

errorlevel -302 ; suppress message 302 from list file
errorlevel -203
errorlevel -205

__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT


; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.


;*****CONSTANT DEFINITIONS
l1 EQU 0x00 ;RB0
l2 EQU 0x01 ;RB1
l3 EQU 0x02 ;RB2
l4 EQU 0x03 ;RB3
l5 EQU 0x04 ;RB4
l6 EQU 0x05 ;RB5
l7 EQU 0x06 ;RB6
l8 EQU 0x07 ;RB7


;***** VARIABLE DEFINITIONS (examples)
w_temp EQU 0x71 ;variable used for context saving
status_temp EQU 0x72 ;variable used for context saving
dc1 EQU 0x74
dc2 EQU 0x75
dc3 EQU 0x76

;************************************************************************

ORG 0x000 ;processor reset vector
goto MAIN ;go to beginning of program

ORG 0x004 ;interrupt vector location
movwf w_temp ;save off current W register contents
movf STATUS,w ;move status register into W register
movwf status_temp ;save off contents of STATUS register

;isr code can go here or be located as a call subroutine elsewhere

movf status_temp,w ;retrieve copy of STATUS register
movwf STATUS ;restore pre-isr W register contents
retfile



MAIN

bcf STATUS,RP0 ;point at bank 0
bcf STATUS,RP1
movlw 0x07 ;turn comparators off
movwf CMCON
movlw 0x00
movwf T1CON
bsf STATUS,RP0 ;now over to bank 1
clrf TRISA ;port A as outputs
clrf TRISB ;all of port B to outputs
bcf STATUS,RP0 ;back to I/O bank 0
clrf PORTB
clrf PORTA

start
clrf PORTB
bsf PORTB,l1
movlw .10
call delay10ms
bcf PORTB,l1
bsf PORTB,l2
movlw .10
call delay10ms
bcf PORTB,l2
bsf PORTB,l3
movlw .10
call delay10ms
bcf PORTB,l3
bsf PORTB,l4
movlw .10
call delay10ms
bcf PORTB,l4
bsf PORTB,l5
movlw .10
call delay10ms
bcf PORTB,l5
bsf PORTB,l6
movlw .10
call delay10ms
bcf PORTB,l6
bsf PORTB,l7
movlw .10
call delay10ms
bcf PORTB,l7
bsf PORTB,l6
movlw .10
call delay10ms
bcf PORTB,l6
bsf PORTB,l5
movlw .10
call delay10ms
bcf PORTB,l5
bsf PORTB,l4
movlw .10
call delay10ms
bcf PORTB,l4
bsf PORTB,l3
movlw .10
call delay10ms
bcf PORTB,l3
bsf PORTB,l2
movlw .10
call delay10ms
bcf PORTB,l2
bsf PORTB,l1

goto start

delay10ms ;this delay is a variable delay that is multiples of 10ms
movwf dc3
dly2 movlw .13
movwf dc2
clrf dc1
dly1 decfsz dc1,f
goto dly1
decfsz dc2,f
goto dly1
decfsz dc3,f
goto dly2
return

end
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Is the programmer connected? That pin is one of the programming pins and maybe the programmer is holding it low.

Bo
 

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
ya the programmer is connected. I disconnected but still nothing. writing 0x00 to T1CON on bank 0 should work right? or is it 0x01?

side note: the program i pasted shows l8 (pin13) not ever set to turn on, it stops at l7(pin12) then reverses direction. I have corrected that so all 8 LED's should have a turn lighting but still nothing.

I remember reading in that gooligum tutorial website that I should write to a port before i configure it as an output, would this be a problem that that area?
 
Last edited:
Top