Ql vịl iS Clock Configuration b4 300090)¡ Project Manager == System view
|
System Core * x Software Packs GF Pinout view
NVIC Mode and Configuration (J Sort by inte
ˆ >
> Code generation Configuration Force DMA
DMA >
GPIO > Priority Group L] Sort by Premption Priority and Sub Priority
IWDG >
Search © =Show |available interrupts v-
RCC
4 SYS Non maskable interrupt 0 STM32F103C6Tx °
Hard fault interrupt 0
WWDG Memory management fault 0 LQFP48 v |
Prefetch fault, memory access fault 0 `» |
Analog Undefined instruction or illegal state 0
Ti System semice call via SWI instruction 0
Debug monitor 0
tmers
Pendable request for system service 0
Connectivit
y Time base: System tick timer 0
PVD interrupt through EXTI line 16 O 0
Computing Flash global interrupt O 0
RCC global interrupt O 0
Middleware EXT! line0 interrupt
1
TINS <
SYS Mode and Configuration
Mode
System Core v Debu g |Serial Wire
@ Sy: stem Wake-Up
a
Timebase Source |SysTick
DMA
nang »
Timers > & Warning: This peripheral has no parameters to be configured.
while (1)
{
/* USER CODE END WHILE */
HAL GPIO_ TogglePin(GPIOA,PGIPN_IO1);
HAL _Delay(500);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
void EXTIO IRQHandler(void)
{
/* USER CODE BEGIN EXTIO_IRQn 0 */
HAL GPIO_WritePin(PIGN P1,IGPOIOA_P,INGRPEISEOT);
for(int 1=0;1<10;1+++)
{
HAL GPIO_ TogslePm(GPIOA,GPPIIN O2_);
HAL_ Delay(500);
}
/* USER CODE END EXTIO_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
/* USER CODE BEGIN EXTIO_IRQn 1 */
/* USER CODE END EXTIO_IRQn 1 */
2 3:
Cau hình giống c2_1
while (1)
J1 f
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
void EXTIO IRQHandler (void)
=l{
/* USER CODE BEGIN EXTIO IRQn 0 «/
if(HAL GPIO ReadPin(GPIOAP, ING0P)I ==O0)
dem++;
if( demt3==0 )
= ¢
HAL GPIO WritePin(GPPINIO 1,GAPI,O GPIP N I SEO T);
ro}
else
=] HAL{ GPIO WritePin(GPIOA,GPIO PIN 1,GPIO PIN RESET);
+} /* USER CODE END EXTIO IRQn 0 */
HAL GPIO EXTI_IRQHandler(GPIO PIN_0);
/* USER CODE BEGIN EXTIO IRQn 1 */
/* USER CODE END EXTIO IRQn 1 */
2_4: cầu hình giống 2_1
+
void EXTIO_IRQHandler (void)
Bf
/* USER CODE BEGIN EXTIO_IRQn 0 */ 0)==0):
if (HAL GPIO ReadPin(GPIOA,GPIO PIN 0)==0)
HH
while (HAL GPIO ReadPin(GPIOA,GPIO PIN
dem++:
fs }
it (dem==1)
1 [ HAL GPIO WritePin(GPIOA,GPIO PIN 1,GPIO PIN SET):
HAL GPIO WritePin(GPIOA,GPIO PIN 2,GPIO PIN RESET):
HAL GPIO WritePin(GPIOA,GPIO PIN 3,GPIO PIN RESET):
m }
if (dem==2)
1 [ HAL GPIO WritePin(GPIOA,CPIO PIN 1,GPIO PIN RESET):
BAL GPIO WritePin(GPIOA,CPIO PIN 2,GCPIO PIN SET):
HAL GPIO WritePin(GPIOA,GPIO PIN 3,GPIO PIN RESET):
E } if(dem==3)
m HAL GPIO WritePin(GPIOA,CPIO PIN 1,GPIO PIN RESET):
HAL GPIO WritePin(GPIOA,CPIO PIN 2,GPIO PIN RESET):
i HAL GPIO WritePin(GPIOA,GPIO_PIN_2,GPIO_PIN_SET):
if (dem>=4)
1 [ HAL GPIO WritePin(GPIOA,GCPIO PIN 1,GCPIO PIN RESET):
HAL GPIO WrivePin(CPIOA,GCPIO PIN 2,GPIO PIN RESET):
BAIL GPIO WritePin(GPIOA,CPIO PIN 3,GPIO PIN RESET),dem=0:
E }
/* USER CODE END EXTIO_IRQn 0 */
HAL GPIO EXTI IRQHandler(GPIO PIN 0):
2 5:
[0] sTM32CubeMX 2_4.i0c*: STM32F103C6T Window Help @® Fi oy .. x
File GENERATE CODE ky
2_4.ioc - Pinout & Configuration |
Clock Configuration Project Manager s
Ql vị] @ x Software Packs 4509) iF Pinout view == System view
NVIC Mode and Configuration i
la Configuration Sort by inte
System Core LY ec generation Force DMA
a Priority Group O Sort by Premption Priority and Sub Priority ([
DMA Search © Show :|available interrupts v-
GPIO
NVIC Interrupt Table rele
IWDG
Non maskable interrupt 0
NVIC
Hard fault interrupt 0
RCC
Memory management fault 0
4 vowoc
0
Prefetch fault, memory access fault
0
Anal > Undefined instruction or illegal state 0
nalog s yystem service call via SWI instruction---:
- >| Debug montr ọ oun Hi STM32F103C6Tx
imers Pendable request for system service 0 - — LQFP48
0
Connectivityvà > Time base: System tick timer- - L 0 GPIO_EXTH liếm
PVD interrupt through EXTI line 16 O 0
Computing > Flash global interrupt O 09 1<
RCC global interrupt 2 ø| 8|&
1 š 55
Middleware > EXTl fined intemapt 8 3, 8
EXTI line1 interrupt
se
oO Preemption Priority L +] Sub Priority L Q có Q Le ral
Q
/* UDEK CUUE BEGIN WHLLE ^/
while (1)
{
/* USER CODE END WHILE */
HAL GPIO TogglePin(GPIOB,PGINPI0O );
HAIL Delay (500);
/* USER CODE BEGIN 3 */
} USER CODE END 3 */
/* EXTIO IRQHandler (void)
-_} USER CODE BEGIN EXTIO IRQn 0 */
void GPIO WritePin(GPIPN I0,O GPB IO,PG INPREI SEO T);
Hí
/*
HAL
for (int i=0; i<5;i++)
{
HAL GPIO TogglePin(GPIOB,PGINPI1)O;
HAL Delay(200);
}
/* USER CODE END EXTIO IRQn 0 */
HAL GPIO EXTI IROHandler(G PIPNI9O0);
/* USER CODE BEGIN EXTIO IRQn 1 */
/* USER CODE END EXTIO TROn 1 */
t— “/
void EXTI1 IRQHandler (void)
=]{ USER CODE BEGIN EXTI1 IRQn 0 */
GPIO WritePin(GPIPN I0,O GPB IO,PG INPREI SEO T);
/*
HAL
for (int j=0;7 j3<10;3++)
{
HAL GPIO TogglePin(GPIOB,PGINPI2O);
HAL Delay (4990);
}
/* USER CODE END EXTI1 IRQn 0 */
HAL GPIO EXTI IROHandler(PGIPNI1O);
/* USER CODE BEGIN EXTI1 IRQn 1 */
/* USER CODE END EXTI1 IRQn 1 */
}
2 6:
Q vị & NVIC Mode and Configuration 4) iOF Pinout view == System view
LY
ik Configuration PAI4 SYS_JTCK-SWi
> v a
System Core > ® Code generation 5 888 88
>
ˆ > Priority Group O Sort by Premption Priority and Sub Priority 1 Sort by inte 5
> Force DMA
DMA Search © _ Show |available interrupts v:>
GPIO NVIC Interrupt Table 0 3 SYS_JTMS-SWDIO
IWDG Non maskable interrupt 0 GPIO_extio [Z7 : STM32F103C6Tx
6Pio ni fy LQFP48
RCC Hard fault interrupt 0
0
4 wne Memory management fault 0
Prefetch fault, memory access fault 0
Analog Undefined instruction or illegal state 0
Timers System service call via SWI instruction 0
Connectivit Debug monitor 0
y - H09
Pendable request for system service
Computing Time base: System tick timer O 0
Middleware O 0
PVD interrupt through EXTI line 16
2
Flash global interrupt 1
RCC global interrupt
EXtTl lined interrupt
EXT] line’ interrupt
LlIEnabled Preemption Priority L +] Sub Priority L Q có Q là al) af
int dem=0;
]char ma_ 1ed[]={0Oxc0, Ox£9, Oxa4, Oxb0, 0x99, Ox92,
- 0x82, 0x£f8, 0x80, 0x90};
void hientthi( unsigned int data)
] t
HAL GPIO WritePin(GPIPO INB0,,G daP taIélO);
HAL GPIO WritePin(GPIP N I 1,O(dBat, a>G >1)P &0I x01O l);
HAL GPIO WritePin(GPIPN I 2,O(B dat, a>G >2P )&OIx0O 1);
HAL GPIO WritePin(GPIPN I 3,O(B dat, a>G >3)P&I Ox0O1);
HAL GPIO WritePin(GPIPN I4$O , (dB at, a>>G 4$)P&I Ox0O1);
HAL GPIO WritePin(GPIPN I 5,O(B dat, a>G >5P )&OIx0O 1);
HAL GPIO WritePin(GPIPN I6€O , (B dat, a>G >€)P&I Ox0O1);
HAL GPIO WritePin(GPIPN I 7,O(B dat, a>G >7)P&I OxO 01);
- +} includes
/* Private
while (1)
] 4 HAL GPIO WritePin(GP PINI8O,GBPI,O G PIP N I SEO T);
/* USER CODE END WHILE */
hientthi(ma_led[dem]);
HAL Delay(19);
/* USER CODE BEGIN 3 */
- }
/* USER CODE END 3 */
-}
void EXTIO IRQHandler (void) 0 */
USER CODE BEGIN EXTIO IRQn
]{
/*
if(HAL GPIO ReadPin(GPIOAPI,NG0P)I ==O0)
] {
while (HAL GPIO ReadPin(GPIOPAI, N G0)P==I0)O ¿,
dem++;
ì ifÍ{dqem>=19j dem=9;}
/* USER CODE END EXTIO IRQn 0 */
HAL GPIO EXTI IRQHandler(PGIPN I0O);
/* USER CODE BEGIN EXTIO IRQn 1 */
/* USER CODE END EXTIO IRQn 1 */
Pinout & Configuration Clock Configuration Project Manager
a[_ vị] l$ NVIC x Software Packs w Pinout icf Pinout view == System view
tea ~ Mode and Configuration f 4
OV OST Eee NYy š š Ỗ
System Core * Confguration L] Sort by inte |
` ———=— 8 šššẽšẽ v
Priority Premption Priority and Sub š -
ˆ Group O Sort by Priority 2
š 1
DMA Search © _ Show [available interrupts v:: Force DMA š
GPIO NVIC Interrupt Table eee 7
IWDG Non maskable interrupt 0 RE) sys_ums-swo1o
NVIC Hard fault interrupt 0 Qh
Memory management fault 0
RCC Prefetch fault, memory access fault 0
4 SYS S
0
Anal > Undefined instruction or illegal state
0
naog System serice call via SWI instruction
> Debug monitor 0 STM32F103C6Tx
Timers Pendable request for system service : 5
0 GPIO_exTio [ow LQFP48
€ tiựt > Time base: System tick timer 6Pio ni fey
0nnectIi Computing y PVD interrupt through EXTI line 16 H09 0
» | Flash global interupt H09 TT FEE
RCC global interrupt
Middleware ca. L1 0 tes
> EXTI lined interrupt 2 2 3 ễ
1 ao e
EXTI line1 interrupt 666
[)Enabled Preemption Priority |v] SubPaoiy| Œ Lo Q i ad
L WN1LE (1)
/* USER CODE END WHILE */
HAL GPIO WritePin(GPIOB,GPIO PIN 8,GPIO PIN SET);
HAL GPIO WritePin(GPIOB,GPIO PIN 9,GPIO PIN RESET);
hienthi (ma_led[dem/10]);
HAL Delay(10);
HAL GPIO WritePin(GPIOB,GPIO PIN &,GPIO PIN RESET);
HAL GPIO WritePin(GPIOB,GPIO PIN 9,GPIO PIN SET);
hienthl (ma_ 1ed [demê 1 0 ] ) ;
BAL Delay (10);
/* USER CODE BEGIN 3 */
FC}
/* USER CODE END 3 */
-} EXTIO_ IRQHandler (void) 0 */
USER CODE BEGIN EXTIO IRQn
void
] {
/*
if (HAL GPIO ReadPin(GPIOA,GPIO PIN 0)==0)
-] {
while (HAL GPIO ReadPin(GPIOA,GPIO PIN 0)==0);
dem++;
F }
/* USER CODE END EXTIO_IRQn 0 */
HAL GPIO EXTI IRQHandler(GPIO PIN 0);
QL) @ Xe 0, cán Saget
NVIC Mode and Configuration Ỉ
‘System Core x Priority Group C1 Sort by Premption Priority and Sub Priority] Sor by inte
ˆ
Search © Show Force DMA
DMA
GPIO. NVIC Interrupt Table BE SYS_sTMS-SWDIO
IWDG ‘Non maskable interrupt 0 GPO_Ouput
Hard fault interrupt 0 GPO_Ouput
mư ng GPO_Ouput
RCC ‘Memory management fault 0 GPIO_Ouput
Prefetch fault, memory access fault 0 (GPIO_Output
a SYS Undefined instruction or illegal state 0
56 ‘System service call via SWI instruction 0
Debug monitor 0
Analog Pendable request for system service 0
Timers > Time base: System tick timer 0
PVD interrupt through EXT! line 16 H0 SPO.Exn STM32F103C6Tx
Connnencetcitiity > | Flash global interrupt oo GPIO_Ex LQFP48
RCC global interrupt oo coo_oune FEB
computing 5 | EXT line0 interupt 1
EXT linet interrupt 2
Middleware 5
(Enabled Preemption Proity [v_ ] SubProiy [| @Q tI
#include "main.h"”
int deml=0;
int dem2=0;
Fichar ma_1ed[]={0xc0, 0x£9, 0xa4, 0xb0, 0x99, 0x92,
0x82, 0x£8, 0x80, 0x90};
void hienthil (unsigned int data)
Et HAL GPIO WritePin(GPIOB,GPIO_PIN_0,datas0x01) ;
HAL GPIO WritePin(GPIOB,GPIO_PIN_1, (data>>1) s0x01) ;
HAL GPIO WritePin(GPIOB,GPIO_PIN_2, (data>>2) s0x01) ;
HAL GPIO WritePin(GPIOB,GPIO PIN 3, (data>>3)s0x01);
HAL GPIO WritePin(GPIOB,GPIO PIN 4, (data>>4) 0x01);
HAL GPIO WritePin(GPIOB,GPIO PIN 5, (data>>5)s0x01l);
HAL GPIO_ WritePin(GPIOB,GPIO_PI6N, (data>>é)s0x01);
HAL GPIO WritePin(GPIOB,GPIO_PIN_7, (data>>7) s0x01) ;
at
void hienthi2(unsigned int data2)
Ait HAL GPIO WritePin(GPIOA,GPIO_PIN 3,data2s0x01);
HAL GPIO WritePin(GPIOA,GPIO_PI4N, (data2>>1) 0x01);
HAL GPIO WritePin(GPIOA,GPIO_PI5N, (data2>>2) 60x01);
HAL GPIO_ WritePin(GPIOA,GPIO_PI6N, (data2>>3) 60x01);
HAL GPIO WritePin(GPIOA,GPIO_PIN_7, (data2>>4) s0x01) ;
HAL GPIO_WritePin (GPIOA,GPIO_PIN_8, (data2>>5) s0x01) ;
HAL GPIO WritePin(GPIOA,GPIO_PIN_9, (data2>>6) s0x01) ;
BAL GPIO WritePin(GPIOA,GPIO PIN 10, (data2>>7) s0x01) ;
while (1)
{
/* USER CODE END WHILE */
HAL GPIO TogglePin(GPIOA,GPIO PIN 2);
HAL Delay(200);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
} EXTIO_IRQHandler (void)
void
{ RESET);
SET);
HAL GPIO WritePin(GPIOA,GPIO PIN 2,GPIO PIN
HAL GPIO WritePin(GPIOB,GPIO PIN 8,GPIO PIN
1f(HAL GPIO ReadPin(GPIOA,GPIO PIN _0)==0)
{
for (int deml=0;deml<=5;deml++)
{
hienthil (ma_led[deml]);
HAL Delay(500);
}
HAL GPIO EXTI IRQHandler(GPIO PIN 0);
}
}
void EXTI1 IRQHandler (void)
H HAL GPIO WritePin(GPIOA,GPIO PIN 2,GPIO PIN RESET);
SET);
] HAL GPIO WritePin(GPIOB,GPIO PIN 9,GPIO PIN
]
1f(HAL GPIO ReadPin(GPIOA,GPIO PIN 1)==0)
/*
HAL {
/*
for(int dem2=0;dem2<=8;dem2++)
{
hienthi2 (ma_led[dem2]);
HAL Delay(500);
}
}
USER CODE END EXTI1_IRQn 0 */
GPIO_ EXTI_IRQHandler(GPIO PIN 1);
USER CODE BEGIN EXTI1 IRQn 1 */
/* USER CODE END EXTI1 IRQn 1 */
Pinout & Configuration Clock Configuration Project Manager
1G) Pinout view
q——_ vị 8 V SoffWware Packs V Pinout
STM32F103C6Tx
NVIC Mode and Configuration wal
anu atid
me ‘System Core x Priority Group Ci Sort by Premption Priority and Sub Priority [1] Sort
- seach Stow Fe
DMA ‘Non maskable interrupt 0
Hard fault interrupt 0
RCC Memory management fault 0
v Svs Prefetch fault, memory access fault 0
wwoe
` ‘Undefined>‘System st _ 0
Analog Debug monitor
~ Pendable request for system service 0
Timers Time base: System tick timer
PVD interrupt through EXT! line 16 0
+ Flash global interrupt
RTC RCC global interrupt 0
“TIM1 break interrupt
TIM1 TIM1 update interrupt 0
› TIM1 trgger and commutation interrupts ooo
TIM2 TIM1 capture compare interrupt al
TIM3 Oo oo
Cennsstity
nnectivil ooo
H0
sở
1
ooo
ooo
11M Mode and Contiguration
Slave Mode [Disable v |
Trigger Source [Disable v |
Clock Source [internal Clock v |
Channel |Disable vị
Channel2 [Disable v |
Channel3 |Disable vị
—i tà ÍDmà- r. ]
Reset Configuration
Configure the below parameters - ettings
Q|Se tr+F, @ © @
x⁄ Counter Settings
Prescaler (PSC - 16 bits va... 79
Up
Counter Mode 9999
No Division
Counter Period (AutoReloa... 0
Internal Clock Division (CKD) Disable
Repetition Counter (RCR- ...
auto-reload preload
vr: BA eR AAL .
7/7" VUSOELNR CYVE DELULIN WHILK "/
HAL TIM Base Start IT(&htiml);
while (1)
1 ff /* USER CODE END WHILE */
_ HAL TIM _SET_PRESCALER (&htiml,79);
HAL Delay(5000);
__HAL TIM SET PRESCALER (&htiml, 399);
HAL Delay(5000);
/* USER CODE BEGIN 3 */
: USER CODE END 3 */ 0 */
PIN 2);
=o
void TIM1 UP_IRQHandler (void)
J {
/* USER CODE BEGIN TIUM P 1 IRQn
HAL GPIO TogglePin(GPIOA,GPIO
/* USER CODE END TIUM P 1 IRQn 0 */
1 */
HAL TIM IRQHandler (&htiml);
/* USER CODE BEGIN TIUM P I1 RQn
/* USER CODE END TIUM P 1 IRQn 1 */
}
3.2: sò Configuration
Bea * Ae @ Code generation
System Core > Search © Show |available interrupts v
DMA Ww NVIC Interrupt Table Enabled
GPIO
> Non maskable interrupt BOOUODOOOUOUSSESEEEEEESE
IWDG Hard fault interrupt
Memory management fault _ CC (©C CC CC CC cCcCccccc
RCC Prefetch fault, memory access fault
Undefined instruction or illegal state
v SYS System service call via SWI instruction
WWDG Debug monitor
Pendable request for system service
Analog Time base: System tick timer
PVD interrupt through EXTI line 16
Timers Flash global interrupt
. RCC global interrupt
RTC TIM1 break interrupt
TIM1 update interrupt
TIM1
v TIM2 TIM1 trigger and commutation interrupts
TIM1 capture compare interrupt
TIM3 TIM2 global interrupt
Connectivity
Slave Mode |Disable * |
v |
Trigger Source [Disable Vv |
Clock Source linternal Clock vị
Channel1 [Disable Vv |
Channel2 |Disable vị
vị
Channel3 |Disable
Channel4 [Disable ® DMA Settings
Confiquration |
Reset Configuration
® User Constants Semel daletS
Configure the ® Parameter Settings
below parameters -
Y Counter Settings
Prescaler (PSC - 16 bits va... 99
Counter Mode Up
Counter Period (AutoReloa... 9999
Internal Clock Division (CKD) No Division
auto-reload preload Disable
av ee ee ee wssk lk a
HAL TIM Base Start_IT(&htim2);
while ni
] t
/* USER CODE END WHILE */
_ HAL TIM_SET_PRE(S&hCtiAm2L,E9R 9);
HAL Delay (4909);
__HAL TIM SET PRESC (&A htiL m2E , 1R 99);
HAL Delay (4909);
/* USER CODE BEGIN 3 */
- +}
/* USER CODE END 3 */
=}
void TIM2 IRQHandler (void)
Jf
/* USER CODE BEGIN TIM2 IROQn 0 */
HAL GPIO TogglePin(GPIOA,PGINPI2)O;
/* USER CODE END TIM2 IRQn 0 */
HAL TIM_IRQHandler (é&htim2);
/* USER CODE BEGIN TIM2 IRQn 1 */
3 3:
¬ : we neve miuue au Cumyurauun i Sy rmuue view =~ oysten view
STM32F103C6Tx
System Core ˆ x Priority Group C1 Sort by Premption Priority and Sub Priority] Sort by LQFP48
DMA seach Shon a Face
NV Interupt Teble
us syS_JTMs-swo10
‘Non maskable interrupt 0
= Hard fault interrupt 0
‘Memory management fault 0
RCC refetch fault, memory access fault 0
a SYS
wwoe
Analog Undefined instruction or illegal state 0
Timers + 2 ‘System senice call via SWI instruction 0
Debug monitor 0
RTC ~ Pendable request for system service 0 6P10_Input
Time base: System tick timer 0 10
TIM1 PVD interrupt through EXTI line 16 oo
TIM2 Flash global interrupt Oo oo orio_ovtput EES
v TRMS RCC global interrupt n0
TIM global interrupt 1
Q 93 TIM3 Mode and Configuration
System Core 1 Slave Mode [Disable v |
a. Trigger Source [Disable v |
DMA Internal Clock
GPIO Channel1 [Disable v |
IWDG
NVIC Channel2 [Disable vị
RCC Channel3 |Disable v |
ASYS vị
WWDG Channel4 |Disable
Analog > Reset Configurat
Timers
v
RTC {Configure the below parameters :
AlSeees/c22] © © a
¥ Counter Settings
Prescaler (PSC - 16 bits va... 399
Counter Mode Up
Connectivity ? Counter Period (AutoReloa... 9999
Internal Clock Division (CKD) No Division
Oona ae ` auto-reload preload Disable
HAL | TIM Base Start _IT(ghtim3) ;
while (1)
] t
/* USER CODE END WHILE */
if(HAL GPIO ReadPin(GPIOAP, ING0P)I ==O0)
] { while (HAL GPIO ReadPin(GPIOPAI,N G9P )=I=0O);
__HAL TIM SET PRESC (é&A htL im3E , 3R 99);
}
{ if(HAL_GPIO ReadPin(GPIOA,GPIO PIN 1)==0)
whi1le (HAL GPIO ReadPin (GPIOA,GPIO PIN 1)==0);
__HAL TIM SET PRESCALER(é&htim3, 79);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
-}
void TIM3 IRQHandler (void)
lf /* USER CODE BEGIN TIM3 IRQn 0 */
HAL GPIO TogglePin(GPIOA,GPIO PIN 2);
/* USER CODE END TIM3_IRQn 0 */
HAL TIM IRQHandler (shtim3) ;
/* USER CODE BEGIN TIM3 IRQn 1 */
3 4:
° 1 Slave Mode [External Clock Mode 1 ° °1 Bo 1 1 T1 7,
ooo9osd !
System Core Trigger Source |ETR1 vị $aa ñn n nnn
Clock Source [Disable
. v | ra mị cBịallamịm œ
DMA Channel1 [Disable | a| a
CPO Channel2 [Disable v | :
IWDG Channel3 [Disable vị cI| sys 5rus-swpio
NVIC
Channel4 [Disable vị Tee} TIM1_ETR
RCC
v |
A SYS
Configuration
WWDG
> Reset Configuration
Analog
v @ NVIC Settings @ DMA Settings @ GPIO Settings
Timers
© Parameter Settings ® User Constants ——v
RTC
(Configure the below ¢ : Ñ:::
Vi
Q|Se tri+F, © @ 0 “1=
4 TiM2
4 TIM3 ¥ Counter Settings ae a
Connectivity Prescaler (PSC - 16 bits value) 0 š š šẽ
Counter Mode Up 656 6 6
> Counter Period (AutoReload Register- ... 10 2 2 2 2
Internal Clock Division (CKD) No Division
oo
Danatitinn Cnumtae (NOM O Bi c.¬l.v-\ n @® 7 š a 5 #1
#include "main.h"
int dem=0;
char ma_led[{ Ox] f9,=O{ xa0 4, x Oxc b0,00, x99,
0x92, 0x82, 0x£8, 0x80, 0x90};
void hienthi(unsigned char data)
H (t
HAL GPIO WritePin(GPPIINO0B,d, atG aéP &é0Ix0O l);
HAL GPIO WritePin(GPIP N I 1,O(dBat, a>G >1P )&0I x0O l);
HAL GPIO WritePin(GPIP N I 2,O(B dat, a>G >2P )&0Ix0O l);
HAL GPIO WritePin(GPIP N I 3,O(dBat, a>G >3)P&I Ox0O 1) ;
HAL GPIO WritePin(GPIPN I4,O(dB at, a>>G 4$)P&I OxO 01);
HAL GPIO WritePin(GPIP N I 5,O(dBat, a>G >5P )&0I x0O l);
HAL GPIO WritePin(GPIP N I 6,O(dBat, a>G >6)P &0I x01O l);
HAL GPIO WritePin(GPIP N I 7,O(dBat, a>G >7)P &0I x01O l);
/* USER CODE BEGLN WHLLE */
HAL TIM Base Start (é&htiml);
while (1)
/* USER CODE END WHILE */
dem= HAL TIM GET COUNTER (&htiml) ;
HAL GPIO WritePin(GPPINI8O,GBPI, O GPIP N I SEO T);
hie(mn a 1t edh [dei m] ) ;
/* USER CODE BEGIN 3 */
/* USER CODE END 3 */
Q * 3 TIM3 Mode and Configig)uration b iG; Pinout view == Syystem view
System Core * Slave Mode [External Clock Mode 1 v |
- Trigger Source [IIFP1 v |
DMA D1 Intemal Clock |
`GPIO Channel† [Disable vị JAE} 5Y5 JTM5-SWDIO
IWDG
NVIC Channel2 |Disable v
WWDG BiBieB|2:oo- vị
Gianna) Disable
Configuration
Analog > Reset Configuration
Timers v ® NVIC Ssttings ® DMA Settings ® GPIO Settings
@ User Constants
RTC ® Parameter Settings A
®
TIM1 Configure the below p : apt áo
4 TiM2 Q[Search (Cut ] ©
TÌM3
¥Y Counter Settings
"
Prescaler (PSC - 16 bits value) 0
Connectivity
Counter Mode Up
? Counter Period (AutoReload Register -... 10
Internal Clock Division (CKD) No Division
#include "main.h"
int dem=0;
|char ma_ 1ed[ ]={Oxc0, Ox£9, Oxa4„, Oxb0, 0x99,
0x92, 0x82, 0x£8, 0x80, 0x90};
void hienthi(unsigned char data)
| ft
HAL GPIO WritePin(GPPI INOOB,d,atGa&P9xI91O);
HAL GPIO WritePin(GPIPN I1,O(Bdat,a>G>1)P&I0x0O1) ;
HAL GPIO WritePin(GPIPN I2,O(Bdat,a>G>2)P&I0x0O1) ;
HAL GPIO WritePin(GPIPN I3,O(Bdat,a>G>3)P&I0x0O1) ;
HAL GPIO WritePin(GPIPN I4,O(Bdat,a>G>4)P6I0x0O1);
HAL GPIO WritePin(GPIPN I5,O(Bdat,a>G>5)P&I0x0O1) ;
HAL GPIO WritePin(GPIPN I6,O(dBat,a>G>6)P&I0x0O1) ;
HAL GPIO WritePin(GPIPN I7,O(dBat,a>G>7)P6I0x0O1);
fe _ - - - -
HAL TIM Base Start (&htim3) ;
while (1)
=] {
/* USER CODE END WHILE */
dem= HAI TIM GET COUNTERĂShtim3Ÿ;
HAL | GPIO | WritePin (GPIOB,GPIO PIN 8,GPIO PIN SET);
hienthi (ma _ 1ed[dem)] ) ;
/* USER CODE BEGIN 3 */
- }
/* USER CODE END 3 */
System Core v Slave Mode |Extemal Clock Mode 1 vị 2
- Trigger Source [laFP2 v | mi :Ñ: + Reset_State ——
DMA
LH Intemal Clock c Pa á=
chlo
Channelt [Disable vị CAN_RX >
IWDG I2C1_SCL
NVIC nas Channel2 [Disable x GPIO_Analogl 2|
GPIO_Input 2A13 SYS_JTMS-SWDIO
ame Channel| Disable
vị EVENTOUT
WWDG GPIO_EXTI8 ll
Configuration
Analog
› EES eeie Mnent STM32F103C6Tx
Timers LQFP48
x @ NVIC Settings
RTC
Q|se tri+E P © - oO 0 ‹Ũ fey lì
TIM1
Y Counter Settings eS
4 TIM2
Prescaler (PSC - 16 bits value) 0 x5 >5 85 85 25 25 3
Connectivity
Counter Mode Up
> Counter Period (AutoReload Register - ... 999 a@aacaa
Intarnal Clack Nivician (CKD) Na Nivician
#include "main.h"
int dem=0;
xỉ char ma_ 1ed[]={Oxc0, Ox£9, Oxa4, Oxb0, 0x99,
0x92, 0x82, 0x£8, 0x80, 0x90};
void hienthi(unsigned char data)
= {
HAL GPIO WritePin(GPPIINO0B,d,atG a&P é0I x0O l);
HAL GPIO WritePin(GPIPN I1,O(dBat,a>G>1)P6I0x0O1);
HAL GPIO WritePin(GPIPN I2,O(Bdat,a>G>2)P&I0x0O1) ;
HAL GPIO WritePin(GPIPN I3,O(Bdat,a>G>3)P&I0%0O1) ;
HAL GPIO WritePin(GPIPN I4,O(dBat,a>G>4)P&I0x0O1) ;
HAL GPIO WritePin(GPIOB,GPIO PIN 5, (data>>5) 60x01);
HAL GPIO WritePin(GPIOB,GPIO PIN 6, (data>>6)&0x0l);
HAL GPIO WritePin(GPIOB,GPIO PIN 7, (data>>7)&0x01l);
- }
/* Private includes
fe TTCUT CANT BEC AT Ta=1ôsa-i=xơa # /
HAL TIM Base Start (&htim3);
while (1)
) {
dem= HAL TIM GET COUNTER (éhtim3);
HAL GPIO WritePin(GPIOB,GPIO PIN 8,GPIO PIN SET);
HAL GPIO WritePin(GPIOB,GPIO PIN $,GPIO PIN RESET);
HAL GPIO WritePin(GPIPN I10O,GBPIO,PGINPREISEOT);
hienthi(ma_led[dem/100]);
HAL Delay (5);
HAL GPIO WritePin(GPIPNI8,OGPBIO,PGINPREISEOT);
HAL GPIO WritePin(GPPINIO$,GBPI,O GPIPN ISEOT);
HAL GPIO WritePin(GPIPN I10O,GBPIO,PGINPREISEOT);
hienthi(ma_led[dem%100/10]);
HAL Delay(5);
HAL GPIO WritePin(GPPINI_8O,GBPIO,PGINPREISEOT);
HAL GPIO WritePin(GPIPNI_9O,GBPIO,PGINPREISEOT);
HAL GPIO WritePin(GPPINI1O0,BGP,IOGPIPN ISEOT);
hienthi (ma_led[dem%100%10]);
HAL Delay (5);
/* USER CODE END 3 */
3.7: ° ‡@ TIM1 Mode and Configuration ` iF Pinout view == System view
System Core * | ao oaaa
- v |
s Slave Mode [Disable
DMA Vv |
Trigger Source [Disable
chlo vị
Clock Source [internal Clock TSEM) 6SYS_JTMS-S\
IWDG vị
Channel [PWM Generation CH1 TIM1_CH2
NVIC vị TIM1_CH1
Channel2 [PWM Generation CH2
Á RCC vị
Channel3 [Disable
4 SYS @ GPIO Settings
Channel4 |Disable
WWDG ® User Constants
Configuration
Analog 0
> Reset Configuration STM32F103C6Tx
Timers I LQFP48
v @ NVIC Settings @ DMA Settings
RTC (SET Cima
VE Configure the below p :
TIM2 Q tri+F, © oO GPIO_Out, put [gee
TIM3 x⁄ Counter Settings GPIO_ Outp pui
Prescaler (PSC - 16 bits value) 7
Connectivity Counter Mode Up GPIO_ Outpput
> Counter Period (AutoReload Register - ... 999
Internal Clack Nivisian (CKD) No Nivisian
/* USER CODE BEGIN WHLLE */
HAL TIM PWM Start (é&htiml,TIM_CHANNEL 1);
while (1)
] t
/* USER CODE END WHILE */
__HAL TIM SET COMPARE (&htiml,TIM CHANNEL 1,200);
HAL Delay(1909);
_ HAL TIM _SET_ COMPARE (&htiml,TIM CHANNEL 1,409);
— HAL _| Delay (1000);
__ HAL TIM SET COMPARE (&htiml,TIM CHANNEL 1,800);
HAL Delay (1000);
/* USER CODE BEGIN 3 *4
- +}
/* USER CODE END 3 */
} = TIM OCMODE PWM1;
sConfigOC.OCMode
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM OCPOLARILTOWYN; //sua tu HIGH thanh LOW trong mo phong
sConfigOC.OCNPolaritvy = TIM OCNPOLARITY HIGH; TIM_CHANNE1L) != HAL OK)
sConfigOC.OCFastMode = TIM OCFAST DI5ABLE;
sConfigOC.OCIdleState = TIM OCIDLESTATE RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE RESET;
if (HAL TIM PWM ConfigChannel(é&htiml, &sConfigOC,
{
Error Handler () ;
`
3 8: ° TIM1 Mode and Configuration Pinout view == System view
a Slave Mode [Disable v | 5 5 sỊ 1 s St 2 5,
System Core Trigger Source [Disable v | a a aaa a 2
.
DMA Clock Source [internal Clock vị SYS_JTMS-SWDIO
Sa TIMI _CH2
IWDG Channel1 [PWM Generation CH1 vị TMI_CHI
NVIC
4 RCC Channel2 [PWM Generation CH2 v |
A SYS
WWDG Channel3 [Disable v |
Analog Channel4 [Disable * |
Timers =Configuration"
RTC > Reset Configuration ñ STM32F103C6Tx
Vv @ NVIC no Settings ® DMA = Szttings =
Km - — LQFP48
4 TIM2 cc;
7% #š
TIM3 ® Parameter Settings = ne
0 ees
Connectivity (Configure the below : I 88 8
Q tr+F, © @ 5 šš
\ Counter Settings
Prescaler (PSC - 16 bits value) 7
Counter Mode Up
Counter Period (AutoReload Register - ... 999
› InternalClock Division (CKD) No Division
HAL TIM PWM 5Start(&htiml,TIM CHANNEL 2); 2,dem);
uint32 t dem=0;
while (1)
{
/* USER CODE END WHILE */
_ HALTIM SET COMPARE (&htiml,TIM CHANNEL
i.
while (HAL GPIO ReadPin(GPIOA,GPIO PIN 0)==0);
dem =dem+100;
af (dem>=500) dem=500;
if(HAL_GPIO ReadPin(GPIOA,GPIO PIN 1)==0)
while (HAL GPIO ReadPin(GPIOPAI, N G1)P=I =0O);
dem = dem-1990;
if (dem<=0) dem=0;
}
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
Error Handler();
} = TIM OCMODE PWM1;
sConfigOC.OCMode
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITLYOW_; //Sua HIGH thanh LOW
sConfigOC.OCNPolarity = TIM_OCNPOLARITY HIGH;
sConfigOC.OCFastMode = TIM OCFAST_ DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE RESET;
if (HAL TIM PWM_ConfigChannel(&htiml, &sConfigOC, TIM CHANNEL1) != HAL OK)
1 {
Error Handler();
}
if (HAL_TIM_PWM_ConfigChannel(&htiml, &sConfigOC, TIM CHANNEL2) != HAL OK)
] {
Error Handler();
}
sBreakDeadTimeConfig.OffStateRunMode = TIM _OSSR_DISABLE;
sBreakDeadTimeConfig.OffStateIDLEMode = TIM _OSSI_DISABLE;
sBreakDeadTimeConfig.LockLevel = TIM _LOCKLEVEL OFF;
sBreakDeadTimeConfig.DeadTime = 0;
=_Mo- - LM . eS ee ee ee OTE NPAT NnTelAaAnrST.
3.9: we Par wwe ane Gorman > SE me view ¬......
System Core Slave Mode [Di- sable vị 6.6 66666 E
“ ° ooo
. v | se
DMA v |
=
GPIO v |
Trigger Source [Disable
IWDG v |
NVIC Clock Source [internal Clock v |
4 RCC
A SYS Channel [PWM Generation CH1 v | SYS_.JTMS-SWDI0
WWDG Channel2 [PWM Generation CH2 onstants TIMI_£H4
Channel3 [PWM Generation CH3
Analog @ 6 TIMI_CH3
Channel4 [PWM Generation CH4 TIMI_CH2
Timers
Configuration
RTC
> Reset Configuration : STM32F103C6Tx
4 TIM2 v @ NVIC = Settings @ DMA _ Settings LQFP48
TIM3
SE ecm i
Configure the below ¢ :
a|Ssacn (CĐ ] © @ a8 8
Y Counter Settings
836
Prescaler (PSC - 16 bits value) T = = =
Counter Mode Up
Counter Perind (AutaRelnad Renister- 999
/* Infinite loop */ 1,100);
2,300);
/* USER CODE BEGIN WHILE */ 3,700);
4,900);
HAL TIM PWM Start (shtiml,TIM CHANNEL 1);
HAL TIM PWM Start (shtiml,TIM CHANNEL 2);
HAL TIM PWM Start (shtiml,TIM CHANNEL 3);
HAL TIM PWM Start (shtiml,TIM CHANNEL 4);
while (1)
{
/* USER CODE END WHILE */
__TIH M SEA T CL OMPARE (shtiml,TIM CHANNEL
__HAL TIM SET COMPARE (shtiml,TIM CHANNEL
__HAL TIM SET COMPARE (shtiml,TIM CHANNEL
__TIH M SEA T CL OMPARE (shtiml,TIM CHANNEL
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
ƒ mm mm. —.=———-—=.—.`"Aa‹
}
sConfigOC.OCMode = TIM OCMODE PWM1;
sConfigOC.Pulse = 9;
sConfigOC.OCPolarity = TIM_OCPOLARILTOWY; //Chuyen HIGH thanh Low
sConfigOC.OCNPolarity = TIM OCNPOLARITY HIGH;
sConfigOC.OCFastMode = TIM OCFAST_ DISABLE;
sConfigOC.OCIdleState = TIM OCIDLESTATE RESET;
sConfigOC.OCNIdleState = TIM _OCNIDLESTATE RESET;
if (HAL_TIM PWM ConfigChannel(éhtiml, &sConfigOC, TIM CHANNEL1) != HAL OK)
{ 7 7 as
_
4 1:
Ql & ADC1 Mode and Configuration 4 0; Pinout view =: System view
System Core v LIN0 #ẽ 1 ¡ , 5 9,
IN1
-
OO IN2
DMA
GPIO - IN3
IWDG L1IN4
NVIC
RCC
4 SYS Configuration
WWDG Reset Configuration
Anal LU @ NVIC Settings ® DMA Settings @ GPIO Settings
aisg © Parameter Settings @ User Constants
LOroAlDCT + afeancmn | © © (Configure the below parameters : apciint [Js :
Timers > - Independent mode
Right alignment
v ADCs_Common_Settings
Mode
v ADC_Settings
Data Alignment
Connectivity > Scan Conversion Mode Disabled
Continuous Conversion Mode Enabled
i > ena Discontinuous Conversion ... Disabledaae ^^ ra ^ n~ rn ^
Computing *>+>*+x~x¬*# a te ee Oe
ar Pr are rrr 1YÝ313%*VẰ*%**v ee ee
¬5w-r
Continuous Conversion Mode Enabled
External Trigger Conversion... Regular Conversion launched by softw...
`» Rank 1
Channel Channel1
Sampling Time
#include "main.h" data)
uint32_t AD;
char hienthi(uint32_t
H f{ HAL GPIO WritePin(GPPIINO0B,d,atGasP0xI01O);
HAL GPIO WritePin(GPIPN I1,O(dBat,a>G >1P )&0Ix0O1);
HAL GPIO WritePin(GPIPN I2,O(dBat,a>G >2)P8I 0x0O1);
HAL GPIO WritePin(GPIPN I3,O(B dat,a>G>3P )&0Ix0O1);
HAL GPIO WritePin(GPIPN I4,O(B dat,a>G>4P )&0Ix0O1);
HAL GPIO WritePin(GPIPN I5,O(dBat, a>>G5S)P&I 0x0O1);
HAL GPIO WritePin(GPIPN I6,O(dBat,a>G >6)P&I 0x0O1);
HAL GPIO WritePin(GPIPN I7,O(B dat,a>G>7P )&0Ix0O1);
HAL GPIO WritePin(GPIPN I8,O(dBat,a>G >8)P&I 0x0O1);
HAL GPIO WritePin(GPIPN I39,O(B dat,a>G>9P )&0Ix0O1);
HAL GPIO WritePin(G PINP1I 0,O(dBat, a>>G10P ) I 0xO 01);
HAL GPIO WritePin(G PINP1I1,O(dBat, a>>G11P )&I 0x0O1);
"ở Mont one ee i a ~
fe
HAL ADC Start (&shadcl);
HAL ADC PollForConversion(&had10c0i0),;
while (1)
{
/* USER CODE END WHILE */
AD=HAL ADC GetValue (&hadci);
hienthi (AD);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
a[ vị io} Software Packs w Pinout GE Pinout view == System view
v ADC1 Mode and Configuration j
System Core OO INo
^
DMA
GPIO
IWDG
NVIC
RCC
A SYS
WWDG
Analog » "arameter Setting Cerne ne STM32F103C6Tx
+ LQFP48
4 ADC2 Configure the below p :
Q|Search (Ctrit)_ | @ @
x ADCs_Common_ Settings
Mode Independent mode
Timers › v ADC_Settings
Connectivity
Data Alignment Right alignment
> Scan Conversion Mode Disabled
Continuous Conversion Mode