Vector Interrupts

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Vector Interrupts

Post by RKP » Tue Mar 31, 2020 2:40 am

Gentlemen,

I am looking forward to using the 18F26K42 or the 18F26Q43 and with vector interrupts.
Does the compiler support either of these two PICs?
Also does it support vector interrupts?

Thanks,
RKP

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Tue Mar 31, 2020 9:34 am

The last update (V2.2.3.0) has support for the K42 family, and a new update w/support for the Q43 is almost ready and should be available shortly. Feature-wise the two parts are pretty similar... the Q43 has more UARTs and CLCs. It also has its SFR registers relocated so that you don't have the performance hit that the K42 has.

Note that neither of these parts has library support for I2C or SPI yet. The libraries only support devices with an MSSP peripheral and those two have dedicated I2C and SPI peripherals. Also, you'll need a PICkit4/ICD4/SNAP to program/debug the Q43. Thank Microchip for that one.

Vectored Interrupts are supported in the current version. They work a bit different than normal interrupts in SF, so it requires a little restructuring from what you're used to. The library module ivt.bas provides the functions you'll need, and there are two examples (ivt_example.bas, ivt_example2.bas) in the 'Samples\NewExamples' folder of using it.

I still have to do a wiki writeup on using vectored interrupts to explain things better, but I was waiting for someone to ask before I spent my time doing that.

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Re: Vector Interrupts

Post by RKP » Tue Mar 31, 2020 1:21 pm

Thanks Jerry for the update.

Not sure which one I am going to use at the moment.
I have a Curiosity HPC board, that according to Microchip can handle both chips.

About four years ago I did a tasked that used a 18F14K50 as a USB to UART to interface with a 16F1508.
Now I have a similar task but want use my favorite compiler for both chips.
Using either chip above as replacements to the 16F1508 since Microchip finally got around with implementing those core independent peripherals from the 16 enhanced chips.

Thanks again, David and Jerry for updating the compiler.

Keith

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Tue Mar 31, 2020 4:17 pm

I have a Curiosity HPC board, that according to Microchip can handle both chips
I think that might depend on the version of the board that you have... rev 1 or rev 2.

Rev 1 has the original PKOB programmer/debugger, while the newer rev 2 has a PKOB4.
I think you need the PKOB4 version, which sort of matches up with the PK4.

I have the original Curiosity HPC board (w/PKOB) and while it lets me select it for the 18F27Q43, it never works.
I get all sorts of connection issues right off the bat.

If I use my PICkit4, it works.

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Re: Vector Interrupts

Post by RKP » Tue Mar 31, 2020 9:09 pm

Jerry,

Thanks for the heads up. Unfortunately I have the Rev1 Curiosity HPC board.
I guess that will make my choice the 18F26K42 for now.

I guess I can try to hack the Curiosity HPC to program with my Pickit2 with the "PICKitPlus" firmware software.
The new firmware supports the 18F26K42 now, and hopefully in the future the 18F26Q43.
Maybe program in David's UMC bootloader with the Pickit2 and then use the ME's USB to UART to re-program and debug.
Never used a bootloader before but this seems like a good time to use one, since this part has a lot of program memory.

Keith

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Tue Mar 31, 2020 9:33 pm

It may not be that bad, Keith.

It looks like the builtin PKOB on the Curiosity HPC rev 1 supports the K42, just not the Q43.
I'll try one and see...

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Tue Mar 31, 2020 10:30 pm

Yup, the Curiosity HPC rev 1 works with the K42.

Just remember to add

Code: Select all

// required for Curiosity HPC
config LVP = ON
to your main module, otherwise MPLABX complains.

The device files have LVP=OFF, so if you ever program it with a pickit you need to use HV programming to be able to set LVP back on.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Wed Apr 01, 2020 10:27 am

FWIW, you can use the low-cost SNAP programmer/debugger with the Q43. That works, too.

The Curiosity HPC has an SMT ICSP pattern on the rear of the pcb where you can solder a SIL header to use an external tool instead of the PKOB.
That can be handy in case you plug a chip into the board that has LVP OFF since the HPC PKOB only does LVP.

Keep in mind the SNAP only does LVP too, and to make matters worse you can't use it to supply target power, so you have to use external power to the HPC.

Out of the bunch the PICkit 4 seems to be the winner here for the Q43. That's the only one that can do HVP, LVP, and supply power to the target.
Even the ICD4 requires an external power supply.

It's getting ridiculous, I know.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Tue Feb 23, 2021 1:59 pm

Well, almost a year later and I finally got around to doing an article on using vectored interrupts!

The new IVT V2.0 module in the latest update makes this much easier to setup.
There are also a few more examples and even versions of ISRRX and ISRTimer that support using them.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Mon May 16, 2022 12:48 pm

just fyi...

I'm working on an update to the IVT module that will allow multiple ISR's to share the SF system variable context,
which can reduce the amount of ram/code space used.

Stay tuned...

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Vector Interrupts

Post by Jerry Messina » Sat Jun 04, 2022 8:46 pm

The new IVT v2.1 module now includes an option that allows for sharing the saved context among multiple intr handlers, which can save ram and code space if using a number of interrupt handlers that require saving context.

The updated module is part of the sf_update_6_1_2022

I also updated the wiki article using vectored interrupts! to show how to use this.

Post Reply