From 609f428e0df35041bb150f99bf4d5aff268361c5 Mon Sep 17 00:00:00 2001 From: Cavailles Kevin Date: Fri, 27 Mar 2020 18:28:57 +0100 Subject: [PATCH] DFT en cours --- Project.uvoptx | 60 ++++++++++++++++++++++-------------- Project.uvprojx | 14 +++++++-- Src/be_1.s | 7 +++-- Src/calculCarre.s | 11 +++++-- Src/calcul_dft.s | 65 +++++++++++++++++++++++++++++++++++++++ Src/principal.c | 51 ++++++++++++++++++------------ Src/signal.s | 75 +++++++++++++++++++++++++++++++++++++++++++++ Src/table_sin_cos.s | 1 + 8 files changed, 235 insertions(+), 49 deletions(-) create mode 100644 Src/calcul_dft.s create mode 100644 Src/signal.s diff --git a/Project.uvoptx b/Project.uvoptx index 5bd83fc..46972a0 100644 --- a/Project.uvoptx +++ b/Project.uvoptx @@ -153,29 +153,19 @@ -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 - 9 - 1 -
134225472
- 0 - 0 - 0 - 0 - 0 - 1 - .\Src\principal.c - - \\CHTI\Src/principal.c\9 -
-
+ + + + 0 + 1 + tab + + 1 - 0 - 0x20000000 + 10 + 0x08001F28 0 @@ -199,7 +189,7 @@ 0 0 0 - 1 + 0 0 0 0 @@ -287,8 +277,8 @@ 0 0 0 - .\Src\table_sin_cos.s - table_sin_cos.s + .\Src\calcul_dft.s + calcul_dft.s 0 0 @@ -332,6 +322,30 @@ 0 0 + + 3 + 7 + 2 + 0 + 0 + 0 + .\Src\table_sin_cos.s + table_sin_cos.s + 0 + 0 + + + 3 + 8 + 2 + 0 + 0 + 0 + .\Src\signal.s + signal.s + 0 + 0 + diff --git a/Project.uvprojx b/Project.uvprojx index 778d4ed..2f7ce75 100644 --- a/Project.uvprojx +++ b/Project.uvprojx @@ -398,9 +398,9 @@ .\Src\calculCarre.s - table_sin_cos.s + calcul_dft.s 2 - .\Src\table_sin_cos.s + .\Src\calcul_dft.s @@ -422,6 +422,16 @@ 4 ..\GASSP72\gassp72.lib + + table_sin_cos.s + 2 + .\Src\table_sin_cos.s + + + signal.s + 2 + .\Src\signal.s + diff --git a/Src/be_1.s b/Src/be_1.s index 2368c13..cdbf819 100644 --- a/Src/be_1.s +++ b/Src/be_1.s @@ -12,6 +12,8 @@ GPIOB_BSRR equ 0x40010C10 ; Bit Set/Reset register timer_callback proc ; mise a 1 de PB1 + push {lr} + ldr r1, =etat ldr r1, [r1] ldr r3, =GPIOB_BSRR @@ -23,8 +25,9 @@ gdc ldr r0, =etat str r1, [r0] str r1, [r3] ; N.B. le registre BSRR est write-only, on ne peut pas le relire - - bx lr + + pop {lr} + bx lr endp eq diff --git a/Src/calculCarre.s b/Src/calculCarre.s index fa9cd64..c173ee5 100644 --- a/Src/calculCarre.s +++ b/Src/calculCarre.s @@ -7,9 +7,13 @@ ; calcul_carre proc - ldr r3, =TabSin + + push {r4} + push {r5} + + ldr r4, =TabSin ldr r5, =TabCos - ldrh r2, [r3, r0, LSL #1] + ldrh r2, [r4, r0, LSL #1] ldrh r0, [r5, r0, LSL #1] mul r0, r0 @@ -17,7 +21,8 @@ calcul_carre proc add r0, r2 - str r0, [r1] + pop {r5} + pop {r4} bx lr endp diff --git a/Src/calcul_dft.s b/Src/calcul_dft.s new file mode 100644 index 0000000..66c0bdb --- /dev/null +++ b/Src/calcul_dft.s @@ -0,0 +1,65 @@ +; ce programme est pour l'assembleur RealView (Keil) + thumb + area moncode, code, readonly + export calcul_dft_moitie + export calcul_dft + import TabCos + import TabSin + import TabSig +; + + +calcul_dft proc + push {lr} + + ;push {r1} + + ldr r2, =TabCos + bl calcul_dft_moitie ;recuperation Re(k) dans r0 + + ;pop {r1} + + ;push {r0} ;mise de Re(k) dans la pile + + ;ldr r2, =TabSin + ;bl calcul_dft_moitie ;mise de -Im(k) dans r0 + + ;mul r0, r0, r0 ;(-Im(k))² + + ;pop {r1} ;mise de Re(k) dans r1 + ;mul r1, r1, r1 ;Re(k)² + ;add r0, r0, r1 ;addition de Re(k)² + Im(k)² + pop {lr} + bx lr + endp + +calcul_dft_moitie proc + push {lr,r4-r6} + + + mov r4, r0 + mov r5, r2 + mov r6, r1 + + mov r3, #0 ;i=0 dans r3 + mov r0, #0 ;resultat de la somme dans r0 +boucle ldrh r2, [r4, r3, LSL #1] ;chargement de x(i) + + mul r1, r3, r6 ;multiplication ik dans r1 + and r1, r1, #63 ;modulo de ik par 64 + + ldrh r1, [r5, r1, LSL #1] ;chargement de cos(ik..) + mul r1, r1, r2 ;multiplication x(i)cos(ik..) + add r0, r0, r1 ;ajout dans la somme + add r3, #1 ;incrementation de i + cmp r3, #64 ;test de i + bne boucle + beq sortie + +sortie + + pop {lr,r4-r6} + bx lr + endp + + end \ No newline at end of file diff --git a/Src/principal.c b/Src/principal.c index 17faa04..b087cc3 100644 --- a/Src/principal.c +++ b/Src/principal.c @@ -1,29 +1,42 @@ #include "gassp72.h" extern void timer_callback(void); +extern short TabSig[]; int etat = 0x00020000; +extern int calcul_carre(int); +extern int calcul_dft(short *, int); +//int tab[64]; + + int main(void) { - u32 Periode_en_Tck = 7200000; - // activation de la PLL qui multiplie la fréquence du quartz par 9 - CLOCK_Configure(); - // config port PB1 pour être utilisé en sortie - GPIO_Configure(GPIOB, 1, OUTPUT, OUTPUT_PPULL); - // initialisation du timer 4 - // Periode_en_Tck doit fournir la durée entre interruptions, - // exprimée en périodes Tck de l'horloge principale du STM32 (72 MHz) - Timer_1234_Init_ff( TIM4, Periode_en_Tck ); - // enregistrement de la fonction de traitement de l'interruption timer - // ici le 2 est la priorité, timer_callback est l'adresse de cette fonction, a créér en asm, - // cette fonction doit être conforme à l'AAPCS - Active_IT_Debordement_Timer( TIM4, 2, timer_callback ); - // lancement du timer - Run_Timer( TIM4 ); - while (1) - { - - } + //for(int i=0; i<64; i++){ + // tab[i]= calcul_carre(i); + //} + calcul_dft(TabSig,1); + + + u32 Periode_en_Tck = 7200000; + + // activation de la PLL qui multiplie la fréquence du quartz par 9 + CLOCK_Configure(); + // config port PB1 pour être utilisé en sortie + GPIO_Configure(GPIOB, 1, OUTPUT, OUTPUT_PPULL); + // initialisation du timer 4 + // Periode_en_Tck doit fournir la durée entre interruptions, + // exprimée en périodes Tck de l'horloge principale du STM32 (72 MHz) + Timer_1234_Init_ff( TIM4, Periode_en_Tck ); + // enregistrement de la fonction de traitement de l'interruption timer + // ici le 2 est la priorité, timer_callback est l'adresse de cette fonction, a créér en asm, + // cette fonction doit être conforme à l'AAPCS + Active_IT_Debordement_Timer( TIM4, 2, timer_callback ); + // lancement du timer + Run_Timer( TIM4 ); + while (1) + { + + } } diff --git a/Src/signal.s b/Src/signal.s new file mode 100644 index 0000000..492eb71 --- /dev/null +++ b/Src/signal.s @@ -0,0 +1,75 @@ + AREA Signal, DATA, READONLY + export TabSig + +; Fnor = 1.000 +; Ph = 0.000 +; A = 2048.000 + +TabSig + DCW 4095 ; 0 0x0fff 0.99976 + DCW 4086 ; 1 0x0ff6 0.99756 + DCW 4057 ; 2 0x0fd9 0.99048 + DCW 4008 ; 3 0x0fa8 0.97852 + DCW 3940 ; 4 0x0f64 0.96191 + DCW 3854 ; 5 0x0f0e 0.94092 + DCW 3751 ; 6 0x0ea7 0.91577 + DCW 3631 ; 7 0x0e2f 0.88647 + DCW 3496 ; 8 0x0da8 0.85352 + DCW 3347 ; 9 0x0d13 0.81714 + DCW 3186 ; 10 0x0c72 0.77783 + DCW 3013 ; 11 0x0bc5 0.73560 + DCW 2832 ; 12 0x0b10 0.69141 + DCW 2643 ; 13 0x0a53 0.64526 + DCW 2448 ; 14 0x0990 0.59766 + DCW 2249 ; 15 0x08c9 0.54907 + DCW 2048 ; 16 0x0800 0.50000 + DCW 1847 ; 17 0x0737 0.45093 + DCW 1648 ; 18 0x0670 0.40234 + DCW 1453 ; 19 0x05ad 0.35474 + DCW 1264 ; 20 0x04f0 0.30859 + DCW 1083 ; 21 0x043b 0.26440 + DCW 910 ; 22 0x038e 0.22217 + DCW 749 ; 23 0x02ed 0.18286 + DCW 600 ; 24 0x0258 0.14648 + DCW 465 ; 25 0x01d1 0.11353 + DCW 345 ; 26 0x0159 0.08423 + DCW 242 ; 27 0x00f2 0.05908 + DCW 156 ; 28 0x009c 0.03809 + DCW 88 ; 29 0x0058 0.02148 + DCW 39 ; 30 0x0027 0.00952 + DCW 10 ; 31 0x000a 0.00244 + DCW 0 ; 32 0x0000 0.00000 + DCW 10 ; 33 0x000a 0.00244 + DCW 39 ; 34 0x0027 0.00952 + DCW 88 ; 35 0x0058 0.02148 + DCW 156 ; 36 0x009c 0.03809 + DCW 242 ; 37 0x00f2 0.05908 + DCW 345 ; 38 0x0159 0.08423 + DCW 465 ; 39 0x01d1 0.11353 + DCW 600 ; 40 0x0258 0.14648 + DCW 749 ; 41 0x02ed 0.18286 + DCW 910 ; 42 0x038e 0.22217 + DCW 1083 ; 43 0x043b 0.26440 + DCW 1264 ; 44 0x04f0 0.30859 + DCW 1453 ; 45 0x05ad 0.35474 + DCW 1648 ; 46 0x0670 0.40234 + DCW 1847 ; 47 0x0737 0.45093 + DCW 2048 ; 48 0x0800 0.50000 + DCW 2249 ; 49 0x08c9 0.54907 + DCW 2448 ; 50 0x0990 0.59766 + DCW 2643 ; 51 0x0a53 0.64526 + DCW 2832 ; 52 0x0b10 0.69141 + DCW 3013 ; 53 0x0bc5 0.73560 + DCW 3186 ; 54 0x0c72 0.77783 + DCW 3347 ; 55 0x0d13 0.81714 + DCW 3496 ; 56 0x0da8 0.85352 + DCW 3631 ; 57 0x0e2f 0.88647 + DCW 3751 ; 58 0x0ea7 0.91577 + DCW 3854 ; 59 0x0f0e 0.94092 + DCW 3940 ; 60 0x0f64 0.96191 + DCW 4008 ; 61 0x0fa8 0.97852 + DCW 4057 ; 62 0x0fd9 0.99048 + DCW 4086 ; 63 0x0ff6 0.99756 + + END + diff --git a/Src/table_sin_cos.s b/Src/table_sin_cos.s index 0dfc80b..c529846 100644 --- a/Src/table_sin_cos.s +++ b/Src/table_sin_cos.s @@ -1,6 +1,7 @@ area Trigo, DATA, READONLY export TabSin export TabCos + TabCos DCW 32767 ; 0 0x7fff 0.99997