diff --git a/GASSP72/Manuel_utilisateur_GASSP72_v7.pdf b/GASSP72/Manuel_utilisateur_GASSP72_v7.pdf deleted file mode 100644 index e146140..0000000 Binary files a/GASSP72/Manuel_utilisateur_GASSP72_v7.pdf and /dev/null differ diff --git a/GASSP72/gassp72.lib b/GASSP72/gassp72.lib deleted file mode 100644 index 7dc0b32..0000000 Binary files a/GASSP72/gassp72.lib and /dev/null differ diff --git a/GFSSP72/GFSSP72.pdf b/GFSSP72/GFSSP72.pdf new file mode 100644 index 0000000..fc4f40c Binary files /dev/null and b/GFSSP72/GFSSP72.pdf differ diff --git a/GASSP72/gassp72.h b/GFSSP72/gassp72.h similarity index 100% rename from GASSP72/gassp72.h rename to GFSSP72/gassp72.h diff --git a/GFSSP72/gfssp72.lib b/GFSSP72/gfssp72.lib new file mode 100644 index 0000000..595e9f5 Binary files /dev/null and b/GFSSP72/gfssp72.lib differ diff --git a/Project.uvoptx b/Project.uvoptx index 84566e1..28879f9 100644 --- a/Project.uvoptx +++ b/Project.uvoptx @@ -153,7 +153,40 @@ -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 + 12 + 1 +
134221212
+ 0 + 0 + 0 + 0 + 0 + 1 + .\Src\calcul_dft.s + + \\CHTI\Src/calcul_dft.s\12 +
+ + 1 + 0 + 19 + 1 +
134221156
+ 0 + 0 + 0 + 0 + 0 + 1 + .\Src\gestionSon.s + + \\CHTI\Src/gestionSon.s\19 +
+
0 @@ -180,7 +213,7 @@ 1 10 - 0x08001F24 + 0x0A490BB4 0 @@ -273,6 +306,18 @@ 0 0 + + 1 + 3 + 2 + 0 + 0 + 0 + .\Src\calcul_dft.s + calcul_dft.s + 0 + 0 + @@ -283,7 +328,7 @@ 0 2 - 3 + 4 2 0 0 @@ -303,7 +348,7 @@ 0 3 - 4 + 5 5 0 0 @@ -315,7 +360,7 @@ 3 - 5 + 6 2 0 0 @@ -327,13 +372,25 @@ 3 - 6 + 7 4 0 0 0 - .\GASSP72\gassp72.lib - gassp72.lib + .\GFSSP72\gfssp72.lib + gfssp72.lib + 0 + 0 + + + 3 + 8 + 2 + 0 + 0 + 0 + .\Src\tab_cos_sin.asm + tab_cos_sin.asm 0 0 diff --git a/Project.uvprojx b/Project.uvprojx index ebd090a..ba6c5c5 100644 --- a/Project.uvprojx +++ b/Project.uvprojx @@ -338,7 +338,7 @@ --C99 STM32F103xB,USE_FULL_LL_DRIVER - ./GASSP72 + ./GFSSP72 @@ -392,6 +392,11 @@ 2 .\Src\gestionSon.s + + calcul_dft.s + 2 + .\Src\calcul_dft.s + @@ -418,9 +423,14 @@ .\Src\son.asm - gassp72.lib + gfssp72.lib 4 - .\GASSP72\gassp72.lib + .\GFSSP72\gfssp72.lib + + + tab_cos_sin.asm + 2 + .\Src\tab_cos_sin.asm diff --git a/Src/calcul_dft.s b/Src/calcul_dft.s new file mode 100644 index 0000000..c4a7a0d --- /dev/null +++ b/Src/calcul_dft.s @@ -0,0 +1,64 @@ + ;ce programme est pour l'assembleur RealView (Keil) + thumb + area moncode, code, readonly + export calcul_dft + import TabCos + import TabSin + +; + + +calcul_dft proc + push {lr} + + push {r0,r1,r4,r5} + + ldr r2, =TabCos + bl calcul_partie_dft ;recuperation Re(k) dans r0 + + smull r4, r5, r0, r0 ;Re(k)² dans r4, r5 + pop {r0,r1} ;recupereration de TabSig et k dans r0,r1 + + + ldr r2, =TabSin + bl calcul_partie_dft ;mise de -Im(k) dans r0 + + smlal r4, r5, r0, r0 ;Re²+(-Im(k))² + + mov r0, r5 ;recuperation des bits de poids fort de M2(k) + pop {lr, r4,r5} + bx lr + endp + +calcul_partie_dft proc + push {r4-r7} + + + mov r4, r0 ;chargement de TabSig dans r4 + mov r5, r2 ;chargement de TabCos/TabSin dans r5 + mov r6, r1 ;chargement de k dans r6 + mov r7, #0 ;ik dans r7 + + mov r3, #0 ;i=0 dans r3 + mov r0, #0 ;resultat de la somme dans r0 + +boucle ldrh r1, [r4, r3, LSL #1] ;chargement de x(i) + ldrsh r2, [r5, r7, LSL #1] ;chargement de cos(ik..), ldrs(!)h tres important, ne fonctionne pas sinon + + mla r0, r1, r2, r0 ;multiplication + ajout au resultat de x(i)cos(ik..) + + add r7, r7, r6 ;mise a jour de ik + and r7, r7, #63 ;modulo de ik par 64 + + add r3, #1 ;incrementation de i + cmp r3, #64 ;test de i + bne boucle + beq sortie + +sortie + + pop {r4-r7} + bx lr + endp + + end \ No newline at end of file diff --git a/Src/principal.c b/Src/principal.c index 25d8562..4388c47 100644 --- a/Src/principal.c +++ b/Src/principal.c @@ -4,18 +4,58 @@ #include #include "etat.h" - +#define TAILLE 6 #define periode_tick_pwm 360 // (360000 ticks équivaut à 5ms) +#define SYSTICK_PER 360000 // (360000 ticks équivaut à 5ms) +#define M2TIR 985988 - -extern void timer_callback(void); extern short Son[]; +extern void timer_callback(void); extern int LongueurSon; extern int PeriodeSonMicroSec; + +extern short TabSig[]; + +extern int calcul_carre(int); +extern int calcul_dft(unsigned short *, int); + +int res_dft = 0; +unsigned short dma_buf[64]; +int compteurs[TAILLE]; +int scores[TAILLE]; +int k_values[] = {17,18,19,20,23,24}; + type_etat etat; +void checkCounter(void){ + for(int i=0; i= 13){ + compteurs[i]=0; + scores[i]++; + etat.position = 0; + } + } +} + +void sys_callback(void){ + // Démarrage DMA pour 64 points + Start_DMA1(64); + Wait_On_End_Of_DMA1(); + Stop_DMA1; + + for(int i=0; i M2TIR){ + compteurs[i]++; + }else{ + compteurs[i] = 0; + } + } + + checkCounter(); +} int main(void) { @@ -44,6 +84,23 @@ int main(void) // lancement du timer Run_Timer( TIM4 ); + + // activation ADC, sampling time 1us + Init_TimingADC_ActiveADC_ff( ADC1, 0x33 ); + Single_Channel_ADC( ADC1, 2 ); + // Déclenchement ADC par timer2, periode (72MHz/320kHz)ticks + Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 ); + // Config DMA pour utilisation du buffer dma_buf (a créér) + Init_ADC1_DMA1( 0, dma_buf ); + + // Config Timer, période exprimée en périodes horloge CPU (72 MHz) + Systick_Period_ff( SYSTICK_PER ); + // enregistrement de la fonction de traitement de l'interruption timer + // ici le 3 est la priorité, sys_callback est l'adresse de cette fonction, a créér en C + Systick_Prio_IT( 3, sys_callback ); + SysTick_On; + SysTick_Enable_IT; + while(1){ } diff --git a/Src/tab_cos_sin.asm b/Src/tab_cos_sin.asm new file mode 100644 index 0000000..8983524 --- /dev/null +++ b/Src/tab_cos_sin.asm @@ -0,0 +1,136 @@ + AREA Trigo, DATA, READONLY + export TabSin + export TabCos + +TabCos + DCW 32767 ; 0 0x7fff 0.99997 + DCW 32610 ; 1 0x7f62 0.99518 + DCW 32138 ; 2 0x7d8a 0.98077 + DCW 31357 ; 3 0x7a7d 0.95694 + DCW 30274 ; 4 0x7642 0.92389 + DCW 28899 ; 5 0x70e3 0.88193 + DCW 27246 ; 6 0x6a6e 0.83148 + DCW 25330 ; 7 0x62f2 0.77301 + DCW 23170 ; 8 0x5a82 0.70709 + DCW 20788 ; 9 0x5134 0.63440 + DCW 18205 ; 10 0x471d 0.55557 + DCW 15447 ; 11 0x3c57 0.47141 + DCW 12540 ; 12 0x30fc 0.38269 + DCW 9512 ; 13 0x2528 0.29028 + DCW 6393 ; 14 0x18f9 0.19510 + DCW 3212 ; 15 0x0c8c 0.09802 + DCW 0 ; 16 0x0000 0.00000 + DCW -3212 ; 17 0xf374 -0.09802 + DCW -6393 ; 18 0xe707 -0.19510 + DCW -9512 ; 19 0xdad8 -0.29028 + DCW -12540 ; 20 0xcf04 -0.38269 + DCW -15447 ; 21 0xc3a9 -0.47141 + DCW -18205 ; 22 0xb8e3 -0.55557 + DCW -20788 ; 23 0xaecc -0.63440 + DCW -23170 ; 24 0xa57e -0.70709 + DCW -25330 ; 25 0x9d0e -0.77301 + DCW -27246 ; 26 0x9592 -0.83148 + DCW -28899 ; 27 0x8f1d -0.88193 + DCW -30274 ; 28 0x89be -0.92389 + DCW -31357 ; 29 0x8583 -0.95694 + DCW -32138 ; 30 0x8276 -0.98077 + DCW -32610 ; 31 0x809e -0.99518 + DCW -32768 ; 32 0x8000 -1.00000 + DCW -32610 ; 33 0x809e -0.99518 + DCW -32138 ; 34 0x8276 -0.98077 + DCW -31357 ; 35 0x8583 -0.95694 + DCW -30274 ; 36 0x89be -0.92389 + DCW -28899 ; 37 0x8f1d -0.88193 + DCW -27246 ; 38 0x9592 -0.83148 + DCW -25330 ; 39 0x9d0e -0.77301 + DCW -23170 ; 40 0xa57e -0.70709 + DCW -20788 ; 41 0xaecc -0.63440 + DCW -18205 ; 42 0xb8e3 -0.55557 + DCW -15447 ; 43 0xc3a9 -0.47141 + DCW -12540 ; 44 0xcf04 -0.38269 + DCW -9512 ; 45 0xdad8 -0.29028 + DCW -6393 ; 46 0xe707 -0.19510 + DCW -3212 ; 47 0xf374 -0.09802 + DCW 0 ; 48 0x0000 0.00000 + DCW 3212 ; 49 0x0c8c 0.09802 + DCW 6393 ; 50 0x18f9 0.19510 + DCW 9512 ; 51 0x2528 0.29028 + DCW 12540 ; 52 0x30fc 0.38269 + DCW 15447 ; 53 0x3c57 0.47141 + DCW 18205 ; 54 0x471d 0.55557 + DCW 20788 ; 55 0x5134 0.63440 + DCW 23170 ; 56 0x5a82 0.70709 + DCW 25330 ; 57 0x62f2 0.77301 + DCW 27246 ; 58 0x6a6e 0.83148 + DCW 28899 ; 59 0x70e3 0.88193 + DCW 30274 ; 60 0x7642 0.92389 + DCW 31357 ; 61 0x7a7d 0.95694 + DCW 32138 ; 62 0x7d8a 0.98077 + DCW 32610 ; 63 0x7f62 0.99518 +TabSin + DCW 0 ; 0 0x0000 0.00000 + DCW 3212 ; 1 0x0c8c 0.09802 + DCW 6393 ; 2 0x18f9 0.19510 + DCW 9512 ; 3 0x2528 0.29028 + DCW 12540 ; 4 0x30fc 0.38269 + DCW 15447 ; 5 0x3c57 0.47141 + DCW 18205 ; 6 0x471d 0.55557 + DCW 20788 ; 7 0x5134 0.63440 + DCW 23170 ; 8 0x5a82 0.70709 + DCW 25330 ; 9 0x62f2 0.77301 + DCW 27246 ; 10 0x6a6e 0.83148 + DCW 28899 ; 11 0x70e3 0.88193 + DCW 30274 ; 12 0x7642 0.92389 + DCW 31357 ; 13 0x7a7d 0.95694 + DCW 32138 ; 14 0x7d8a 0.98077 + DCW 32610 ; 15 0x7f62 0.99518 + DCW 32767 ; 16 0x7fff 0.99997 + DCW 32610 ; 17 0x7f62 0.99518 + DCW 32138 ; 18 0x7d8a 0.98077 + DCW 31357 ; 19 0x7a7d 0.95694 + DCW 30274 ; 20 0x7642 0.92389 + DCW 28899 ; 21 0x70e3 0.88193 + DCW 27246 ; 22 0x6a6e 0.83148 + DCW 25330 ; 23 0x62f2 0.77301 + DCW 23170 ; 24 0x5a82 0.70709 + DCW 20788 ; 25 0x5134 0.63440 + DCW 18205 ; 26 0x471d 0.55557 + DCW 15447 ; 27 0x3c57 0.47141 + DCW 12540 ; 28 0x30fc 0.38269 + DCW 9512 ; 29 0x2528 0.29028 + DCW 6393 ; 30 0x18f9 0.19510 + DCW 3212 ; 31 0x0c8c 0.09802 + DCW 0 ; 32 0x0000 0.00000 + DCW -3212 ; 33 0xf374 -0.09802 + DCW -6393 ; 34 0xe707 -0.19510 + DCW -9512 ; 35 0xdad8 -0.29028 + DCW -12540 ; 36 0xcf04 -0.38269 + DCW -15447 ; 37 0xc3a9 -0.47141 + DCW -18205 ; 38 0xb8e3 -0.55557 + DCW -20788 ; 39 0xaecc -0.63440 + DCW -23170 ; 40 0xa57e -0.70709 + DCW -25330 ; 41 0x9d0e -0.77301 + DCW -27246 ; 42 0x9592 -0.83148 + DCW -28899 ; 43 0x8f1d -0.88193 + DCW -30274 ; 44 0x89be -0.92389 + DCW -31357 ; 45 0x8583 -0.95694 + DCW -32138 ; 46 0x8276 -0.98077 + DCW -32610 ; 47 0x809e -0.99518 + DCW -32768 ; 48 0x8000 -1.00000 + DCW -32610 ; 49 0x809e -0.99518 + DCW -32138 ; 50 0x8276 -0.98077 + DCW -31357 ; 51 0x8583 -0.95694 + DCW -30274 ; 52 0x89be -0.92389 + DCW -28899 ; 53 0x8f1d -0.88193 + DCW -27246 ; 54 0x9592 -0.83148 + DCW -25330 ; 55 0x9d0e -0.77301 + DCW -23170 ; 56 0xa57e -0.70709 + DCW -20788 ; 57 0xaecc -0.63440 + DCW -18205 ; 58 0xb8e3 -0.55557 + DCW -15447 ; 59 0xc3a9 -0.47141 + DCW -12540 ; 60 0xcf04 -0.38269 + DCW -9512 ; 61 0xdad8 -0.29028 + DCW -6393 ; 62 0xe707 -0.19510 + DCW -3212 ; 63 0xf374 -0.09802 + + END \ No newline at end of file