Objective C of stm32.

Source: Internet
Author: User
Tags ranges
Stm32 has an interrupt source for the settable of 43 channels; AIRC (Application interrupt and reset register) registers have 4 bits for the specified priority. The four bits are used to assign the preemption priority and sub priority. They are defined in the stm32 Firmware Library as follows:

# Define nvic_prioritygroup_0 (uint32_t) 0x700 )/*! <0 bits for pre-emption priority
4 bits for subpriority */
# Define nvic_prioritygroup_1 (uint32_t) 0x600 )/*! <1 bits for pre-emption priority
3 bits for subpriority */
# Define nvic_prioritygroup_2 (uint32_t) 0x500 )/*! <2 bits for pre-emption priority
2 bits for subpriority */
# Define nvic_prioritygroup_3 (uint32_t) 0x400 )/*! <3 bits for pre-emption priority
1 bits for subpriority */
# Define nvic_prioritygroup_4 (uint32_t) 0x300 )/*! <4 bits for pre-emption priority
0 bits for subpriority */

Visualization:

You are God,
43 people have been created, so many people have to be divided into social class and social class;
Because "class" has a heavy part of speech; "class" is neutral,
So preemption priority-> class; each class contains some class, sub priority-> class;

If the score is based on nvic_prioritygroup_4, it is divided into 16 classes (one class is one preemption priority), 0 class; high class people, it can interrupt low-class people who are doing things (nesting). A maximum of one interrupt and 15 levels of nesting can be completed.
For each class (each preemption priority), you can specify the 43 people who enter the class; for a person named exti0_irqchannel, you specify him to Enter Class 8, then
Nvic_initstructure.nvic_irqchannel = exti0_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 8; // specify preemptible Priority Level 1, which can be 0-15

In addition, when a person is working in the same class, another person cannot interrupt him; (there is no nested relationship between the source of the same preemption priority level)
Also, if the two of them want to do things at the same time, because there is no class, they will sort the physical order in the vector table and let the top people do it;

Another person, spigot irqchannel, is set as follows:
Nvic_initstructure.nvic_irqchannel = spi1_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 0; // specify preemptible Priority Level 1. The value ranges from 0 to 15.

Spigot irqchannel has a high class, And exti0_irqchannel can interrupt (nested) when doing things ).

If the score is based on nvic_prioritygroup_3, it is divided into eight classes (one class is one preemption priority), each class has two classes (sub priority); high class people, it can interrupt low-class people who are doing things (nesting). A maximum of one interrupt and seven levels of nesting can be completed.

For each class (each preemption priority), you can specify the 43 people who enter the class; for a person named exti0_irqchannel, you specify him to Enter Class 3, then:
Nvic_initstructure.nvic_irqchannel = exti0_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 3; // specify preemptible Priority Level 1, which can be 0-7
You also need to specify his class:
Nvic_initstructure.nvic_irqchannelsubpriority = 0; // specify the response priority level 0, which can be 0-1

Another person is exti9_5_irqchannel. His Class and Class are set as follows:
Nvic_initstructure.nvic_irqchannel = exti9_5_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 3; // specify the preemptible priority level 0, which can be 0-7
Nvic_initstructure.nvic_irqchannelsubpriority = 1; // specify response Priority Level 1

The two are brothers of the same class. When a person is working, the other person cannot interrupt him. (There is no nested relationship between the source of the same preemption priority level)
If both of them want to do things at the same time, the former has a higher class, so the former has a higher priority.

Another person is usartjavasirqchannel. His Class and Class are set as follows:
Nvic_initstructure.nvic_irqchannel = usart?irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 2; // specify the preemptible priority level 0, which can be 0-7
Nvic_initstructure.nvic_irqchannelsubpriority = 1; // specify response Priority Level 1

Usartjavasirqchannel has the highest priority. When two people do things, they can interrupt (nesting ).

