diff --git a/git/PjtKEIL_StepDeb_1/Src/Delay.s b/git/PjtKEIL_StepDeb_1/Src/Delay.s
index 2f16361..3ac3369 100644
--- a/git/PjtKEIL_StepDeb_1/Src/Delay.s
+++ b/git/PjtKEIL_StepDeb_1/Src/Delay.s
@@ -74,19 +74,6 @@ BoucleTempo
-int tab Son
-int index
-short sortieSon
-int callBack {
- distance = abs(min(index)) + abs(max(index))
- miseAEchelle = 761/distance
- if(index < LongueurSon) {
- sortieSon = (Son[index] - min(index)))*miseAEchelle
-
- index += 1;
- }
-
-}
\ No newline at end of file
diff --git a/git/PjtKEIL_StepSon/Src/GestionSon.s b/git/PjtKEIL_StepSon/Src/GestionSon.s
index 22e60d1..6cec8b8 100644
--- a/git/PjtKEIL_StepSon/Src/GestionSon.s
+++ b/git/PjtKEIL_StepSon/Src/GestionSon.s
@@ -1,40 +1,101 @@
PRESERVE8
THUMB
-
+
+ include DriverJeuLaser.inc
; ====================== zone de réservation de données, ======================================
;Section RAM (read only) :
area mesdata,data,readonly
+
+
;Section RAM (read write):
area maram,data,readwrite
-
+
+SortieSon dcw 0
+Index dcd 0
+Res dcw 719
+
export CallbackSon
extern Son
+ extern LongueurSon
+ EXPORT SortieSon
+ EXPORT Index
+
+
; ===============================================================================================
-SortieSon dcw 0
-Index dcd 0
;Section ROM code (read only) :
area moncode,code,readonly
; écrire le code ici
+
+;int tab Son
+;int index
+;short sortieSon
+
+;int callBack
+; int decalage = 1<<15;
+; double echelle = 719/(1<<16) //decalage*2
+; if(index < LongueurSon) {
+; sortieSon = (Son[index] +decalage)*echelle
+;
+; index += 1;
+; }
+
+; return sortieSon
+
+;
+
+
;CallbackSon mov r0,=Son
CallbackSon proc
+ ; On récupère l'adresse du tableau Son et de l'index
+ push {lr}
ldr r0,=Son
ldr r2,=Index
ldr r3,[r2]
- ldr r1, [r0,r3] ; On li la valeur dans le tableau à la case Index
+
+; if(index < LongueurSon)
+ push {r0}
+ ldr r0,=LongueurSon
+ cmp r0, r2
+ bge exit
+ pop{r0}
+
+; sortieSon = (Son[index] +decalage)*echelle
+ ; On lit Son[index]
+ ldrsh r1, [r0,r3]
ldr r0,=SortieSon
- str r1,[r0] ; On écrit cette valeur dans SortieSon
- add r3,r3,2
+
+ ;mise à echelle
+ push {r0,r2,r3}
+ ; Variable décalage
+ mov r3,#1
+ lsl r0,r3,#15
+ add r1,r1,r0
+ ;Calcul mise à l'échelle (719/2^16)
+ ldr r2,=Res
+ ldrh r2,[r2]
+ mul r1,r1,r2
+ lsr r1,r1,#16
+ pop {r0,r2,r3}
+ ;fin mise à échelle
+
+ strh r1,[r0] ; On écrit cette valeur dans SortieSon
+ mov r0,r1
+ bl PWM_Set_Value_TIM3_Ch3
+; index += 1;
+ add r3,r3,#2
str r3,[r2] ; On ajoute 2 à l'index
- bx lr
+
+
+exit pop {pc}
endp
diff --git a/git/PjtKEIL_StepSon/Src/bruitverre.asm b/git/PjtKEIL_StepSon/Src/bruitverre.asm
index deb5b8e..2c64a20 100644
--- a/git/PjtKEIL_StepSon/Src/bruitverre.asm
+++ b/git/PjtKEIL_StepSon/Src/bruitverre.asm
@@ -8,7 +8,7 @@
export PeriodeSonMicroSec
export Son
- DCD 5512
+LongueurSon DCD 5512
PeriodeSonMicroSec DCD 91
Son
DCW -6911
diff --git a/git/PjtKEIL_StepSon/Src/principal.c b/git/PjtKEIL_StepSon/Src/principal.c
index b27dadb..440857e 100644
--- a/git/PjtKEIL_StepSon/Src/principal.c
+++ b/git/PjtKEIL_StepSon/Src/principal.c
@@ -14,11 +14,13 @@ int main(void)
// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
CLOCK_Configure();
-Timer_1234_Init_ff( TIM4, 100000*91 );
+Timer_1234_Init_ff( TIM4, 6552 );
+PWM_Init_ff(TIM3,3,720);
GPIO_Configure(GPIOB, 1, OUTPUT, OUTPUT_PPULL);
+GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
-
+PWM_Set_Value_TIM3_Ch3( 720);
Active_IT_Debordement_Timer( TIM4, 2, CallbackSon );
diff --git a/git/PjtKEIL_StepSon/StepSon.uvprojx b/git/PjtKEIL_StepSon/StepSon.uvprojx
index c69c3c5..8b6e91a 100644
--- a/git/PjtKEIL_StepSon/StepSon.uvprojx
+++ b/git/PjtKEIL_StepSon/StepSon.uvprojx
@@ -422,6 +422,44 @@
GestionSon.s
2
.\Src\GestionSon.s
+
+
+ 2
+ 0
+ 0
+ 0
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 11
+
+
+ 1
+
+
+
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+
+
+
+
+ .\Driver
+
+
+
+
diff --git a/git/PjtKEIL_StepSon/spice/PWM.asc b/git/PjtKEIL_StepSon/spice/PWM.asc
new file mode 100644
index 0000000..5cbcda5
--- /dev/null
+++ b/git/PjtKEIL_StepSon/spice/PWM.asc
@@ -0,0 +1,68 @@
+Version 4
+SHEET 1 1084 820
+WIRE 208 16 96 16
+WIRE 784 16 208 16
+WIRE 944 16 864 16
+WIRE 1008 16 944 16
+WIRE -368 80 -512 80
+WIRE 96 96 96 16
+WIRE 944 144 944 16
+WIRE -512 176 -512 80
+WIRE 96 224 96 176
+WIRE 944 256 944 208
+WIRE -512 304 -512 256
+WIRE 96 384 -48 384
+WIRE -48 480 -48 384
+WIRE -48 608 -48 560
+FLAG -512 304 0
+FLAG -368 80 Compteur
+FLAG 944 256 0
+FLAG 1008 16 Filtre
+FLAG -48 608 0
+FLAG 96 384 CompValue
+FLAG 208 16 PWM
+FLAG 96 224 0
+SYMBOL voltage -512 160 R0
+WINDOW 3 -372 78 Left 2
+WINDOW 123 0 0 Left 0
+WINDOW 39 0 0 Left 0
+SYMATTR Value PULSE(0 3.3 0 5u 0 0 5u)
+SYMATTR InstName V1
+SYMBOL cap 928 144 R0
+SYMATTR InstName C1
+SYMATTR Value 10n
+SYMBOL res 880 0 R90
+WINDOW 0 0 56 VBottom 2
+WINDOW 3 32 56 VTop 2
+SYMATTR InstName R1
+SYMATTR Value 3.9k
+SYMBOL voltage -48 464 R0
+WINDOW 3 49 61 Left 2
+WINDOW 123 0 0 Left 0
+WINDOW 39 0 0 Left 0
+SYMATTR Value SINE(1.65 1 2k)
+SYMATTR InstName V2
+SYMBOL bv 96 80 R0
+SYMATTR InstName B1
+SYMATTR Value V=if(V(CompValue)>V(Compteur),3.3,0)
+TEXT 272 256 Left 2 !;ac dec 100 1 10meg
+TEXT 272 296 Left 2 !.tran 0 1.5m 0 0.01u
+TEXT -880 40 Left 2 ;Compteur de l'unité Timer
+TEXT -96 -24 Left 2 ;Partie PWM de l'unité Timer
+TEXT -904 -56 Left 4 ;TIMER3
+TEXT 688 80 Left 4 ;PB0
+TEXT 480 0 Left 2 ;Chanel 3
+TEXT 384 -168 Left 5 ;STM32F103
+LINE Normal 688 48 752 -16
+LINE Normal 688 -16 688 48
+LINE Normal 752 48 688 -16
+LINE Normal 752 48 752 48
+LINE Normal 720 -208 720 -16
+LINE Normal 256 -208 720 -208
+LINE Normal 720 784 720 48
+LINE Normal 720 784 720 784
+LINE Normal 720 816 720 784
+RECTANGLE Normal -192 352 -912 16 2
+RECTANGLE Normal 592 656 -128 -48 2
+RECTANGLE Normal 640 736 -976 -96
+RECTANGLE Normal 752 48 688 -16