PIC18F45K50 FVR & IOC Port C not working

Moderator: Benj

Post Reply
Niko
Posts: 3
Joined: Tue Sep 24, 2019 1:27 pm
Been thanked: 2 times
Contact:

PIC18F45K50 FVR & IOC Port C not working

Post by Niko »

I hope somebody can please confirm and fix what I believe is a serious bug with the 18F45K50.fcdx device file...

I am in the process of porting over code from PIC18F4550 to 18F45K50 specifically because I want to use the FVR part of the ADC module and the IOC Port C functions.

In the case of the FVR for the ADC it does not appear as an option when I try to select the ADC reference voltage in the properties window of a Potentiometer, only VDD and Vref+ appear.

I traced this to missing code in the 18F45K50.fcdx file, by comparing to a similar device that has a working FVR, namely 18F45K22...

<vref>
<option name='VDD' value='0' />
<option name='Vref+' value='1' />
<option name='FVR' value='2' />
</vref>

I copied this section of code from 18F45K22.fcdx to 18F45K50.fcdx and confirmed FVR now appeared in the properties list with VDD and VRef+.

As for the Interrupt ON Change (IOC) function for Port C, it does not appear as an option when selecting what type of interrupt I am setting up. IOC for Port B does appear along with all the other interrupts. It also would not compile successfully when I was just using IOC Port B pins.

Checking the 18F45K50.fcdx file again, I can clearly see an error in the following line where IOC functionality is defined, it is defined for port A and B, not port B and C. I am not sure what is the correct contents of this line of code as I cannot find a a similar device to copy from. The closest I could find was 18F45K40, which has IOC functions for Port A, B and C. But I suspect it may not be transferable to 18F45K50.fcxd.

<interrupt ident='IOC0' type='multipin' name='IOC PORTA&b' handler='#ifndef MX_INTHANDLER_INTCON_RABIF\n#define MX_INTHANDLER_INTCON_RABIF\nchar mxtmp;\nif (ts_bit(INTCON, RABIF) && ts_bit(INTCON, RABIE))\n{\n\tFCM_%n();\n\tmxtmp=PORTB;\n\tcr_bit(INTCON, RABIF);\n}\n#else\n#warning "This interrupt has previously been enabled, so the macro <%n> may never get called."\n#endif\n' enable='IOCA=%pA0v;\nIOCB=%pB0v;\nst_bit(INTCON, RABIE);\n' disable='cr_bit(INTCON, RABIE);\n' >

I believe this problem is also in 18F25K50.fcdx file.

Please help.

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: PIC18F45K50 FVR & IOC Port C not working

Post by Benj »

Hello,

Many thanks for letting us know. I have now fixed the problems you mentioned and pushed the changes to the v8 update system. In Flowcode simply use the Help -> Check for updates menu to get the latest files.

Niko
Posts: 3
Joined: Tue Sep 24, 2019 1:27 pm
Been thanked: 2 times
Contact:

Re: PIC18F45K50 FVR & IOC Port C not working

Post by Niko »

Thank you very much for the prompt fix Ben.

I have updated and confirmed FVR is now available in ADC functions and IOC for Ports B & C are present in the interrupts selection list and my code compiles successfully for 18F45K50.

Now you need to make the same changes to the other device files in the 18F45K50 family, I have checked and found the same problem for both FVR and IOC Ports in the following device files...

18LF45K50.fcdx
18F25K50.fcdx
18LF25K50.fcdx
18F24K50.fcdx
18LF24K50.fcdx

FYI.. looks to me like the error comes from the 18(L)F1XK50 family of devices that actually do have IOC interrupts on Ports A & B, not B & C and a FVR option for the ADC. I have checked and this device family does not seem to have the same problem. I suspect a cut and paste type error without checking the device datasheet.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: PIC18F45K50 FVR & IOC Port C not working

Post by LeighM »

Thanks for the post.
I've just checked our repo and it looks like Ben already spotted that.
Could you try a "Full Database" update?
Thanks!
Leigh

Niko
Posts: 3
Joined: Tue Sep 24, 2019 1:27 pm
Been thanked: 2 times
Contact:

Re: PIC18F45K50 FVR & IOC Port C not working

Post by Niko »

Thanks Leigh, full database update done, all good now. :)

Post Reply