And so on.Stm32 has an interrupt source for the settable of 43 channels; AIRC (Application interrupt and reset register) registers have 4 bits for the specified priority. The four bits are used to assign the preemption priority and sub priority. They are defined in the stm32 Firmware Library as follows:

# Define nvic_prioritygroup_0 (uint32_t) 0x700 )/*! <0 bits for pre-emption priority
4 bits for subpriority */
# Define nvic_prioritygroup_1 (uint32_t) 0x600 )/*! <1 bits for pre-emption priority
3 bits for subpriority */
# Define nvic_prioritygroup_2 (uint32_t) 0x500 )/*! <2 bits for pre-emption priority
2 bits for subpriority */
# Define nvic_prioritygroup_3 (uint32_t) 0x400 )/*! <3 bits for pre-emption priority
1 bits for subpriority */
# Define nvic_prioritygroup_4 (uint32_t) 0x300 )/*! <4 bits for pre-emption priority
0 bits for subpriority */

Visualization:

You are God,
43 people have been created, so many people have to be divided into social class and social class;
Because "class" has a heavy part of speech; "class" is neutral,
So preemption priority-> class; each class contains some class, sub priority-> class;

If the score is based on nvic_prioritygroup_4, it is divided into 16 classes (one class is one preemption priority), 0 class; high class people, it can interrupt low-class people who are doing things (nesting). A maximum of one interrupt and 15 levels of nesting can be completed.
For each class (each preemption priority), you can specify the 43 people who enter the class; for a person named exti0_irqchannel, you specify him to Enter Class 8, then
Nvic_initstructure.nvic_irqchannel = exti0_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 8; // specify preemptible Priority Level 1, which can be 0-15

In addition, when a person is working in the same class, another person cannot interrupt him; (there is no nested relationship between the source of the same preemption priority level)
Also, if the two of them want to do things at the same time, because there is no class, they will sort the physical order in the vector table and let the top people do it;

Another person, spigot irqchannel, is set as follows:
Nvic_initstructure.nvic_irqchannel = spi1_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 0; // specify preemptible Priority Level 1. The value ranges from 0 to 15.

Spigot irqchannel has a high class, And exti0_irqchannel can interrupt (nested) when doing things ).

If the score is based on nvic_prioritygroup_3, it is divided into eight classes (one class is one preemption priority), each class has two classes (sub priority); high class people, it can interrupt low-class people who are doing things (nesting). A maximum of one interrupt and seven levels of nesting can be completed.

For each class (each preemption priority), you can specify the 43 people who enter the class; for a person named exti0_irqchannel, you specify him to Enter Class 3, then:
Nvic_initstructure.nvic_irqchannel = exti0_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 3; // specify preemptible Priority Level 1, which can be 0-7
You also need to specify his class:
Nvic_initstructure.nvic_irqchannelsubpriority = 0; // specify the response priority level 0, which can be 0-1

Another person is exti9_5_irqchannel. His Class and Class are set as follows:
Nvic_initstructure.nvic_irqchannel = exti9_5_irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 3; // specify the preemptible priority level 0, which can be 0-7
Nvic_initstructure.nvic_irqchannelsubpriority = 1; // specify response Priority Level 1

The two are brothers of the same class. When a person is working, the other person cannot interrupt him. (There is no nested relationship between the source of the same preemption priority level)
If both of them want to do things at the same time, the former has a higher class, so the former has a higher priority.

Another person is usartjavasirqchannel. His Class and Class are set as follows:
Nvic_initstructure.nvic_irqchannel = usart?irqchannel;
Nvic_initstructure.nvic_irqchannelpreemptionprioRity = 2; // specify the preemptible priority level 0, which can be 0-7
Nvic_initstructure.nvic_irqchannelsubpriority = 1; // specify response Priority Level 1

Usartjavasirqchannel has the highest priority. When two people do things, they can interrupt (nesting ).

And so on.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.