Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

c - Disable IRQ on STM32

Is there any way to disable all irq from Cortex M3 MCU except one ?

My issue is that I have a system running several kinds of irq with various priority levels and I want to disable all irq except one in a particular state.

I know I can disable all irq by using "__disable_irq()" instruction but I can't enable one irq after calling this instruction if I didn't call "__enable_irq()" before.

Thanks for your help,

Regards

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use the BASEPRI register to disable all interrupts below the specified priority level.

This is a core register, described in the Cortex-M3 Programming Manual.

enter image description here

CMSIS provides the __get_BASEPRI() and __set_BASEPRI() functions to manipulate its value.

Note that bits 7-4 are used, the priority value must be shifted left by 4. To disable all interrupts with priority 1 or lower, use

__set_BASEPRI(1 << 4);

and to enable all, set it to 0

__set_BASEPRI(0);

You should of course set interrupt priorities accordingly, ensuring that no other interrupt has priority 0.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...