Programming with ARM @Cortex-M4 based STM32 Nucleo

This provides information related to ARM Cortex-M4 features , Modes, Registers etc. I have discussed importance of multiple stack pointers and privilege levels. STM32 Nucleo-L4R5ZI board is taken for this case study.

This is in continuation of last blog ARM

Where to start learning ARM architecture ?

Let me take example of three different ARM family based SoCs . Following table provides different features of specifications, the CPU implementation and SoC based on that from three different semiconductor companies.

This comparison is just to understand different ARM family features. I understand that in terms of product/pricing , this is not Apple-to-Apple comparison. You may take analogy with sticky note, Notepad and Word  Windows programs in terms of features/requirement.

Cortex-M4 @STM32

Following are three important aspects related to software architecture :

How two stack pointers help in Multi-process Applications  ?

Lets assume process-1 is using stack region pointed by PSP1 and process-2 using stack region pointed by PSP2 . Kernel is using MSP  and these processes or tasks are using PSP .

Now when process-1 starts running , PSP register  will be assigned PSP1 . When operating system scheduler interrupt occurs , control will be automatically passed to interrupt handler which itself uses MSP register for stack. Interrupt handler will assign PSP2 to PSP register . After returning from Handler mode, process state will be automatically changed to Thread mode and it will start using PSP .

This overall process will make context switching between two processes fast and independent of handler mode stack pointer i.e. MSP .

Cortex-M4 Registers Overview

I will go through necessary registers first to make learning simpler. Following registers (r0-r12), PSP, LR and PC can be accessed with unprivileged level as well.

 

Reference

Next Article   ARM Instruction Set Classification

Thanks for reading till end. I am trying to improve usability of my  site. Did you find this discussion helpful ? If so,  Please subscribe  Embedkari so that you don’t miss any interesting topic .

This particular post is discussed  at ARM Cortex-M4

 

Exit mobile version