From 0ebfe3d25d02e67b8be9791a1eeb85b5c9fd87c6 Mon Sep 17 00:00:00 2001 From: Axel Olougouna Date: Fri, 21 Apr 2023 18:17:34 +0200 Subject: [PATCH] Debut DFT --- soft/PjtKEIL_StepDFT/Src/DFT.s | 34 +++++++- soft/PjtKEIL_StepDFT/Src/calculdft.s | 67 +++++++++++++++ soft/PjtKEIL_StepDFT/Src/principal.c | 7 +- soft/PjtKEIL_StepDFT/StepDFT.uvoptx | 32 ++++++- soft/PjtKEIL_StepDFT/StepDFT.uvprojx | 30 +++++++ soft/PjtKEIL_StepSon/GestionSon.h | 2 + soft/PjtKEIL_StepSon/Src/GestionSon.h | 2 + soft/PjtKEIL_StepSon/Src/GestionSon.s | 23 +++-- soft/PjtKEIL_StepSon/Src/principal.c | 13 ++- soft/PjtKEIL_StepSon/StepSon.uvoptx | 118 ++++++-------------------- soft/PjtKEIL_StepSon/StepSon.uvprojx | 17 +++- 11 files changed, 239 insertions(+), 106 deletions(-) create mode 100644 soft/PjtKEIL_StepDFT/Src/calculdft.s create mode 100644 soft/PjtKEIL_StepSon/GestionSon.h create mode 100644 soft/PjtKEIL_StepSon/Src/GestionSon.h diff --git a/soft/PjtKEIL_StepDFT/Src/DFT.s b/soft/PjtKEIL_StepDFT/Src/DFT.s index 3f6b5d4..ce78b6e 100644 --- a/soft/PjtKEIL_StepDFT/Src/DFT.s +++ b/soft/PjtKEIL_StepDFT/Src/DFT.s @@ -1,6 +1,6 @@ PRESERVE8 THUMB - + include Driver/DriverJeuLaser.inc ; ====================== zone de réservation de données, ====================================== ;Section RAM (read only) : @@ -13,7 +13,7 @@ ; =============================================================================================== - + EXPORT DFT_ModuleAuCarre @@ -21,7 +21,37 @@ area moncode,code,readonly ; écrire le code ici +DFT_ModuleAuCarre proc + push{lr, r4,r5, r6, r7} + + mov r2, r0 ; mettre l'adresse du signal dans r2 + mov r0, #0 ; r0 peut être utilisé ;dans r1 on a la valeur de k + ldr r4,=TabCos + mov r5, #0 ; contient notre indice n + +Boucle + cmp r5,#64 + ble Fin + ldrsh r3,[r2, r5, LSL #1] ; x[n] ; là format 4.12 + mul r6, r1, r5 ; kn + and r6, r6, #63 ; kn & 000000000011111 + ldrsh r7,[r4, r6, LSL #1] ; TabCos[kn] ; là format 1.15 + mul r3, r3, r7 ; x[n]*TabCos[n] 5.27 + asr r3, r3, #6 ; 5.21 + asr r0, r0, #6 ; 5.21 + ;mla r0, r7, r3, r0 ; x(k) += x[n]*TabCos[n] ;11.27 + add r0, r0, r3 ; 6.21 + + add r5, #1 + bl Boucle +Fin + + asr r0, r0, #16 + mul r0, r0, r0 ; 5. + pop{pc, r4, r5, r6, r7} + + endp diff --git a/soft/PjtKEIL_StepDFT/Src/calculdft.s b/soft/PjtKEIL_StepDFT/Src/calculdft.s new file mode 100644 index 0000000..60ff2ff --- /dev/null +++ b/soft/PjtKEIL_StepDFT/Src/calculdft.s @@ -0,0 +1,67 @@ + PRESERVE8 + THUMB + include Driver/DriverJeuLaser.inc + + +; ====================== zone de réservation de données, ====================================== +;Section RAM (read only) : + area mesdata,data,readonly + extern TabCos + extern LeSignal + +;Section RAM (read write): + area maram,data,readwrite + + + +; =============================================================================================== + + + + +;Section ROM code (read only) : + area moncode,code,readonly +; écrire le code ici + + EXPORT DFT_ModuleAuCarre + + +DFT_ModuleAuCarre proc + + push {lr} + ldr r0,=Son + ldr r1,=LongueurSon + ldr r1,[r1] + + + ldr r3,=Index ;on met l'adr d'Index dans r3 + ldrh r2,[r3] + + cmp r1,r2 + ble Fin + push{r4,r5} + + ldrsh r0,[r0,r2, LSL #1]; en C Son[Index] + add r2, r2, #1 + strh r2,[r3] ; maj Index + mov r1, #32768 + add r0, r0, r1 + mov r4, #719 + mul r0, r0, r4 + asr r0, r0, #16 + + ldr r5,=SortieSon + str r0,[r5] + bl PWM_Set_Value_TIM3_Ch3 + + pop{r4,r5} + +Fin + + pop {pc} + + endp + + + + END \ No newline at end of file diff --git a/soft/PjtKEIL_StepDFT/Src/principal.c b/soft/PjtKEIL_StepDFT/Src/principal.c index d09be75..3a74007 100644 --- a/soft/PjtKEIL_StepDFT/Src/principal.c +++ b/soft/PjtKEIL_StepDFT/Src/principal.c @@ -3,10 +3,13 @@ #include "DriverJeuLaser.h" +extern short int LeSignal; +extern int DFT_ModuleAuCarre(short int* Signal64ech, char k); int main(void) { + int tab[64]; // =========================================================================== // ============= INIT PERIPH (faites qu'une seule fois) ===================== // =========================================================================== @@ -14,8 +17,10 @@ int main(void) // Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers CLOCK_Configure(); - + for(int i=0; i<64; i++){ + tab[i] = DFT_ModuleAuCarre(&LeSignal, i); + } //============================================================================ diff --git a/soft/PjtKEIL_StepDFT/StepDFT.uvoptx b/soft/PjtKEIL_StepDFT/StepDFT.uvoptx index 0d72cfc..f6e9a5b 100644 --- a/soft/PjtKEIL_StepDFT/StepDFT.uvoptx +++ b/soft/PjtKEIL_StepDFT/StepDFT.uvoptx @@ -75,7 +75,7 @@ 1 0 - 0 + 1 18 @@ -267,7 +267,7 @@ 1 0 - 1 + 0 18 @@ -624,6 +624,30 @@ 0 0 + + 1 + 2 + 2 + 0 + 0 + 0 + .\Src\DFT.s + DFT.s + 0 + 0 + + + 1 + 3 + 2 + 0 + 0 + 0 + .\Src\Signal.asm + Signal.asm + 0 + 0 + @@ -634,7 +658,7 @@ 0 2 - 2 + 4 2 0 0 @@ -654,7 +678,7 @@ 0 3 - 3 + 5 4 0 0 diff --git a/soft/PjtKEIL_StepDFT/StepDFT.uvprojx b/soft/PjtKEIL_StepDFT/StepDFT.uvprojx index 9031782..63375da 100644 --- a/soft/PjtKEIL_StepDFT/StepDFT.uvprojx +++ b/soft/PjtKEIL_StepDFT/StepDFT.uvprojx @@ -388,6 +388,16 @@ 1 .\Src\principal.c + + DFT.s + 2 + .\Src\DFT.s + + + Signal.asm + 2 + .\Src\Signal.asm + @@ -797,6 +807,16 @@ 1 .\Src\principal.c + + DFT.s + 2 + .\Src\DFT.s + + + Signal.asm + 2 + .\Src\Signal.asm + @@ -1275,6 +1295,16 @@ 1 .\Src\principal.c + + DFT.s + 2 + .\Src\DFT.s + + + Signal.asm + 2 + .\Src\Signal.asm + diff --git a/soft/PjtKEIL_StepSon/GestionSon.h b/soft/PjtKEIL_StepSon/GestionSon.h new file mode 100644 index 0000000..a3134f8 --- /dev/null +++ b/soft/PjtKEIL_StepSon/GestionSon.h @@ -0,0 +1,2 @@ +extern void CallbackSon(void); +extern void StartSon(void); \ No newline at end of file diff --git a/soft/PjtKEIL_StepSon/Src/GestionSon.h b/soft/PjtKEIL_StepSon/Src/GestionSon.h new file mode 100644 index 0000000..a3134f8 --- /dev/null +++ b/soft/PjtKEIL_StepSon/Src/GestionSon.h @@ -0,0 +1,2 @@ +extern void CallbackSon(void); +extern void StartSon(void); \ No newline at end of file diff --git a/soft/PjtKEIL_StepSon/Src/GestionSon.s b/soft/PjtKEIL_StepSon/Src/GestionSon.s index d786326..7ac2ff7 100644 --- a/soft/PjtKEIL_StepSon/Src/GestionSon.s +++ b/soft/PjtKEIL_StepSon/Src/GestionSon.s @@ -12,7 +12,7 @@ ;Section RAM (read write): area maram,data,readwrite -SortieSon dcw 0 +SortieSon dcd 0 Index dcw 0 ; =============================================================================================== @@ -26,7 +26,8 @@ Index dcw 0 EXPORT CallbackSon EXPORT SortieSon - EXPORT Index + ;EXPORT Index + EXPORT StartSon CallbackSon proc push {lr} @@ -52,16 +53,28 @@ CallbackSon proc asr r0, r0, #16 ldr r5,=SortieSon - strh r0,[r5] + str r0,[r5] + bl PWM_Set_Value_TIM3_Ch3 pop{r4,r5} - pop{pc} - Fin pop {pc} endp + + +StartSon proc + + push {lr} + ldr r0,=Index + mov r1, #0 + strh r1,[r0] + + pop {pc} + + endp + END \ No newline at end of file diff --git a/soft/PjtKEIL_StepSon/Src/principal.c b/soft/PjtKEIL_StepSon/Src/principal.c index c15045b..0118d31 100644 --- a/soft/PjtKEIL_StepSon/Src/principal.c +++ b/soft/PjtKEIL_StepSon/Src/principal.c @@ -1,9 +1,10 @@ #include "DriverJeuLaser.h" +#include "GestionSon.h" +int bouton = 0; -extern void CallbackSon(void); int main(void) { @@ -15,14 +16,20 @@ int main(void) CLOCK_Configure(); Timer_1234_Init_ff(TIM4, 6552); -Active_IT_Debordement_Timer(TIM4, 2, CallbackSon); - +Active_IT_Debordement_Timer(TIM4, 2, CallbackSon); +PWM_Init_ff( TIM3, 3, 720); +GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL); + //============================================================================ while (1) { + if( bouton == 1){ + StartSon(); + bouton = 0; + } } } diff --git a/soft/PjtKEIL_StepSon/StepSon.uvoptx b/soft/PjtKEIL_StepSon/StepSon.uvoptx index aa872e3..8aa49b3 100644 --- a/soft/PjtKEIL_StepSon/StepSon.uvoptx +++ b/soft/PjtKEIL_StepSon/StepSon.uvoptx @@ -75,7 +75,7 @@ 1 0 - 1 + 0 18 @@ -153,88 +153,7 @@ -U066CFF574857847167074929 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) - - - 0 - 0 - 32 - 1 -
134220068
- 0 - 0 - 0 - 0 - 0 - 1 - .\Src\GestionSon.s - - \\StepSon\Src/GestionSon.s\32 -
- - 1 - 0 - 52 - 1 -
134220110
- 0 - 0 - 0 - 0 - 0 - 1 - .\Src\GestionSon.s - - \\StepSon\Src/GestionSon.s\52 -
- - 2 - 0 - 54 - 1 -
134220114
- 0 - 0 - 0 - 0 - 0 - 1 - .\Src\GestionSon.s - - \\StepSon\Src/GestionSon.s\54 -
- - 3 - 0 - 57 - 1 -
134220118
- 0 - 0 - 0 - 0 - 0 - 1 - .\Src\GestionSon.s - - \\StepSon\Src/GestionSon.s\57 -
- - 4 - 0 - 55 - 1 -
134220116
- 0 - 0 - 0 - 0 - 0 - 1 - .\Src\GestionSon.s - - \\StepSon\Src/GestionSon.s\55 -
-
+ 0 @@ -250,7 +169,7 @@ 1 - 256 + 260 0x200000a0 0 @@ -261,7 +180,7 @@ 0 1 - 1 + 0 0 0 0 @@ -275,7 +194,7 @@ 0 0 0 - 1 + 0 0 0 0 @@ -301,12 +220,12 @@ 0 ((portb & 0x00000002) >> 1 & 0x2) >> 1 - FF000000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000922449922449E23F030000000000000000000000000000000000000096020008 + FF000000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000922449922449E23F150000000000000000000000000000000000000096020008 1 `SortieSon - 0080000000000000000000000000001D0488B54100000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000002000000DBB66DDBB66DDB3F030000000000000000000000000000000000000000090008 + 008000000000000000000000000000000070864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000002000000DBB66DDBB66DDB3F150000000000000000000000000000000000000000090008 @@ -373,7 +292,7 @@ 1 0 - 0 + 1 18 @@ -452,6 +371,13 @@ + + + 0 + 1 + bouton + + 1 @@ -466,7 +392,7 @@ 0 1 - 1 + 0 0 0 0 @@ -802,6 +728,18 @@ 0 0 + + 4 + 6 + 5 + 0 + 0 + 0 + .\Src\GestionSon.h + GestionSon.h + 0 + 0 +
diff --git a/soft/PjtKEIL_StepSon/StepSon.uvprojx b/soft/PjtKEIL_StepSon/StepSon.uvprojx index c69c3c5..55b20c6 100644 --- a/soft/PjtKEIL_StepSon/StepSon.uvprojx +++ b/soft/PjtKEIL_StepSon/StepSon.uvprojx @@ -423,6 +423,11 @@ 2 .\Src\GestionSon.s + + GestionSon.h + 5 + .\Src\GestionSon.h + @@ -434,7 +439,7 @@ CibleSondeKEIL 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 @@ -847,6 +852,11 @@ 2 .\Src\GestionSon.s + + GestionSon.h + 5 + .\Src\GestionSon.h + @@ -1340,6 +1350,11 @@ 2 .\Src\GestionSon.s + + GestionSon.h + 5 + .\Src\GestionSon.h +