2022-12-08 06:30 AM
i have a code in c of nxp mcu. in the code mcu nxp i configure pinout as:
#define led PTBD_PTBD3
#define led_dir PTBDD_PTBDD3
i am using led in pin B3, next a use
led_dir = 0;
to define output,
led=1 or led =0, to set or reset output, i want do in stm32. do you have idea? this is posible in stm32?
Solved! Go to Solution.
2022-12-08 07:40 AM
Some STM32 support bit-banding, others do not.
As there are many duplicative peripherals the approach chosen here is to use structures, and wrapping low level functions.
Your approach would need to address multiple bits.
The GPIO peripheral has a BSRR allowing for a single register write to set or clear one or multiple pin states.
2022-12-08 07:40 AM
Some STM32 support bit-banding, others do not.
As there are many duplicative peripherals the approach chosen here is to use structures, and wrapping low level functions.
Your approach would need to address multiple bits.
The GPIO peripheral has a BSRR allowing for a single register write to set or clear one or multiple pin states.
2022-12-08 11:53 AM
and i can use this?
led GPIOA->BSRR = ((led & GPIO_Pin) << GPIO_NUMBER) | (~led & GPIO_Pin)
2022-12-08 12:55 PM
try. should work, if you put together the right bits.
i used : GPIOC->BSRR = GPIO_PIN_13; : to set LED pin
2022-12-08 01:07 PM
The bitwise test seems problematic
GPIOA->BSRR = led ? (1 << GPIO_NUMBER) : (1 << (GPIO_NUMBER+16));
2022-12-09 10:28 AM
Something like the following would give you the same functionality as on NXP, and is atomic.
#define led GPIOB->BSRR = GPIO_PIN_3;
#define led_dir GPIOB->BSRR = GPIO_PIN_3 << 16;
2022-12-13 08:33 AM
i test and not work, i need define "led" as output for set and reset, led=1 or led=0, and i need too read led for polling, i am doing project with maticial key and i need toogle the port colum. but now i am using ll_gpio for avance in projet.