STM8S105C6T6 48 pins 32KB Flash Package: LQFP temp: -40~85
PA1~PA6,PB0~PB7,PC1~PC7,PD0~PD7,PE0~PE3,PE5~PE7,PG0,PG1,
There are a total of 38 general-purpose I/O ports.
GPIO Registers
Port x Output Data Register (Px_ODR);
Port x input data register (Px_IDR);
Port x output data direction (Px_DDR); 0: input mode 1: output mode;
Port x Control Register 1 (Px_CR1);
When DDR=1; set to 0 for analog open-drain output; set to 1 for push-pull output; (CR2 bit is used for output slew rate control);
When DDR=0; set to 0 floating input; set to 1 pull-up input;
Port x Control Register 2 (Px_CR2);
When DDR=0; set to 0 to disable external interrupt; set to 1 to enable external interrupt;
When DDR=1; set 0 speed 2MHz; set 1 speed 10MHz;
Corresponding GPIO library functions
void GPIO_DeInit(GPIO_TypeDef* GPIOx);
Used to restore the register of the specified port to the default value, 0x00; non-interrupt function floating input.
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode);
GPIO initialization, configuration of specified port functions
GPIO_Pin:
GPIO_PIN_0 ~GPIO_PIN_7;
GPIO_PIN_HNIB; //High four pins
GPIO_PIN_LNIB; //lower four pins
GPIO_PIN_ALL ; //All pins
GPIO_Mode: input and output mode settings;
void GPIO_Write(GPIO_TypeDef* GPIOx, u8 PortVal);
Write value to the corresponding GPIO output.
void GPIO_WriteHigh(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins);
Sets one or more pins of the specified port and outputs a high level, provided that the port is configured in output mode.
void GPIO_WriteLow(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins);
Sets one or more pins of the specified port and outputs a low level, provided that the port is configured in output mode.
void GPIO_WriteReverse(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins);
Negate the level state of one or more pins of the specified port and output them, provided that the port is configured in output mode.
u8 GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
Read the specified port data and return an 8-bit unsigned value. The prerequisite is that the port is configured in input mode.
u8 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
Read the value of the specified port output register and return an 8-bit unsigned value.
BitStatus GPIO_ReadInputPin(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin);
Read the status of one or more pins of the specified port. If any pin is high, it returns SET, otherwise it returns RESET.
void GPIO_ExternalPullUpConfig(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, FunctionalState NewState);
Pin to enable or disable the internal pull-up resistor.
The STM8S series can be programmed using library functions or by directly manipulating registers.
Library function version of GPIO lights up LED (IAR FOR STM8S)
#include "stm8s.h"
#define uint unsigned int
void Delay(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=220;j>0;j--);
}
void main()
{
GPIO_Init( GPIOD,GPIO_PIN_0,GPIO_MODE_OUT_PP_HIGH_FAST);
GPIO_WriteHigh(GPIOD,GPIO_PIN_0);
Delay(500);
GPIO_WriteLow(GPIOD,GPIO_PIN_0);
Delay(500);
while(1);
}
void assert_failed(u8* file, u32 line)
{
while (1)
{
}
}
Previous article:STM8S independent watchdog configuration and use
Next article:STM8S HSI self-study notes
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Taking a “family-first” approach to op amp design
- Who knows the name of the chip?
- How to realize 12864 display of 430f149 MCU AD sampling waveform
- Pre-match training FAQ: Detailed explanation of ON Semiconductor's ultra-low power RSL10 Bluetooth SoC development board
- How to start with PCB layout and wiring to avoid noise caused by improper switching power supply layout
- EEWORLD University ---- Type-C end-to-end solution
- Diary of the trouble of building TMS320F28379D project with css6.0
- ESP32-S2 Development Pitfalls (4) -- USB Pitfalls
- Analysis of several components of switching power supply that "seriously affect the cost"!
- Three differential amplifier circuits, available for actual testing