Created Sun, 03 May 2015 17:54:59 +0000 by PSalzmann
Sun, 03 May 2015 17:54:59 +0000
Is there a list of all UNO32 interrupts and ISR call definitions? I guess something similar to what Nick Gammon published on his forum for the Atmega328? Thank You
Sun, 03 May 2015 18:02:30 +0000
There are two documents you need to read.
First is the interrupts document for the PIC32 family: http://ww1.microchip.com/downloads/en/DeviceDoc/61108G.pdf
With that you need to read the datasheet for the specific PIC on the UNO32: http://ww1.microchip.com/downloads/en/DeviceDoc/61143H.pdf
Mon, 04 May 2015 22:35:57 +0000
Thank You for the swift reply & the links to the MCHP documents. More questions:
Is there a description of how one gains access and control of hardware registers on micro controller in the MPIDE environment?
Using "attachInterrupt(interrupt, ISR, mode)" how does one know what the interrupt is? For example interrupt = 0 accesses the external interrupt on pin2, and interrupt = 1 accesses external interrupt on pin 3 (depending on hardware). I gathered as much from reading various links on Arduino and UNO32. But where does this definition come from? Is there a listing of other interrupts? I guess in a broader sense I'm asking where MPIDE defines references to the hardware. Thank You again - Phil
Tue, 05 May 2015 00:34:20 +0000
You just use them. There's no trick to it.
The external interrupt definitions are in the manual for your board.
Tue, 05 May 2015 04:20:07 +0000
Thank You for your time, but I still have questions about the last parts 1 & 2
1- So for example if I wanted to set the Timer1 interrupt enable bit - IEC0<4>, how do I write that in the mpide environment? And once I accomplish that how do I create an interrupt service routine that captures Timer1 interrupt flag - IFS0<4> having gone up?
2 - I gather that "attachInterrupt(interrupt, ISR, mode)" is only for external pin interrupts 0 to 4? Or are there other defined interrupts?
Very interesting - Thank you
Tue, 05 May 2015 08:50:53 +0000
Firstly to answer (2): Yes, attachInterrupt is only for the external interrupts. It would have been nice for it to be a full interrupt abstraction function, but Arduino are too thick to manage that kind of thing.
For part (1) there a lots of ways of doing it. The simplest way is to use my Timer library but if you want to manipulate other things, or get maximum efficiency, then manipulating the registers manually can be done.
The most efficient way is:
[regname]SET = 1 << [bit]; -- and -- [regname]CLR = 1 << [bit];
That uses the "SET" and "CLEAR" sub-registers for setting and clearing the bits. There is also an "INV" register to invert the bits. So for your IEC example you would use:
IFS0CLR = 1<<4; IEC0SET = 1<<4;
There's a more wordy way of doing it which is easier to read six months down the line:
IFS0bits.T1IF = 0; IEC0bits.T1IE = 1;
For most of these it's easiest to look in the processor header files within the compiler to get all the right names.
However, for interrupt handling, it's all abstracted by chipKIT into some easy to use functions (because we're clevererer than Arduino ;) ) I'm in the process of getting a document peer reviewed before publishing which details how you use the chipKIT interrupt system, but for now take a look in my Timer library's source code for the usage of functions like setIntEnable(), setIntVector(), etc.
Tue, 05 May 2015 12:57:39 +0000
Ok, had the word we're good to go with that interrupt document, so here's the link for you: [url]http://cdn.majenko.co.uk/docs/an/AN1132.pdf[/url]
It should tell you all you need to know to get you started working with the chipKIT interrupt system. There's another document that I don't have a link for at the moment that goes into more depth about the inner workings of the interrupt system - I'll get that link for you as soon as it's available,
Wed, 06 May 2015 20:19:47 +0000
Very Good - Thank You Majenko This will keep me busy digesting & testing for some time. We appreciate your help!
Wed, 13 May 2015 16:55:46 +0000
I copied the code in Example 7 of the interrupt document <http://cdn.majenko.co.uk/docs/an/AN1132.pdf> provided by Majenko above and it gives the following error messages when I try to compile:
sketch_may13a.cpp:4:17: error: expected initializer before 'myISR' sketch_may13a.cpp:11:17: error: expected initializer before 'myISR' sketch_may13a.cpp: In function 'void setup()': sketch_may13a.cpp:17:31: error: 'myISR' was not declared in this scope
This seems reasonable since I don't see how the compiler knows what "myISR" is nor what processor I would like to target.
What am I leaving out?
Some #include file and /or some definition of "myISR"? Thank You - Phil