Hello....All of the code is shown below......
Code:
'****************************************************************
'* Name : TIMER01.INC *
'* Author : Michael Denton *
'* Notice : *
'* Date : 27/03/2010 *
'* Version : 1.0 *
'* Notes : *
'****************************************************************
cmcon = %00000111 'Make portA all digital I/O otherwise ADC
intcon = %10110000 'R/W Reg Bit2 is T0IF TMRO overflow bit
'must be reset in software
option_reg = %10010000 'prescaler for TMR0 set at 1:1
vrcon = %00000000 'Turn off reference voltage
eecon1 = %00001111 'EEPROM data register
'=======================================================
PIN6 VAR PORTB.0 ' Rename all port names with physical PIN number
PIN7 VAR PORTB.1 ' Makes it easier to wire up
PIN8 VAR PORTB.2
PIN9 VAR PORTB.3
PIN10 VAR PORTB.4
PIN11 VAR PORTB.5
PIN12 VAR PORTB.6
PIN13 VAR PORTB.7
PIN17 VAR PORTA.0
PIN18 VAR PORTA.1
PIN1 VAR PORTA.2
PIN2 VAR PORTA.3
PIN3 VAR PORTA.4
'=======================================================
INPUT PIN2 '
input pin6 '
input PIN7 '
input PIN8 '
input PIN9 '
input PIN12 '
input PIN13 '
output pin1 '
output pin3 '
output pin10 '
output PIN11 '
OUTPUT PIN17 '
OUTPUT PIN18 '
'================= Check functionality ==========================
m var word :n var word
clicks var word: secs var word
' ===============================================================
pause 1000 'Do nothing for a while
main:
loop1:
if intcon.2 = 0 then loop1 'TMR0 must be enabled to get out of this loop1
intcon.2 = 0
clicks=clicks+1
if clicks >=1900 then
clicks=0
high pin11:pause 100:low pin11 'Flash LED for 10th of second
secs=secs+1
endif
if secs>=5 then
high pin10:pause 100:low pin10
gosub nowt
secs=0 'Reset secs
endif
goto loop1
end
nowt: 'm=m+1 ' Why does this one extra instruction cause Pin11 High
' And cause progam to FAIL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return
Bookmarks