From 0eb960b0e7fa73748168ae70bfb0e78349ef84f0 Mon Sep 17 00:00:00 2001 From: Oussama Hannouch Date: Mon, 10 Apr 2023 23:55:47 +0200 Subject: [PATCH] Update 'soft/PjtKEIL_StepSon/Src/GestionSon.s' --- soft/PjtKEIL_StepSon/Src/GestionSon.s | 35 ++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/soft/PjtKEIL_StepSon/Src/GestionSon.s b/soft/PjtKEIL_StepSon/Src/GestionSon.s index 5e5d7e9..e69c856 100644 --- a/soft/PjtKEIL_StepSon/Src/GestionSon.s +++ b/soft/PjtKEIL_StepSon/Src/GestionSon.s @@ -69,4 +69,37 @@ FIN ENDP - END \ No newline at end of file + END + + EXPORT GestionSon + EXPORT StartSon +StartSon proc + eor r0, r0 + ldr r1, =Son_index + str r0, [r1] + bx lr + endp + +GestionSon proc + ldr r2, =LongueurSon + ldr r0, [r2] + ldr r2, =Son_index + ldr r1, [r2] + cmp r0, r1 + bls EndOfSound ; if (LongeurSon <= Son_index) goto ResetGestionSon; + ldr r3, =Son + ldrsh r0, [r3, r1, lsl #1] + ; r0 = Son[Son_index] + add r0, #32768 + mov r3, #720 + mul r0, r3 + lsr r0, #16 ;x in [-32768; 32767] -> x in [0; 719] + ldr r3, =Sortie_son + str r0, [r3] ; Sortie_son = x + add r1, r1, #1 + str r1, [r2] ; Son_index++; + b PWM_Set_Value_TIM3_Ch3 +EndOfSound + bx lr + endp + END \ No newline at end of file