StartSon fonctionnelle

This commit is contained in:
Remi Pitault 2023-04-12 13:02:13 +02:00
parent 2304e386e9
commit 7bbad209c5
3 changed files with 17 additions and 7 deletions

View file

@ -13,7 +13,7 @@
;Section RAM (read write): ;Section RAM (read write):
area maram,data,readwrite area maram,data,readwrite
IndexSon DCW 0 IndexSon DCW 5512
SortieSon DCW 0 SortieSon DCW 0
EXPORT SortieSon EXPORT SortieSon
@ -21,11 +21,21 @@ SortieSon DCW 0
; =============================================================================================== ; ===============================================================================================
EXPORT CallbackSon EXPORT CallbackSon
EXPORT StartSon
;Section ROM code (read only) : ;Section ROM code (read only) :
area moncode,code,readonly area moncode,code,readonly
; écrire le code ici ; écrire le code ici
StartSon proc
push {lr}
ldr r0, =IndexSon
mov r1, #0
str r1, [r0]
pop {lr}
bx lr
ENDP
CallbackSon proc CallbackSon proc
push {lr} push {lr}
ldr r0, =IndexSon ; r0 = &IndexSon ldr r0, =IndexSon ; r0 = &IndexSon
@ -35,9 +45,7 @@ CallbackSon proc
ldr r3, [r2] ; r3 = LongueurSon ldr r3, [r2] ; r3 = LongueurSon
cmp r1, r3 cmp r1, r3
blt NoReset bge DoNothing
mov r1, #0 ; si IndexSon >= LongueurSon alors IndexSon = 0
NoReset
ldr r3, =Son ; r3 = &Son ldr r3, =Son ; r3 = &Son
ldrsh r2, [r3, r1, LSL#1] ; r2 = Son[IndexSon] ldrsh r2, [r3, r1, LSL#1] ; r2 = Son[IndexSon]
add r2, #0x8000 ; translater de [-32768;32767] à [0;65535] add r2, #0x8000 ; translater de [-32768;32767] à [0;65535]
@ -50,6 +58,7 @@ NoReset
strh r2, [r0] ; SortieSon = ce qu'on veut strh r2, [r0] ; SortieSon = ce qu'on veut
mov r0, r2 mov r0, r2
bl PWM_Set_Value_TIM3_Ch3 bl PWM_Set_Value_TIM3_Ch3
DoNothing
pop {lr} pop {lr}
bx lr bx lr

View file

@ -1,6 +1,7 @@
#include "DriverJeuLaser.h" #include "DriverJeuLaser.h"
extern void CallbackSon(void); extern void CallbackSon(void);
extern void StartSon(void);
int main(void) int main(void)
{ {
@ -16,10 +17,10 @@ PWM_Init_ff(TIM3, 3, 720); // f_PWM = 72MHz/720 = 100kHz
Timer_1234_Init_ff(TIM4, 6552); // periode_son/f_CPU = (91*10^-6)*(72*10^6) = 6552 Timer_1234_Init_ff(TIM4, 6552); // periode_son/f_CPU = (91*10^-6)*(72*10^6) = 6552
Active_IT_Debordement_Timer(TIM4, 2, CallbackSon); Active_IT_Debordement_Timer(TIM4, 2, CallbackSon);
//============================================================================ //============================================================================
while (1) while (1)
{ {
StartSon();
} }
} }

View file

@ -215,7 +215,7 @@
<Wi> <Wi>
<IntNumber>0</IntNumber> <IntNumber>0</IntNumber>
<FirstString>`SortieSon</FirstString> <FirstString>`SortieSon</FirstString>
<SecondString>008000000000000000000000000000905D78864100000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100000001000000000000000000E03F170000000000000000000000000000000000000094080008</SecondString> <SecondString>0080000000000010572172410000005058E17A4100000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100000001000000000000000000E03F170000000000000000000000000000000000000094080008</SecondString>
</Wi> </Wi>
<Wi> <Wi>
<IntNumber>1</IntNumber> <IntNumber>1</IntNumber>