PRESERVE8 THUMB IMPORT LongueurSon IMPORT PeriodeSonMicroSec IMPORT Son IMPORT PWM_Set_Value_TIM3_Ch3 EXPORT CallbackSon ; ====================== 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 EXPORT SortieSon ; =============================================================================================== ;Section ROM code (read only) : area moncode,code,readonly ; écrire le code ici CallbackSon proc ;; 1. Il faut pouvoir utiliser SortieSon comme index d'iteration dans le tableau bruitverre push {r4,r5,r6,r7,lr} ldr r1,=SortieSon ;sortie ldr r2,=LongueurSon ;nb de sons ldr r2,[r2] ldr r3,=Son ;adresse du tableau de sons ldr r7,=Index ldr r4,[r7] ;compteur cmp r4,r2 ;moveq r4,#0 beq fin mov r5,#(1<<15) ;registre pour operations mov r6,#719 ;sauvegarde de 719 calcul ldrsh r0, [r3,r4,lsl #1] ;faire +32768, ensuite x719, puis diviser par 2^16 add r0,r5 mul r0,r0,r6 lsr r0,#16 str r0,[r1] add r4,#1 str r4,[r7] push {r1,r2,r3} bl PWM_Set_Value_TIM3_Ch3 pop {r1,r2,r3} ;add r4,#1 ;cmp r2,r4 ;bne calcul fin pop {r4,r5,r6,r7,lr} bx lr endp StartSon proc ldr r1,=Index ldr r2,=LongueurSon cmp r1,r2 bne pass mov r1,#0 pass bx lr endp END