For a peripheral PPP(), there is an initialization function in HAL as:


and there is also the following which is a called a callback:


In this manual, it says:

HAL_PPP_MspInit() is called from HAL_PPP_Init() API function to perform peripheral system level initialization (GPIOs, clock, DMA, interrupt)

I'm a bit confused with the meanings of initializations here and the terminology.

1-) What type of initialization is HAL_PPP_Init() called in terminology if not low-level? After we compile the code and upload to the uC memory isn't all happening low-level hardware level? I guess HAL_PPP_MspInit sets up registers that's why called system level. So does that mean HAL_PPP_Init stored in memory registers after the upload and HAL_PPP_MspInit is actually executed?

2-) Is the following true about the usages?

low-level initialization = peripheral level initialization = system level initialization


1 Answer 1


The HAL_XXX_Init() initializes the peripheral XXX for use, I2C, SPI, USART or whatever. Usually you give it a handle which peripheral to initialize, such as I2C4, SPI2 or UART7. It only initialsizes the given peripheral, but that is not enough, you can't use the peiripheral without setting up other resources to use the peripheral.

The HAL_XXX_MspInit() sets up everything else needed to use the peripheral. It sets up the clock frequency and clock source to the peripheral. It enables the clocks to the peripheral. Iy enables the clocks to IO port the peripheral uses. It configures the IO pins for use with the peripheral.

  1. No, not correct. They both write to registers. The Init will only uses the periperal registers and MspInit uses registers of other peripherals to allow the peripheral to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.