BASIC interrupt priorities

Questions about the BASICtools and MakeItC
Post Reply
maray
Posts: 1
Joined: Fri Oct 19, 2012 12:27 pm

BASIC interrupt priorities

Post by maray »

>from the help line

>Within ARMBASIC how are the Interrupt priorities currently set, mainly in reference to Systemtick, Uarts EINT0 and timers.
>Can WAIT() and WAITMICRO() be used freely within an interrupt service routine?

For almost all chips I've worked with,
SysTick and other system interrupts are not part of the priority scheme.

I saw a case recently (which we don't use) where Systick, HardFault, etc had a priority register.
You would need to verify in the Interrupt Priority Register section of the individual User Manual.

I think Systick, HardFault, etc receive the highest priority.
I did a test to verify but that was many years ago.

By default all other priorities are FF, lowest.

Bellow is a basic example to set priorities to different levels.
Note: the lower 3 bits of each 8 bit value are not used so the actual priority is >> 3.

Code: Select all

'  Interrupt Priority Registers from LPC40xx.bas
#define NVIC_IP0    *&HE000E400
#define NVIC_IP1    *&HE000E404
#define NVIC_IP2    *&HE000E408
#define NVIC_IP3    *&HE000E40C
#define NVIC_IP4    *&HE000E410
#define NVIC_IP5    *&HE000E414
#define NVIC_IP6    *&HE000E418
#define NVIC_IP7    *&HE000E41C
#define NVIC_IP8    *&HE000E420
#define NVIC_IP9    *&HE000E424
#define NVIC_IP10    *&HE000E428

sub Config
    ' set interrupt priorities
    ' Timer1   priority = 0 highest
    ' Timer2   priority = 4 (&H20 >> 3)
    ' Timer3   priority = 6 (&H30 >> 3)
    ' set all other interrupt priorities to lowest
    NVIC_IP0 = &H2000FFFF
    NVIC_IP1 = &HFFFFFF30
    NVIC_IP2 = &HFFFFFFFF
    NVIC_IP3 = &HFFFFFFFF
    NVIC_IP4 = &HFFFFFFFF
    NVIC_IP5 = &HFFFFFFFF
    NVIC_IP6 = &HFFFFFFFF
    NVIC_IP7 = &HFFFFFFFF
    NVIC_IP8 = &HFFFFFFFF
    NVIC_IP9 = &HFFFFFFFF
    NVIC_IP10 = &HFFFFFFFF
' other stuff .....
end sub



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: BASIC interrupt priorities

Post by basicchip »

>Can WAIT() and WAITMICRO() be used freely within an interrupt service routine?

WAIT() requires the Systick interrupt to be serviced, by default this will preempt other interrupts, though you can change that, but I don't recommend that.

WAITMICRO() does not need the SysTick interrupt, so that would be a better choice.

BUT Interrupt code should be kept to a minimum and it is BAD practice to wait for anything inside an interrupt !!!

AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: BASIC interrupt priorities

Post by AMDlloydsp »

I do a great deal of interrupt-serviced I/O on SuperPro boards, on real-time automated explosives manufacturing machinery.

I find it most beneficial to just set flags and "get the hell out", rather than doing 'productive work' (or especially DELAYS) inside an IRQ routine!

Depending upon your IRQ rate (which you establish, of course), the service routines alone (regardless of any 'real' processing within them) can usurp a substantial portion of your available processing time, et. al.

Lloyd

Post Reply