Led_Blinking not working correctly.

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
senoleker
Posts: 28
Joined: 01 Mar 2015 18:43

Led_Blinking not working correctly.

#1 Post by senoleker » 06 Oct 2017 16:46

Hi,
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.

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: Led_Blinking not working correctly.

#2 Post by lana.arsic » 10 Oct 2017 17:27

Hi,

I'm sorry because of this inconvenience,
I was able to reproduce the issue and I have reported it to our developers.

Meanwhile, you can try to add delay without gosub.

Kind regards,
Lana

Post Reply

Return to “mikroBasic PRO for PIC32 General”