I have been developing STM8S103 for the past two days. After adjusting the hardware, I started to write the software. The first step was to light up the LED light. It turned out to be embarrassing that it just wouldn't light up! Later, I searched Baidu and carefully checked the data sheet, only to find a big pitfall. Due to carelessness, I didn't see it and made a note as a reminder.
1. Process
To light up the LED, the process is basically the same as that of STM32:
(1) Configure GPIO (STM8S does not require the clock of each pin to be configured specifically, and the system clock can be configured at the beginning)
(2) GPIO output high and low levels
Without further ado, let's get straight to the code:
2. Code
//FUNCKTION: Initialize the LED light GPIO port
//PARA: None
//RETURN : None
void LED_Config()
{
GPIO_Init(GPIOB, GPIO_PIN_5, GPIO_MODE_OUT_PP_LOW_SLOW);
GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_SLOW);
}
//FUNCKTION: Turn on the LED light
//PARA: None
//RETURN : None
void LED_ON()
{
GPIO_WriteHigh(GPIOB, GPIO_PIN_4);
GPIO_WriteHigh(GPIOB, GPIO_PIN_5);
}
//FUNCKTION: Turn off the LED light
//PARA: None
//RETURN : None
void LED_OFF()
{
GPIO_WriteLow(GPIOB, GPIO_PIN_4);
GPIO_WriteLow(GPIOB, GPIO_PIN_5);
}
3. The problem of LED not lighting up no matter how hard you try
Because the two GPIO ports *PB4 and PB5 are used, the following figure can be seen in the data sheet:
You can see that the GPIO port marked in the red circle is T(3). Continue scrolling down to the bottom of the table to see the description of T(3):
I'm not good at English, so I won't translate it. Anyway, the meaning is that you need to add pull-up or pull-down resistors externally, otherwise it will be useless.
So, I quickly found a wire, made a line, connected a resistor, and it was done. ~~~Haha. . .
Previous article:STM8S103FP6 chip PB_4/PB_5 output problem
Next article:STM8S103 tim4 ordinary timer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Sandia Labs develops battery failure early warning technology to detect battery failures faster
- Ranking of installed capacity of smart driving suppliers from January to September 2024: Rise of independent manufacturers and strong growth of LiDAR market
- Industry first! Xiaopeng announces P7 car chip crowdfunding is completed: upgraded to Snapdragon 8295, fluency doubled
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- F28335 learning ADC configuration
- MicroPython's "Season of Docs" project
- Please recommend a step-down circuit
- C6000 Cache
- FPGA_100 Days_Binary to Decimal
- What parameters determine the emission distance of the infrared transmitter tube?
- Msp430PID control motor speed programming example
- A New Decision Feedback Equalizer Architecture Based on FPGA
- Reply and give points: 5G is coming, will you change to a 5G mobile phone?
- Application of ultra-high threshold voltage depletion-mode MOSFET DMZ0615E in mobile phone fast charging