here what i have, but when i send it a C to start sub colors it works, but i cannot get it to exit the sub when i send it a O?
#chip 16F688, 18 'mhz
#config MCLRE=off, WDT=off, bod=off
#define USART_BLOCKING
#define SerInPort PORTc.5
#define USART_BAUD_RATE 2400 'the speed you want
InitUsart
On Interrupt UsartRX1Ready call getdata 'info
main:
goto main
sub getdata
hserreceive temp
if temp = 67 then colors
if temp= 79 then goto main
end sub
sub colors
LoopCounter = 0
For LoopCounter = 1 to 255
pvalue = loopcounter/2
pv1 = 128 - pvalue
pv2 = 128 - pv1
repeat 4
pwmout 1, pv1, 1
pwmout 2, 0, 1
pwmout 3, pvalue, 1
end repeat
goto colors
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is here.
sub getdata
hserreceive temp
if temp = 67 then colors <========= problems.
if temp= 79 then goto main <======= problems
end sub
When you enter a sub routine , you must exit the subroutine either by the end sub , or by exit sub statements.
Having gotos in the Sub which leave the sub mean that the stack will slowly fill up with return addresses which never get removed.
You can have gotos in the Sub provided they dont go outside of the Sub.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
here what i have, but when i send it a C to start sub colors it works, but i cannot get it to exit the sub when i send it a O?
#chip 16F688, 18 'mhz
#config MCLRE=off, WDT=off, bod=off
#define USART_BLOCKING
#define SerInPort PORTc.5
#define USART_BAUD_RATE 2400 'the speed you want
InitUsart
On Interrupt UsartRX1Ready call getdata 'info
main:
goto main
sub getdata
hserreceive temp
if temp = 67 then colors
if temp= 79 then goto main
end sub
sub colors
LoopCounter = 0
For LoopCounter = 1 to 255
pvalue = loopcounter/2
pv1 = 128 - pvalue
pv2 = 128 - pv1
repeat 4
pwmout 1, pv1, 1
pwmout 2, 0, 1
pwmout 3, pvalue, 1
end repeat
goto colors
end sub
The problem is here.
sub getdata
hserreceive temp
if temp = 67 then colors <========= problems.
if temp= 79 then goto main <======= problems
end sub
When you enter a sub routine , you must exit the subroutine either by the end sub , or by exit sub statements.
Having gotos in the Sub which leave the sub mean that the stack will slowly fill up with return addresses which never get removed.
You can have gotos in the Sub provided they dont go outside of the Sub.