From a745f8197468cc4a8b6b4206bce6e37e82942ffc Mon Sep 17 00:00:00 2001 From: Firmin Rousseau Date: Wed, 19 Apr 2023 10:54:54 +0200 Subject: [PATCH] Version finale PWM --- soft/PjtKEIL_StepSon/Src/GestionSon.s | 40 ++++++++++++--------------- soft/PjtKEIL_StepSon/Src/principal.c | 1 - soft/PjtKEIL_StepSon/StepSon.uvoptx | 13 ++++++--- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/soft/PjtKEIL_StepSon/Src/GestionSon.s b/soft/PjtKEIL_StepSon/Src/GestionSon.s index 283f96d..d71ead0 100644 --- a/soft/PjtKEIL_StepSon/Src/GestionSon.s +++ b/soft/PjtKEIL_StepSon/Src/GestionSon.s @@ -18,7 +18,7 @@ -SortieSon dcw 0 +SortieSon dcd 0 Index dcw 0 export SortieSon @@ -39,38 +39,32 @@ timer_callback_son proc push {lr,r4} - ldr r4,=Index - ldr r2,[r4] - mov r0, r2 - ldr r1,=LongueurSon - ldr r2,[r1] - mov r1, r2 - cmp r0, r1 + ldr r4, =Index ; r4 = &Index + ldr r0, [r4] ; r0 = *r4 + ldr r1, =LongueurSon + ldr r2, [r1] + cmp r0, r2 beq fin - ldr r3,=SortieSon + ldr r2,=Son - ldrsh r1,[r2,r0, lsl #1] - add r1,#32768 ; (1<<16) + ldrsh r1, [r2,r0, lsl #1] + add r1, #32768 ; (1<<16) mov r2, #720 - mul r1,r2 - asr r1,#16 + mul r1, r2 + asr r1, #16 - - - mov r4, r0 - mov r0, r1 - bl PWM_Set_Value_TIM3_Ch3 - ;str r1, [r3] ;Mise à jour sortie son pas PWM - str r0, [r3] ;Mise à jour sortie son PWM - mov r0, r4 - - mov r3, r0 + mov r3, r0 add r3, #1 str r3, [r4] + ldr r3,=SortieSon + mov r0, r1 + bl PWM_Set_Value_TIM3_Ch3 + + str r0, [r3] ;Mise à jour sortie son pas PWM fin pop {lr,r4} diff --git a/soft/PjtKEIL_StepSon/Src/principal.c b/soft/PjtKEIL_StepSon/Src/principal.c index 02cdac4..b817344 100644 --- a/soft/PjtKEIL_StepSon/Src/principal.c +++ b/soft/PjtKEIL_StepSon/Src/principal.c @@ -15,7 +15,6 @@ CLOCK_Configure(); // configuration du Timer 4 en débordement 91 microsecondes Timer_1234_Init_ff( TIM4, 91*72); - Timer_1234_Init_ff( TIM3, 91*72); int Periode_ticks = 720; diff --git a/soft/PjtKEIL_StepSon/StepSon.uvoptx b/soft/PjtKEIL_StepSon/StepSon.uvoptx index 486c71c..53cdb08 100644 --- a/soft/PjtKEIL_StepSon/StepSon.uvoptx +++ b/soft/PjtKEIL_StepSon/StepSon.uvoptx @@ -75,7 +75,7 @@ 1 0 - 0 + 1 18 @@ -165,7 +165,7 @@ 1 265 - &SortieSon + r3 0 @@ -215,7 +215,12 @@ 0 (SortieSon & 0xFFFF) >> 0 - 008000000000000000000000000000000000894000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000F03F1400000000000000000000000000000000000000AE080008 + 008000000000000000000000000000000000894000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000E03F1500000000000000000000000000000000000000AE080008 + + + 1 + (PORTB & 0x00000001) + 00800000000000000000000000000000E0FFEF400000000000000000000000000000000028504F52544220262030783030303030303031290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F1500000000000000000000000000000000000000540A0008 @@ -282,7 +287,7 @@ 1 0 - 1 + 0 18