0% found this document useful (0 votes)
15 views8 pages

Lecture-13-to-15-STM GPIO Port Pin and HAL - GPIO Module

Uploaded by

Vani telluri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

Lecture-13-to-15-STM GPIO Port Pin and HAL - GPIO Module

Uploaded by

Vani telluri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

GPIO Port Pin Hardware

and
GPIO Software Module
STM32F302R8 block diagram GPIO Ports in STM32F302R8
STM32F302R8 block diagram GPIO Ports in STM32F302R8
• There are 8 ports in STM32F302R8
GPIO Ports in STM32F302R8

• 15 pin ports
• GPIO PORT A – PA[15:0]
• GPIO PORT B – PB[15:0]
• GPIO PORT C – PC[15:0]
• GPIO PORT D – PD[15:0]
• GPIO PORT E – PE[15:0]

• 8 pin ports
• GPIO PORT F – PF[7:0]
• GPIO PORT G – PG[7:0]
• GPIO PORT H – PH[7:0]
Typical STM GPIO port pin block
diagram/schematic
GPIO Port Pin Hardware and GPIO
Software Module
//Blinking LED Example

#include "stm32f3xx_hal.h"

GPIO_InitTypeDef GPIO_InitStruct = {0};

int main(void) {
// 1. Initialize the HAL Library
HAL_Init();

// 2. Enable the GPIO Clock


// Assuming the LED is connected to GPIO port A, enable the GPIOA clock
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO Port Pin Hardware and GPIO
Software Module
// 3. Configure the GPIO pin for the LED
GPIO_InitStruct.Pin = GPIO_PIN_5; // Assuming LED is on pin PA5
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; // Output mode: Push-Pull
GPIO_InitStruct.Pull = GPIO_NOPULL; // No pull-up or pull-down resistor
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; // Low speed
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); // Initialize GPIOA pin 5

// 4. Blink the LED


while (1) {
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); // Toggle the LED state
HAL_Delay(500); // Delay for 500ms
}
Thank You

You might also like