Home
STMicroelectronics
Microcontrollers
STM8
STMicroelectronics STM8 User Manual
4
of 1
of 1 rating
126 pages
Give review
Manual
Specs
To Next Page
To Next Page
To Previous Page
To Previous Page
Loading...
{
UART1_DeInit();
UART1_Init(9600,
UART1_WORDLENGTH_8D,
UART1_STOPBITS_1,
UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE,
UART1_MODE_TXRX_ENABLE);
UART1_Cmd(ENABLE);
}
E
x
p
l
a
n
a
t
i
o
n
The peripheral and
CPU clocks are se
t at 2MHz:
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV8);
CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
….
….
CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, ENABLE);
The TX-RX GPIO pin
s are set as output and inp
ut respectivel
y:
GPIO_DeInit(GPIOD);
GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_PU_NO_IT);
UART
setup
is
straightforward. We
just
need
to
set
baud
rate,
no.
of
data
bits,
no.
of
stop
bit,
parity
and type of com
munication (synchr
onous or asynchronous).
void UART1_setup(void)
{
UART1_DeInit();
UART1_Init(9600,
UART1_WORDLENGTH_8D,
UART1_STOPBITS_1,
UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE,
UART1_MODE_TXRX_ENABLE);
UART1_Cmd(ENABLE);
}
In
the
main
code,
we
are
checking
both
transmissi
on
complete
and
reception
complete
f
lags.
With
these flags, we will
know if new data arriv
ed and if it is
possible to send a new dat
a.
The first part checks
if any new data received. That’s why the
IF
condition is checking if the RX
buffer
is empty
or n
ot. If
it is n
ot e
mpty then
new data
must
have arriv
ed. The
new data
(a
character her
e) is
fetched
and
displayed
on
a
LCD.
Then
we
clear
the
RX
buffer
not
empty
flag
to
enable
reception
of
new data. After that
we are sending s
ome data to the host PC
over the UART.
if(UART1_GetFlagStatus(UART1_FLAG_RXNE) == TRUE)
{
101
103
Table of Contents
Starting STM8 Microcontrollers
1
The STM8 Family
2
Overview of the Discovery Board
3
Hardware Tools
5
Software Tools
7
Stm8Cubemx
11
Preparing the Software Tools
12
Creating a New Code Project
14
Uploading Code
20
General Purpose Input Output (GPIO)
24
Functions
26
Hardware Connection
27
Code Example
27
Explanation
28
Demo
29
Video Link
29
Clock System (CLK)
30
External Interrupt (EXTI)
34
Stm8_Interrupt_Vector.C
38
Stm8S_It.h
39
Stm8S_It.C
39
Beeper (BEEP)
41
Alphanumerical LCD
44
Analog-To-Digital Converter (ADC)
51
Analog Watchdog (AWD)
56
Independent Watchdog (IWDG)
62
Window Watchdog (WWDG)
67
Video Link
70
Timer Overview
71
Time Base Generation (TIM2)
72
Timer Interrupt (TIM4)
76
General Purpose Pulse Width Modulation (TIM2 PWM)
82
Advanced Pulse Width Modulation (TIM1 PWM)
86
Timer Input Capture (TIM1 & TIM2)
91
Stm8_Interrupt_Vector.C (Interrupt Vector Address Part Only)
94
Stm8S_It.h (Top Part Only)
94
Stm8S_It.C (Top Part Only)
94
Communication Overview
98
Serial Communication (UART)
99
Video Link
103
Serial Peripheral Interface (SPI)
104
Inter-Integrated Circuit (I2C)
111
Some Useful Tips
119
Creation & Addition of Libraries
119
Peripheral Clock Configurations
121
Configuring Similar Stuffs Quickly
122
Some Stuffs about Cosmic C and SPL
122
Unlocking a Locked STM8 Chip
124
Mastering C Language
125
Epilogue
126
4
Based on 1 rating
Ask a question
Give review
Questions and Answers:
Need help?
Do you have a question about the STMicroelectronics STM8 and is the answer not in the manual?
Ask a question
STMicroelectronics STM8 Specifications
General
Brand
STMicroelectronics
Model
STM8
Category
Microcontrollers
Language
English
Related product manuals
STMicroelectronics STM32
118 pages
STMicroelectronics STM32F427
36 pages
STMicroelectronics STM32F038C6
103 pages
STM32F05 series
742 pages
STM32WL5 Series
1450 pages
STM32F469I-DISCO
30 pages