Interrupt not working

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

Moderators: Benj, Mods

Post Reply
echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Interrupt not working

Post by echase »

I can’t get my PIC to recognise any interrupt. I have 4 switches on Port B and although they can be read easily with an input command, if I use an interrupt to call a macro to execute this input command then nothing happens when any button is pressed. So it is not reacting to the interrupt. Have tried both upper nibble and B0 interrupts. (Flowcode simulation works fine.)

What am I doing wrong?

1) Is it an error in the 16F886.FCD file? Please Ben can you try it on your 887 to check, assuming any error woudl also be in the 887 file? You have my code for this.

2) Have I put the interrupt command in wrong place? It’s at beginning of flowchart and I assume that wherever the code is at the time that the interrupt will always stop the program and jump to the above macro. Is that right?

3) Does an interupt need a special hardware circuit to trgger it? I am using a push button to 5V via 220 ohm resistor. with pulldown to 0V. It switches from 5 to 0V OK as measured by voltmeter.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello Echase

Yes I think I have found the problem. Try adding a C code statement straight after you enable the interrupts with the following C code.

Code: Select all

iocb = 0xff;
This enables all of the portB pins to interrupt on change. If you want to change which pins can trigger the interrupt then you can change the hex value going into the icob register.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Post by echase »

Great. Does that work with upper nibble B port change? Don't want it to react to lower nibble as that is connected to some LED outputs (or maybe, as these only light when set to outputs, the interrupt on input would not trigger). I have masked off the lower nibble in the Input command.

Slightly worrying that certain bits of Flowcode like OSCCON and this don't work without extra lines of C code being added. Is it something you correct in future releases or is it because Flowcode can’t cover all PIC varieties without some C lines being added?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

Flowcode can cover all varieties of PICmicros but there are still a few bugs present in our FCD files.

I will be editing the FCD files for the 886 and family to correct this problem.

To just allow interrupts of the high nibble of PortB you use the following C command.

Code: Select all

iocb = 0xf0;

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Post by echase »

Works fine, thanks

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Post by echase »

Now that the 16F886 file has been upissued in v3.2.2 is this line of C still needed?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello echase

yes it looks like the C command is still required to mask off the low nibble.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Sorry I was wrong.

This was something that we changed a while ago. With the latest FCD you should get the option to select properties when using the port change interrupt. This will allow you to mask off the pins you want to trigger the interrupt.

Post Reply