From 0fc477a68d52efe031d35439c8ccd32eec97d109 Mon Sep 17 00:00:00 2001 From: Bensebaa Date: Wed, 12 Apr 2023 15:25:52 +0200 Subject: [PATCH] Pwm wip --- soft/PjtKEIL_StepSon/Src/GestionSon.s | 48 ++++++++++++++++++++++----- soft/PjtKEIL_StepSon/Src/principal.c | 5 ++- soft/PjtKEIL_StepSon/StepSon.uvoptx | 25 ++++++++++---- soft/PjtKEIL_StepSon/StepSon.uvprojx | 2 +- 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/soft/PjtKEIL_StepSon/Src/GestionSon.s b/soft/PjtKEIL_StepSon/Src/GestionSon.s index d09db9c..e3074a2 100644 --- a/soft/PjtKEIL_StepSon/Src/GestionSon.s +++ b/soft/PjtKEIL_StepSon/Src/GestionSon.s @@ -2,13 +2,13 @@ THUMB export CallbackSon - + include DriverJeuLaser.inc ; ====================== zone de réservation de données, ====================================== ;Section RAM (read only) : area mesdata,data,readonly - + IMPORT LongueurSon IMPORT Son ;Section RAM (read write): @@ -30,18 +30,48 @@ SortieSon dcw 0; CallbackSon proc - ldr r0,=index - ldr r1,[r0]; valeur index - add r1,#1; - str r1,[r0] ;mettre a jour index + push{lr} + + ldr r0,=LongueurSon + ldr r1,=index ; @ index + ldr r2,[r1] + ldr r3,[r0] + cmp r2,r3 + beq ret ldr r0, =Son ; recuperer @ son - ldrh r1, [r0];valeur son + movs r2,r2,lsl #1 + add r0,r2 + ldrsh r2,[r0];valeur son + + ldr r0, =SortieSon ;@ sortie son - ldr r2, =SortieSon ;@ sortie son - str r1,[r2]; mettre a jour SortieSon + ;mise a l'echelle; + add r2,#32768 + mov r3,#719 + mul r2,r3 + mov r2,r2,asr #16 + ; mettre a jour SortieSon + str r2,[r0] + + + push{r1} + mov r0,r2 + bl PWM_Set_Value_TIM3_Ch3 + pop{r1} + + ;incrementer index + ldr r0,[r1]; valeur index + add r0,#1; + str r0,[r1] ;mettre a jour index + + + + +ret + pop{pc} bx lr diff --git a/soft/PjtKEIL_StepSon/Src/principal.c b/soft/PjtKEIL_StepSon/Src/principal.c index 92e014d..9b24aa7 100644 --- a/soft/PjtKEIL_StepSon/Src/principal.c +++ b/soft/PjtKEIL_StepSon/Src/principal.c @@ -1,7 +1,6 @@ #include "DriverJeuLaser.h" -#include extern void CallbackSon(void); @@ -20,8 +19,8 @@ Timer_1234_Init_ff(TIM4,tick); Active_IT_Debordement_Timer( TIM4, 2, CallbackSon ); - - +PWM_Init_ff( TIM3, 3, 720); +GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL); //============================================================================ diff --git a/soft/PjtKEIL_StepSon/StepSon.uvoptx b/soft/PjtKEIL_StepSon/StepSon.uvoptx index 7bcba52..01dbf4d 100644 --- a/soft/PjtKEIL_StepSon/StepSon.uvoptx +++ b/soft/PjtKEIL_StepSon/StepSon.uvoptx @@ -157,9 +157,9 @@ 0 0 - 33 + 57 1 -
134220060
+
134220678
0 0 0 @@ -168,7 +168,7 @@ 1 .\Src\GestionSon.s - \\StepSon\Src/GestionSon.s\33 + \\StepSon\Src/GestionSon.s\57
@@ -178,6 +178,14 @@ SortieSon + + + 1 + 265 + R0 + 0 + + 0 @@ -223,8 +231,13 @@ 0 - ((portb & 0x00000002) >> 1 & 0x2) >> 1 - FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274622026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F100000000000000000000000000000000000000096020008 + `SortieSon + FF0000000000000000000000000000000050824000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0C00000000000000000000000000000000000000E8080008 + + + 1 + ((portb & 0x00000001) & 0x1) >> 0 + 00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F72746220262030783030303030303031290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0C00000000000000000000000000000000000000080B0008 @@ -712,7 +725,7 @@ 4 5 2 - 0 + 1 0 0 .\Src\GestionSon.s diff --git a/soft/PjtKEIL_StepSon/StepSon.uvprojx b/soft/PjtKEIL_StepSon/StepSon.uvprojx index c69c3c5..b34880e 100644 --- a/soft/PjtKEIL_StepSon/StepSon.uvprojx +++ b/soft/PjtKEIL_StepSon/StepSon.uvprojx @@ -357,7 +357,7 @@ - + .\Driver