First an initialization is done in the stm32cubemx for stm32f103c8t6 microcontroller. 7 stm32 microcontoller pins are initialed as output which are going to be interfaced with the seven segment display. Pins are named same as seven segment display pins. Port-A pins of stm32 microcontroller are used in the project. Port-A of stm32 microcontroller is a 16-bit wide port. I am going to use its first 7 pins from 0 to 6 in the project. Stm32cubemx configuration for declaring pins as output is shown at the right side.
Project circuit diagram
The board which i am using in the project is in the below circuit diagram. Though in the board not all the GPIO pins of stm32f103 microcontroller are exposed but still it has pretty fair amount of GPIO pins to work with. Port-A of stm32f103 has 16 GPIO pins but only 12 are exposed on the board. Luckily port-a pins from 0 to 6 are present on the board and they are enough for our project need. I connected
- Port-A pin#0 is connected to pin-a of 7 segment display
- Port-A pin#1 is connected to pin-b of 7 segment display
- Port-A pin#2 is connected to pin-c of 7 segment display
- Port-A pin#3 is connected to pin-d of 7 segment display
- Port-A pin#4 is connected to pin-e of 7 segment display
- Port-A pin#5 is connected to pin-f of 7 segment display
- Port-A pin#6 is connected to pin-g of 7 segment display
Since i am using common anode 7 segment display so the 3.3 volt output pin of stm32 is connected to com pin of seven segment display. I uploaded the code in microcontroller using stlink v2 debugger.
GPIOA->ODR = 0x003F; //Displaying 0
You can interface a series of seven segment display’s with the single port of stm32 and control them with individual pins of stm32 for displaying numbers from 0 to 100. You can make a clock with seven segment display. Special led bars can be used to make special characters diagrams etc.
You may also like:
Filed Under: Electronic Projects, STM32, STM32