Blinking a LED in Multiple Sequences Using STM 32
by Jugraj Shergill in Circuits > Electronics
18 Views, 0 Favorites, 0 Comments
Blinking a LED in Multiple Sequences Using STM 32
STM32 is a microcontroller just like Arduino Uno and Rasberry pi which is considered an industry standard. The microcontroller is a kind of integrated circuit chip, which uses VLSI technology to integrate the central processing unit CPU, random access memory RAM, read-only memory ROM, various I/O ports, interrupt systems, timers with data processing capabilities, counter and other functions (may also include display drive circuit, pulse width modulation circuit, an analog multiplexer, A/D converter, and other circuits) into a silicon chip to form a small and complete microcomputer system. Because 8-bit single-chip microcomputers have a simple internal structure, small size, and low cost, they are widely used in some simpler controllers. Common 8-bit microcontrollers mainly include Intel's 51 series, Atmel's AVR system, Microchip's PIC series, TI's MSP430 series, and so on.
Supplies
- STM 32 BOARD
- USB TYPE C CABLE
- 3 LED's
- JUMPER WIRES
- BREADBOARD
Installing STM 32 Cube IDE
Download the STM 32 Cube IDE in order to perform this task
The file can be downloaded from the following link:
https://github.com/eziya/STM32_HAL_I2C_HD44780/blob/master/Src/liquidcrystal_i2c.h
STARTING THE PROJECT
As we head into programming in the CUBE IDE head over to the top left and create a new STM32 project by clicking on "FILE" and then "NEW" then after on new "STM32 Project".
SETTING PIN CONFIGURATION
Once the file is created select the required STM board and then after set the pin configuration as shown.
NOTE: Set the pin in output configuration as we will be writing the data i.e. we will be giving the input through the code.
CLOCK CONFIGURATION
In any synchronous circuit, clock frequency plays an integral part thereby we set the frequency as shown in order to execute the task.
CODE GENERATION
One of the major advantages of using STM32 IDE is that the code is automatically adjusted according the the clock configuration and then we just have to make a little bit of changes using the required syntax.
The only change we make is that we add the following information in the existing code:
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);
HAL_Delay(400);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);
HAL_Delay(500);
}
Using the Binary File
One of the tricky part is that we will require the binary file i.e. .elf file.
For that, we simply open the .elf file created in the system explorer by Right clicking on the project and clicking on show in system explorer and copying the path on the STM32Cube PROGRAMMER.
STM 32 CubeProgrammer
Next we just need to copy the path of the file in the programmer connect the STM32 Board with the system and upload the code to get the required results.
Make sure that hardware implementation is according to the code that we make.
TA DAA!!
Finally after executing all the above mentioned steps we can clearly see the 3 LEDs blinking in different sequences such as 001,010,011 etc.
There we go, we have reached the end of the program and got the required result.