Skip to main content
uhaid.1
Associate
September 5, 2022
Question

what is diffrencce between direct register accessing vs hal.instance?? for example: SPI2->SR; //direct register accessing hspi2.Instance->SR; // hal.instance register accessing

..

This topic has been closed for replies.

3 replies

Piranha
Principal III
September 7, 2022

This has nothing to do with STM32 and even MCUs in general. Only learning the C language can help:

http://www.tutorialspoint.com/cprogramming/index.htm

waclawek.jan
Super User
September 7, 2022

The latter allows you to change mind and switch to a different SPI painlessly (this may be arguably rare).

​

JW​

Piranha
Principal III
September 7, 2022
#define SPI_MOTOR SPI2
 
SPI_MOTOR->SR;

This will do the same.