cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing GPIOA CRL and CRH registers using STM32 HAL libraries

BKem.1
Associate II

Hey,

I was wondering how to interface GPIO port registers CRL and CRH with HAL libraries, as I don't see such an option and simple GPIOB->CRL line gives an error.

Here are the available selections:

0693W00000D1P1rQAF.png

1 ACCEPTED SOLUTION

Accepted Solutions
That library is for an STM32F103. It's not going to work for you without modification.
The STM32F4 doesn't have CRL/CRH registers in GPIO.
If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
TDK
Guru

CRL and CRH aren't GPIO registers on all chips. On chips that they are, you can access them just fine with GPIOx->CRL and GPIOx->CRH. What chip are you using?

https://github.com/STMicroelectronics/STM32CubeF1/blob/master/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h#L483

If you feel a post has answered your question, please click "Accept as Solution".
BKem.1
Associate II

I'm using a STM32F446VET6 chip.

Might be off topic, but I'm trying to interface a TFT Screen which sends commands through data pins on a GPIO port. And looking through some examples, a writing direction needs to be set, and all libraries use the CRL and CRH registers. Although I have another problem, that my Data pins of the screen are not on the same port..

But as I understand, when selecting writing or reading direction from the screen, you set the pins to input or output mode, which I can do with HAL, right?

That library is for an STM32F103. It's not going to work for you without modification.
The STM32F4 doesn't have CRL/CRH registers in GPIO.
If you feel a post has answered your question, please click "Accept as Solution".

> when selecting writing or reading direction from the screen, you set the pins to input or output mode

It's simpler in 'F4 (and all other STM32 family) than in 'F1 - simply write 0b00 or 0b01 into the bitfield respective to given pin in GPIOx_MODER.

> which I can do with HAL, right?

Sure, you can even click it in CubeMX (or so I think, I don't use Cube/CubeMX).

JW