Hdware Interrupt not working

Started by Cory Heisterkamp September 1, 2003
Hey Guys,

Well, I've got a new problem. It seems my hardware intterupt no longer
works. I just recently switched to a different computer with the latest
compiler and also put my breadboard design to perfboard and everything
works except the interrupt. I've verified that the pin is actually being
pulled low when the switch is pressed and it is. At first I thought
maybe I had a stack overflow, but then I whipped up the code below and
tried it alone and it was still a no-go. Anything wrong with this code?
Am I overlooking something or was there a change in the latest compiler?
The pin is configured as a pull-up.

Thanks,
Cory
----

Option Explicit
Public Const EncoderPin as byte = 11
Dim StackEncoder (0 to 32) as byte
Dim pulsecount as integer

Public Sub Main()
CallTask "EncoderTask", StackEncoder

Do
Debug.print "nothing.."
Call delay(0.3)
Loop

End Sub

'----------
Public Sub EncoderTask()

Do
Call Waitforinterrupt(bxPinRisingEdge)
Call sleep(0.2)

pulsecount=pulsecount+1
Debug.print "pulse= "; cstr(pulsecount)
Call sleep(0.0)
Loop

End Sub




From: Cory Heisterkamp <>

> [...]
> At first I thought maybe I had a stack overflow,
> but then I whipped up the code below and tried
> it alone and it was still a no-go. Anything
> wrong with this code?
> [...]
> Dim StackEncoder (0 to 32) as byte
> [...]
> CallTask "EncoderTask", StackEncoder
> [...]
> Public Sub EncoderTask()
> [...]
> Debug.print "pulse= "; cstr(pulsecount)

I'd guess you have a stack overflow here. StackEncoder reserves 33
bytes for the task stack, of which 15 is taken up by the task
frame. That leaves only 18 bytes for everything else, and CStr
probably takes up more than that.

-- Frank Manning
-- NetMedia, Inc.


Frank, is there a way I can figure how many bytes to allocate to
StackEncoder? I'm a little fuzzy on the memory allocation and I have
over 600 lines of code. Any pointers? -no pun intended : )

Cory Frank Manning wrote:
>
> From: Cory Heisterkamp <>
>
> > [...]
> > At first I thought maybe I had a stack overflow,
> > but then I whipped up the code below and tried
> > it alone and it was still a no-go. Anything
> > wrong with this code?
> > [...]
> > Dim StackEncoder (0 to 32) as byte
> > [...]
> > CallTask "EncoderTask", StackEncoder
> > [...]
> > Public Sub EncoderTask()
> > [...]
> > Debug.print "pulse= "; cstr(pulsecount)
>
> I'd guess you have a stack overflow here. StackEncoder reserves 33
> bytes for the task stack, of which 15 is taken up by the task
> frame. That leaves only 18 bytes for everything else, and CStr
> probably takes up more than that.
>
> -- Frank Manning
> -- NetMedia, Inc.



From: Cory Heisterkamp <>

> Frank, is there a way I can figure how many bytes
> to allocate to StackEncoder? I'm a little fuzzy
> on the memory allocation and I have over 600
> lines of code.

There's a section in the OS reference manual on measuring a task's
stack usage. Also check out message 13718 (28 May 2003) which has
an example of how to display the amount of stack space being taken
up by a couple of tasks.

-- Frank Manning
-- NetMedia, Inc.


Well, looks like it's not a stack overflow but some sort of problem with
the bx-24. Pin 11 is unresponsive to any input. Very strange as
everything else works just fine. I'm not sure when or how it could have
been damaged but I guess I'm SOL.

Cory

Frank Manning wrote:
>
> From: Cory Heisterkamp <>
>
> > [...]
> > At first I thought maybe I had a stack overflow,
> > but then I whipped up the code below and tried
> > it alone and it was still a no-go. Anything
> > wrong with this code?
> > [...]
> > Dim StackEncoder (0 to 32) as byte
> > [...]
> > CallTask "EncoderTask", StackEncoder
> > [...]
> > Public Sub EncoderTask()
> > [...]
> > Debug.print "pulse= "; cstr(pulsecount)
>
> I'd guess you have a stack overflow here. StackEncoder reserves 33
> bytes for the task stack, of which 15 is taken up by the task
> frame. That leaves only 18 bytes for everything else, and CStr
> probably takes up more than that.
>
> -- Frank Manning
> -- NetMedia, Inc.