How to set/arrange KL03 interrupt priority

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set/arrange KL03 interrupt priority

735 Views
tigerlo
Contributor III

Dear Sir,

    I want set KL03 PortB interrupt's priority is higher than RTC .

          void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) 

    1.  uint32_t priority : -1,-2  , 3 , 72 , 116 what is the priority in them ?

    2. if I use NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)  to set the priority , then it can work as these priority properly ? or  is there any other code I  need to added then it can work as it's priority ?

pastedImage_2.png

pastedImage_1.png

0 Kudos
5 Replies

567 Views
tigerlo
Contributor III

Mark,

      Thanks for your answer. it's very helpful.

      I want set the Port B interrupt higher than RTC Alarm interrupt , Is that correct?

    ==》Set  IPR5 IRQ=4 (Lowest , RTC Alarm Interrupt)  &  IPR7 IRQ3=0. (Highest, Port B Interrupt)

     IPR5 RTC AlarmpastedImage_3.png

                                                                                                                                                     IRQ0=4

 

IPR7 Port  pastedImage_4.png

                            IRQ3=0    

Tiger

0 Kudos

567 Views
mjbcswitzerland
Specialist V

Hi

With IRQ0 as 3 instead of 4 it looks to be correct.

In the uTasker project it is done like this:

#define PRIORITY_RTC            3
#define PRIORITY_PORTB          0

fnEnterInterrupt(irq_RTC_ALARM_ID, PRIORITY_RTC, _rtc_handler);

fnEnterInterrupt(irq_PORTB_ID, PRIORITY_PORTB, _port_B_isr);

which avoids the head-scratching required in your environment.

Regards

Mark

0 Kudos

567 Views
tigerlo
Contributor III

Mark,

    Thanks for your reply, I still have something don't understand.

pastedImage_1.png

pastedImage_2.png

1. I want set the Port B interrupt higher than RTC Alarm interrupt , what the IPR 5 and IPR 7 value set ?

     IPR5 RTC AlarmpastedImage_3.png

                                                                                                                                                     IRQ0=4

IPR7 Port  pastedImage_4.png

                            IRQ3=0            

  2. Is the priority  IRQ0=0    higher than IRQ0=1 or 2 or 3 ?

0 Kudos

567 Views
mjbcswitzerland
Specialist V

Hi

0 is highest priority and 3 is lowest.

Regards

Mark

0 Kudos

567 Views
mjbcswitzerland
Specialist V

Hi

The values for priority that are being displayed with whichever tool is being used can't be correct. The only possibilities are (0x00 << 6) = 0x00 [decimal 0]

(0x01 << 6) = 0x40 [decimal 64]

(0x02 << 6) = 0x80 [decimal 128]

(0x03 << 6) = 0xc0 [decimal 192]

for Cortex m0+ devices (4 priority levels), whereby the Cortex m0+ only implements these 2 bits in the register so all otherwise will read '0'

I don't know the routine
void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority);

but expect that it will either want the values 0,1,2 or 3 as priority, or else will require (0, (1 << 6), (2 << 6) or (3 << 6)) depending on how it is internally implemented.
If it is not documented or obvious from examples you will need to study its code.

Regards

Mark

Professional support for Kinetis: http://www.utasker.com/index.html
Remote desktop one-on-one coaching: http://www.utasker.com/services.html
Getting started to expert videos: https://www.youtube.com/results?search_query=utasker+shorts

0 Kudos