STM32 from ground up: NVIC active bit, Processor Modes (FIQ, IRQ, ABT, USR...)
Context: I'm writing my first STM32 "from the ground up" project. Notepad++ and GCC in command line (Windows 10) are my IDE. I've never done this before, so I'm learning ropes, taking first look into assembly (but keeping own assembly to a minimum, C does the job), writing my first makefile, linker script etc.. I've been working on my NVIC implementation, and I had a few questions I wanted to clarify. Searching the internet gave partial results. I would want to have a full picture from someone who knows the stuff better than I do.
Windows 10, STM32F746 Discovery Board. No CMSIS, no nothing. Mainly C for now. So far, I've created my own vector table, placed .data and .bss where I wanted them to go (SRAM2, because SRAM1 is executable, and who knows if I get cute later and want to run something from SRAM for the fun of it). I successfully run main(void) after reset handler places all data where it's supposed to go.
Question 1: can multiple interrupts be Active at the same time, or is strictly one active at a time, while the other ones are pending? (considering all situations, including low-priority interrupt interrupted mid-execution by higher priority interrupt). I implemented my NVIC function with the assumption that only one interrupt can be active at a time. After that I ran into some material on the internet that may have suggested otherwise. It would be nice to have this question answered once and for all.
Question number 2: while reading programming manual PM0253, I ran into CMSIS functions that generate processor instructions (page 62). The first ones are CPSIE/CPSID. I searched for what they are and ended up on ARM website, which describes what it does and what its parameters are, but gives no context. So I know how to use instruction, but I actually don't know what it does and why would I need it (especially if my program is in C and I can enable or disable interrupts by writing directly to NVIC-related registers, which is can do easily).
So, here is a piece from the ARM website:
My problem with it is the word "abort". Aborting what? I mean, there are 100-ish interrupts on the MCU I'm using, that's clear. But what is Abort? Abort what?
Next, it also mentions some "mode" of processor, so I searched that and ended up on ARM page describing these "modes" that I've never heard of. Not thread and handler mode, but some other modes, which have some weird numbers. Here:
As far as I can gather from it, USR mode, which has priviledge level PL0, is basically a thread mode, while PL1 seems like handler mode to me (let's not talk about PL2 for now). Also, as far as I can guess, FIQ means fault handler. Also, my intuitive guess is that different exceptions are associated with different modes (abort mode for memory access exception?). I take it, when I write code in C, the compiler does this mode switching? Or does it happen automatically when exception handler is triggered? What is the point of CPS change processor state instruction? What's the point in manually setting mode to FIQ? And what will happen if I call fault handler while having IRQ mode? They have the same priviledge after all. Oh yes, and I still have no idea what that ABT abort mode is and what it does, it looks like a separate mode that handles memory access exceptions, like MPU-related exceptions. In fact, I failed to find any mention of any of these modes (their abbreviations) in Datasheet/Reference Manual/Programming Manual of my MCU.
I apologise for rather vague question, but I'm trying to learn things here. Your reply could be some text or even just a link to some article or page, where these things are discussed in a friendlier way. Thank you.
