interrupt on port B

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
samdel
Posts: 7
Joined: Sun May 07, 2006 6:46 pm
Contact:

interrupt on port B

Post by samdel »

hello, the macro "interrupt_portB" is executed twice (or more) every time for a single change on portB even with a simple program
I have succeed one time (on a program doing nothing) using delays but it's not efficient on my actual program .

You could see the problem using the simulation on ISIS (proteus) or on a board with the real devices.
My program read a keyboard and write the touch on a LCD screen.
The value of the touch is written twice.

Could you help me ?.
Regards
Christian

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Hello Christian,

Congratulations - you have posted the 100th topic in the FlowCode forum, and your prize is.....

....an attempt to answer your problem! :D

The PORTB interrupt gets called each time there is a change in state of the top nibble of PORTB. This means that the interrupt will fire once when the key is pressed down, and then again when the key is released.

Note also that the switch may not be debounced, and may cause multiple changes of statewhen pressed down.

The other possible problem is that another pin in the top nibble of PORTB is also changing state. For example: if the LCD display is connected to PORTB, then (by default) B4 and B5 are used to communicate to the LCD. These could possibly be triggering the interrupt. [I'm not sure about this without testing - it may be that interrupts only get triggered by external signals].

I hope this solves your problem.

samdel
Posts: 7
Joined: Sun May 07, 2006 6:46 pm
Contact:

interrupt on portB

Post by samdel »

This is a quick answer but when I spoke about a change it was only one edge on only one pin of portB (choice beetween RB4 .. RB7) and , when you simulate there is no perturbation ,
altough , in my program , when I examine the portB to read the keyboard , I had add a delay of 3 seconds to prevent reading defaults of the buttons.
The simulation woks exactly as my manipulation.

Another idea ?
regards
Christian

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Hello Christian,

I'm sorry, but I can't think of anything else.

Perhaps you will need to keep track of the status of the input within the interrupt routine using a variable and react depending on the state of this variable.

Post Reply