PIC18F47J53 Pin interrupt configuration

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

Moderator: Benj

Post Reply
streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times

PIC18F47J53 Pin interrupt configuration

Post by streammaster »

Hi All,

I'm stuck on configuring the pin mapping chip internal configuration register. I had a look in example configuring 'Custom Interrupt properties'; but for the 18F47J53 there are INT 0, 1, 2, 3 pins available to choose already, I need to use two interrupts INT0 (this is a fixed pin input) and another interrupt like INT1 which is routable to pin.
My problem is that I do not understand a link between Selection in Flowcode for the interrupt (like INT1Pin). Where I declare that the actual pin mapping and also the Interrupt priority?
Aditional trouble is that the Microchip MCC has no support for PIC18F47J53 so I'm out of ideas how to help my self. However, I managed to configure successfully the Project Options -> Configure hardware registers. I can get local oscillator working and the chip is actually working correctly with the correct frequency for USB and for simulation (48MHz). Here is the Configuration:
Configure PIC18F47J53.PNG
(64.47 KiB) Downloaded 2058 times
I hope somebody will know what to do to get the Interrupt going.


Thanks.

Igor

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:

Re: PIC18F47J53 Pin interrupt configuration

Post by Benj »

Hello Igor,

Thanks for letting us know, it's a new device for us so looks like there may be a few problems lurking. I've added the options for the INT pins now as part of the interrupt properties.

Simply copy the attached file into your "Flowcode 7/FCD/PIC" folder and restart Flowcode. I've also done the other definitions in the family so let me know if you need others.
18F47J53.fcdx
(53.78 KiB) Downloaded 233 times
Let us know how you get on.

streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times

Re: PIC18F47J53 Pin interrupt configuration

Post by streammaster »

Thanks for that, it makes sense now.

I noticed that the separate pin input for 'simulation Pin':
Interupt pins.PNG
(18.92 KiB) Downloaded 2052 times
There are no options to select different pin. The problem is that the RB4 is fixed pin for SCL (i2c port 1).
Way it can be in simulation the same as the Remapped pin?

Regards,

Igor

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:

Re: PIC18F47J53 Pin interrupt configuration

Post by Benj »

Hi Igor,

The simulation pin is currently fixed in the definition file and cannot be changed on the fly. However you can change the pin by editing the file.

Copy the file to a location where you can edit it, e.g. the desktop.

Then find this section in the file using a text editor. I've highlighted the parts to change to alter the pin to B2 and also changed the values for you.
<interrupt ident='INT1' type='pin' name='INT1 Pin' handler='#ifndef MX_INTHANDLER_INTCON3_INT1IF\n#define MX_INTHANDLER_INTCON3_INT1IF\nif (ts_bit(INTCON3, INT1IF) && ts_bit(INTCON3, INT1IE))\n{\n\tFCM_%n();\n\tcr_bit(INTCON3, INT1IF);\n}\n#else\n#warning "This interrupt has previously been enabled, so the macro <%n> may never get called."\n#endif\n' enable='st_bit(INTCON3, INT1IE);\n' disable='cr_bit(INTCON3, INT1IE);\n' >
<ioc config='3' >
<rising port='1' mask='4' />
<falling port='1' mask='4' />
</ioc>
<options >
<edge name='Interrupt Edge Select' >
<entry name='Rising edge of INT' value='st_bit(INTCON2, INTEDG1);\n' />
<entry name='Falling edge of INT' value='cr_bit(INTCON2, INTEDG1);\n' />
</edge>
<option name='Remapped Pin Selection' >
<entry name='RP0 - RA0' value='RPINR1 = 0;\n' />
<entry name='RP1 - RA1' value='RPINR1 = 1;\n' />
<entry name='RP2 - RA5' value='RPINR1 = 2;\n' />
<entry name='RP3 - RB0' value='RPINR1 = 3;\n' />
<entry name='RP4 - RB1' value='RPINR1 = 4;\n' />
<entry name='RP5 - RB2' value='RPINR1 = 5;\n' />
<entry name='RP6 - RB3' value='RPINR1 = 6;\n' />
<entry name='RP7 - RB4' value='RPINR1 = 7;\n' />
<entry name='RP8 - RB5' value='RPINR1 = 8;\n' />
<entry name='RP9 - RB6' value='RPINR1 = 9;\n' />
<entry name='RP10 - RB7' value='RPINR1 = 10;\n' />
<entry name='RP11 - RC0' value='RPINR1 = 11;\n' />
<entry name='RP12 - RC1' value='RPINR1 = 12;\n' />
<entry name='RP13 - RC2' value='RPINR1 = 13;\n' />
<entry name='RP14 - RC3' value='RPINR1 = 14;\n' />
<entry name='RP15 - RC4' value='RPINR1 = 15;\n' />
<entry name='RP16 - RC5' value='RPINR1 = 16;\n' />
<entry name='RP17 - RC6' value='RPINR1 = 17;\n' />
<entry name='RP18 - RC7' value='RPINR1 = 18;\n' />
</option>
<option name='Simulation Pin' >
<entry name='RB2' value='' />
</option>
</options>
</interrupt>


When you're done editing simply copy the file back to the FCD/PIC folder. Remember to make a backup of the file just incase you need to go back.

Let us know how you get on.

streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times

Re: PIC18F47J53 Pin interrupt configuration

Post by streammaster »

Hi Ben,

thank you for instructions:
Interupt pins fixed.PNG
(19.14 KiB) Downloaded 2037 times
It worked. However, I still have to actually build the code and do simulation I will let you know if I will have any issue with simulation.

I noticed some issue related to interrupts and simulation on UART ( Interupt really not working in simulation but works on actual hardware). Will post this question as a separate post.

Thanks a lot for this help!

Regards,

Igor

Post Reply