-
16f690 interupt
hello,
I have program which working perfect on PIC18F242. I wish to changed this program and build to 16F690. I was changed some pins between PIC and now don't working properly. Now couldn't test A/D input but Synchro pulse not triggering interrupt routine to my program. I am not convinced if have ADC channel and other configuration set properly.
down is attached both program. Please help me and check configuration.
Thanks,
Samo
'@ DEVICE PIC18F252, HS_OSC
define osc 20
DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/32)
DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
TRISA=%11111111
ADCON1=%10000010
ADCON0=%10000111
sinh var portb.0
led var portb.1
out VAR PORTC.0
b0 var byte
b1 var byte
b2 var byte
W0 var word
W1 var word
maxlim var word
maxlim1 var word
maxlim2 var word
minstart var word
minstart1 var word
regulacija var word
reg1 var word
reg2 var word
reg3 var word
reg4 var word
eeprom 0,[43]
eeprom 2,[23]
eeprom 4,[18]
clear
high led
pause 1000
toggle led
pause 1000
toggle led
pause 1000
toggle led
read 0,b0
read 2,b1
read 4,b2
On Interrupt Goto myint
INTCON = $90
loop:
Goto loop
Disable
myint:
adcin 1,maxlim
adcin 0,minstart
adcin 2,regulacija
reg1= (maxlim2 -minstart1)
reg2= (reg1*regulacija)
reg3= div32 1024
reg4= reg3+minstart1
minstart1=(minstart*10)/B1
maxlim1=(maxlim*10)/B2
maxlim2=1024-maxlim1
if w0=40 then
toggle led
w0=0
endif
if regulacija>=1022 or regulacija=0 then
high led
endif
pauseus (1023-reg4)*b0
high out
pause 5
low out
w0=w0+1
INTCON.1 = 0
Resume
Enable
END
program which not working:
'@ DEVICE PIC16F690, HS_OSC
define osc 20
DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/32)
DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
CM1CON0 = 0
CM2CON0 = 0
ANSEL = %00001011
ANSELH=0
IOCA.2=1
ADCON1=%00000000
ADCON0=%10000001
sinh var portc.2
led var porta.2
out VAR portc.1
b0 var byte
b1 var byte
b2 var byte
W0 var word
W1 var word
maxlim var word
maxlim1 var word
maxlim2 var word
minstart var word
minstart1 var word
regulacija var word
reg1 var word
reg2 var word
reg3 var word
reg4 var word
eeprom 0,[43]
eeprom 2,[23]
eeprom 4,[18]
clear
high led
pause 1000
toggle led
pause 1000
toggle led
pause 1000
toggle led
read 0,b0
read 2,b1
read 4,b2
On Interrupt Goto myint
INTCON = $90
loop:
Goto loop
Disable
myint:
adcin 1,maxlim
adcin 0,minstart
adcin 2,regulacija
reg1= (maxlim2 -minstart1)
reg2= (reg1*regulacija)
reg3= div32 1024
reg4= reg3+minstart1
minstart1=(minstart*10)/b1
maxlim1=(maxlim*10)/b2
maxlim2=1024-maxlim1
if w0=40 then 'and regulacija>minstart then
toggle led
w0=0
endif
if regulacija>=1022 or regulacija=0 then
high led
endif
pauseus (1023-reg4)*b0
high out
pause 5
low out
w0=w0+1
INTCON.1 = 0
Resume
Enable
END
-
Re: 16f690 interupt
Not sure which version of PBP you are using... but "Loop" is a reserved word that should NOT be used as a variable name or program label.
You should change that to something else like "MainLoop", etc.
-
Re: 16f690 interupt
I use PBP 2.50C and both program sample compiled without problems. "loop variables" by first program working very good. I was trying with "loop1" and was no changed.
-
Re: 16f690 interupt
Seems like you forgot to set TRIS registers in the second code unless I am snowblind.
Ver 2.6 makes LOOP a reserved word.
-
Re: 16f690 interupt