diff --git a/BE-chti C/soft/PjtKEIL_StepSon/Src/GestionSon.s b/BE-chti C/soft/PjtKEIL_StepSon/Src/GestionSon.s index a605b9e..932c75d 100644 --- a/BE-chti C/soft/PjtKEIL_StepSon/Src/GestionSon.s +++ b/BE-chti C/soft/PjtKEIL_StepSon/Src/GestionSon.s @@ -1,20 +1,11 @@ - PRESERVE8 +PRESERVE8 THUMB - EXPORT CallbackSon - EXPORT SortieSon - EXPORT i - IMPORT Son - IMPORT LongueurSon - INCLUDE DriverJeuLaser.inc -;void CallbackSon(void){ -; static int i = 0; -; if(i < 5512){ -;0 SortieSon = (Son[i] + 32768) * 719 / 65535; -; i++; -; } -;} - + import LongueurSon + import PeriodeSonMicroSec + import Son + + include Driver/DriverJeuLaser.inc ; ====================== zone de réservation de données, ====================================== ;Section RAM (read only) : @@ -24,48 +15,49 @@ ;Section RAM (read write): area maram,data,readwrite -i dcd 0 -SortieSon dcw 0 +Son_index dcd 0 +SortieSon dcw 0 ; =============================================================================================== + EXPORT Son_index + EXPORT SortieSon ;Section ROM code (read only) : area moncode,code,readonly -; écrire le code ici - -CallbackSon proc - push {lr} - - ldr r0,=i - ldr r1, [r0] - ldr r2,LongueurSon - cmp r2, r1 -; if(i < 5512) - ble fin - - ldr r3,=Son - ldrsh r2, [r3,r1, LSL#1] - add r2, #32768 - mov r12, #719 - mul r2, r12 - mov r12, #65535 - udiv r2, r12 -; i++; - add r1, #1 - str r1, [r0] -; On stocke enfin la sortie son - ldr r0, =SortieSon - strh r2, [r0] - mov r0, r2 - bl PWM_Set_Value_TIM3_Ch3 +; écrire le code ici + EXPORT StartSon + EXPORT CallbackSon + +StartSon proc + mov r0, #0 ; Charger la valeur 0 dans le registre r0 + ldr r1, =Son_index ; Charger l'adresse de la variable Son_index dans le registre r1 + str r0, [r1] ; Stocker la valeur de r0 dans la variable Son_index + bx lr ; Retourner à l'appelant + endp; Fin de la procédure StartSon +CallbackSon proc + ldr r1, =LongueurSon + ldr r0, [r1] + ldr r1, =Son_index + ldr r2, [r1] + cmp r0, r2 + bls fin ; if (LongeurSon <= Son_index) ; + 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] // divise r0 par 65536 + ldr r3, =SortieSon + str r0, [r3] ; Sortie_son = x + add r2, r2, #1 + str r2, [r1] ; Son_index++; + b PWM_Set_Value_TIM3_Ch3 fin - pop {pc} - ENDFUNC - - - END \ No newline at end of file + bx lr + endp + END \ No newline at end of file