Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LaboMCU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fabian.troller
LaboMCU
Commits
4110b12b
Commit
4110b12b
authored
4 years ago
by
Troller Fabian (HES)
Browse files
Options
Downloads
Patches
Plain Diff
Add new pwm features
parent
1a5086bf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
labo1.cpp
+61
-5
61 additions, 5 deletions
labo1.cpp
with
61 additions
and
5 deletions
labo1.cpp
+
61
−
5
View file @
4110b12b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include
"mbed.h"
#include
"mbed.h"
DigitalOut
LED_0
(
P
0
_0
);
DigitalOut
LED_0
(
P
2
_0
);
DigitalOut
LED_1
(
P0_1
);
DigitalOut
LED_1
(
P0_1
);
DigitalOut
LED_2
(
P0_2
);
DigitalOut
LED_2
(
P0_2
);
DigitalOut
LED_3
(
P0_3
);
DigitalOut
LED_3
(
P0_3
);
...
@@ -161,15 +161,70 @@ void timer_mesure()
...
@@ -161,15 +161,70 @@ void timer_mesure()
}
}
}
}
void
MyNewPCB
()
void
PWM_de_base
()
{
while
(
1
)
{
MonBus
=
1
;
wait_us
(
200
);
MonBus
=
3
;
}
}
void
PWM_dormant
()
{
uint16_t
pwmLed
;
uint16_t
cpt10ms
=
0
;
uint8_t
cptPwm
=
0
;
while
(
1
)
{
if
(
cptPwm
==
0
)
{
cpt10ms
++
;
if
(
cpt10ms
<
100
)
{
pwmLed
=
cpt10ms
*
256
/
100
;
}
else
if
(
cpt10ms
<
200
)
{
pwmLed
=
256
-
((
cpt10ms
-
100
)
*
256
/
100
);
}
else
{
pwmLed
=
0
;
}
if
(
cpt10ms
==
400
)
{
cpt10ms
=
0
;
}
}
if
((
cptPwm
==
0
)
&&
(
pwmLed
>
0
))
{
LED_0
=
1
;
}
if
(
cptPwm
==
pwmLed
)
{
LED_0
=
0
;
}
cptPwm
++
;
wait_us
(
39
);
}
}
void
tri_phase
()
{
{
LED_1
=
1
;
}
}
int
main
(
void
)
{
int
main
(
void
)
{
// Choisir le numero de l'exercice en changeant la valeur de 'exo'.
// Choisir le numero de l'exercice en changeant la valeur de 'exo'.
uint8_t
exo
=
9
;
uint8_t
exo
=
10
;
while
(
1
)
{
while
(
1
)
{
// Choix de l'exercice. Rajouter des exercices si besoin, en gardant la même
// Choix de l'exercice. Rajouter des exercices si besoin, en gardant la même
...
@@ -183,7 +238,8 @@ int main(void) {
...
@@ -183,7 +238,8 @@ int main(void) {
case
6
:
exercice_sequence
();
break
;
case
6
:
exercice_sequence
();
break
;
case
7
:
compter_rebond
();
break
;
case
7
:
compter_rebond
();
break
;
case
8
:
timer_mesure
();
break
;
case
8
:
timer_mesure
();
break
;
case
9
:
MyNewPCB
();
break
;
case
9
:
PWM_de_base
();
break
;
case
10
:
PWM_dormant
();
break
;
default:
printf
(
"Bad exercice number !
\n
"
);
default:
printf
(
"Bad exercice number !
\n
"
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment