It's a very simple code, But I'm confused.
This code did not worked as expected.
Normally one of the LEDs should flash at 2 Hz and the other at 1 Hz.
Problem is: second "gosub bekle" does not work.
So, one led flash with 2 Hz, other LED is stable.
When an additional delay_ms (250) is added after gosub, the code is working according to plan. "gosub wait" line whether exist or not.
If we add a second "gosub bekle" after "gosub bekle" that is not working, everything was stops after the first cycle. The program is locking.
Where is my fault?
Hardware: https://www.sparkfun.com/products/9713
Code: Select all
program Led_Blinking
dim LED as sbit at LATE.0
dim LED1 as sbit at LATE.1
main:
AD1PCFG = 0xFFFF ' Configure AN pins as digital I/O
JTAGEN_bit = 0 ' Disable JTAG
TRISA = 0xFF ' Initialize PORTA as input
TRISB = 0xFF ' Initialize PORTB as input
TRISC = 0xFF ' Initialize PORTC as input
TRISD = 0xFF ' Initialize PORTD as input
TRISE = 0xF0
TRISF = 0xFF ' Initialize PORTE as input
TRISG = 0xFF ' Initialize PORTG as input
late=0xFF
while TRUE
LED1=not LED1
LED=0
gosub bekle
LED=1
gosub bekle 'This line not working as expected.
rem delay_ms(250) 'Remove rem to work correctly
rem gosub bekle 'Remove rem to lock program.
wend
bekle:
delay_ms(250)
return
end.