Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

stack overflow .. help :( mikrobasic .. sleep mode

Status
Not open for further replies.

iamnoy

New Member
program asdf
dim counter as word
dim counter2 as word
sub procedure Interrupt()
Inc(counter) ' Increment value of counter on every interrupt

TMR0 = 0
INTCON = 0x20 ' Set T0IE, clear T0IF
end sub

main:
OPTION_REG = 0x84 ' Assign prescaler to TMR0

TRISB = 0x0f ' rb0-rb3 input, rb4-rb7 output
PORTB = 0x0f '
TRISC = 0
PORTC = 0
TMR0 = 0 ' Timer0 initial value
INTCON = 0xA0 ' Enable TMRO interrupt
counter = 0 ' Initialize counter
counter2 = 0

while TRUE

if (portb.0 = 1) then
Inc(counter2)
gosub aa
end if

if (counter2 = 100) then
portb.4 = 0
counter2 = 0
end if

wend

aa:

if (counter > 10 ) then
portb.4 = 1
end

if (counter > 50) then
portb.4 = 0
counter2 = 0
end if

return

end.

I always receive on ISIS message box "stack overflow in call instruction" what should i do ?

This is the flow of program I want to make .

if portb.0 = 1 then counter2 will increment and it will call the sub program aa . and once counter2 reached 100 it will automatically turn-off portb.4 where program aa is located .


hope you guys help me ! thnx .
 
You accidentally typed "end" instead of "end if" after the first "if" in your "aa:" subroutine. Try this -

Code:
program asdf
dim counter as word
dim counter2 as word
sub procedure Interrupt()
Inc(counter) ' Increment value of counter on every interrupt

TMR0 = 0
INTCON = 0x20 ' Set T0IE, clear T0IF
end sub

main:
OPTION_REG = 0x84 ' Assign prescaler to TMR0

TRISB = 0x0f ' rb0-rb3 input, rb4-rb7 output
PORTB = 0x0f ' 
TRISC = 0
PORTC = 0
TMR0 = 0 ' Timer0 initial value
INTCON = 0xA0 ' Enable TMRO interrupt
counter = 0 ' Initialize counter
counter2 = 0

while TRUE

if (portb.0 = 1) then
Inc(counter2)
gosub aa
end if

if (counter2 = 100) then
portb.4 = 0
counter2 = 0
end if

wend

aa:

if (counter > 10 ) then
portb.4 = 1
end if

if (counter > 50) then
portb.4 = 0
counter2 = 0
end if

return 

end
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top