Development environment uses MDK5.16A + CUBEMX to generate code
Development Board Use: NUCLEO-L053R8
Core chip: STM32L053R8
Today mainly learned the next most basic IO reading and writing, IO using PA5 led output, PC13 key input
Use CUBEMX to generate LED and key settings input and output code (this step omitted), compare the simple stamp point on the line
Precautions:
The 1.NUCLEO board does not have external crystal oscillator, so the crystal oscillator chooses HSI
2. The button is best set using internal pull-up, personal habits. Did not carefully see whether the button on the circuit has a pull-up.
3.MDK use GB2312 encoding format, other coding written in Chinese comments, re-use CUBEMX generated sometimes garbled.
4. Write your own code must be written in the system prompt between the user code begin and end, so that the re-generation of CUBEMX will not overwrite this part of the code, the other place to write the program in the code will be generated by the software is overwritten.
5.MDK5 has automatic code completion function, or very good, remember to open the next.
IO read-write Learning:
if(Hal_gpio_readpin (gpioc,gpio_pin_13) = =0){//If there is a button press theHal_delay (Ten);//Delay to Jitter if(Hal_gpio_readpin (gpioc,gpio_pin_13) = =0){//re-detect if a button is pressedHal_gpio_writepin (Gpioa,gpio_pin_5,gpio_pin_set);//Press the button and light the LED}Else{hal_gpio_writepin (gpioa,gpio_pin_5,gpio_pin_reset); //Release the button and turn off the LED } }
stm32l0 Hal Library IO Read and write function