ozkanozkan
New Member
Hi all,
im trying to control the position of a dc servo. when i make the simulation in proteus it says: stack overflow executing call instruction/stack underflow executing return instruction. i couldnt understand what is the problem.,
attached is my circuit and the picbasic code. thanks to all.
code is here:
@ DEVICE pic16F876A
@ DEVICE pic16F876A, WDT_off
@ DEVICE pic16F876A, PWRT_ON
@ DEVICE pic16F876A, PROTECT_OFF
@ DEVICE pic16F876A, XT_OSC
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE OSC 4
DEFINE ADC_SAMPLEUS 100
adcon1=%10001101
TRISA.1=1
TRISC.1=0
TRISC.2=0
trisc.3=0
TRISB=0
trisb.0=1
'---------------------------------------------------
on interrupt goto pregeterror
INTCON = %10010000 'RB0 interrupt
main:
high portc.3
GOTO main
disable
pregeterror:
intcon.1=1
intcon.1=0
RESUME geterror
ENABLE
geterror:
low portc.3
adcin 1, error
waitadc:
if adcon0.2=1 then goto waitadc
'Compare
if ABS(512-error)<=1 then goto dur
if error >513 then goto Sag
if error <511 then goto sol
'actuate
sag:
high portc.1
low portc.2
GOTO main
sol:
low portc.1
high portc.2
GOTO main
dur:
low portc.1
low portc.2
GOTO main
im trying to control the position of a dc servo. when i make the simulation in proteus it says: stack overflow executing call instruction/stack underflow executing return instruction. i couldnt understand what is the problem.,
code is here:
@ DEVICE pic16F876A
@ DEVICE pic16F876A, WDT_off
@ DEVICE pic16F876A, PWRT_ON
@ DEVICE pic16F876A, PROTECT_OFF
@ DEVICE pic16F876A, XT_OSC
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE OSC 4
DEFINE ADC_SAMPLEUS 100
adcon1=%10001101
TRISA.1=1
TRISC.1=0
TRISC.2=0
trisc.3=0
TRISB=0
trisb.0=1
'---------------------------------------------------
on interrupt goto pregeterror
INTCON = %10010000 'RB0 interrupt
main:
high portc.3
GOTO main
disable
pregeterror:
intcon.1=1
intcon.1=0
RESUME geterror
ENABLE
geterror:
low portc.3
adcin 1, error
waitadc:
if adcon0.2=1 then goto waitadc
'Compare
if ABS(512-error)<=1 then goto dur
if error >513 then goto Sag
if error <511 then goto sol
'actuate
sag:
high portc.1
low portc.2
GOTO main
sol:
low portc.1
high portc.2
GOTO main
dur:
low portc.1
low portc.2
GOTO main