stm32l0 Hal Library IO Read and write function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.