Objectif 2 DFT en réel : En cours

This commit is contained in:
Cavailles Kevin 2020-05-14 10:52:03 +02:00
parent 3368286817
commit d1081eb58d
5 changed files with 123 additions and 107 deletions

View file

@ -157,9 +157,9 @@
<Bp> <Bp>
<Number>0</Number> <Number>0</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>59</LineNumber> <LineNumber>29</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>134218250</Address> <Address>134227768</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
@ -168,23 +168,55 @@
<BreakIfRCount>1</BreakIfRCount> <BreakIfRCount>1</BreakIfRCount>
<Filename>.\Src\calcul_dft.s</Filename> <Filename>.\Src\calcul_dft.s</Filename>
<ExecCommand></ExecCommand> <ExecCommand></ExecCommand>
<Expression>\\CHTI\Src/calcul_dft.s\59</Expression> <Expression>\\CHTI\Src/calcul_dft.s\29</Expression>
</Bp> </Bp>
<Bp> <Bp>
<Number>1</Number> <Number>1</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>28</LineNumber> <LineNumber>42</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>134218196</Address> <Address>134227652</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <BreakIfRCount>1</BreakIfRCount>
<Filename>.\Src\calcul_dft.s</Filename> <Filename>.\Src\principal.c</Filename>
<ExecCommand></ExecCommand> <ExecCommand></ExecCommand>
<Expression>\\CHTI\Src/calcul_dft.s\28</Expression> <Expression>\\CHTI\Src/principal.c\42</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>37</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134227626</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Src\principal.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\CHTI\Src/principal.c\37</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>62</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\Src\principal.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp> </Bp>
</Breakpoint> </Breakpoint>
<WatchWindow1> <WatchWindow1>
@ -203,7 +235,7 @@
<Mm> <Mm>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<SubType>10</SubType> <SubType>10</SubType>
<ItemText>0x08001F30</ItemText> <ItemText>0x20000250</ItemText>
<AccSizeX>0</AccSizeX> <AccSizeX>0</AccSizeX>
</Mm> </Mm>
</MemoryWindow1> </MemoryWindow1>
@ -348,18 +380,6 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Src\signal.s</PathWithFileName>
<FilenameWithoutPath>signal.s</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>

View file

@ -338,7 +338,7 @@
<MiscControls>--C99</MiscControls> <MiscControls>--C99</MiscControls>
<Define>STM32F103xB,USE_FULL_LL_DRIVER</Define> <Define>STM32F103xB,USE_FULL_LL_DRIVER</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\GASSP72</IncludePath> <IncludePath>../GFSSP72</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@ -417,11 +417,6 @@
<FileType>2</FileType> <FileType>2</FileType>
<FilePath>.\Src\table_sin_cos.s</FilePath> <FilePath>.\Src\table_sin_cos.s</FilePath>
</File> </File>
<File>
<FileName>signal.s</FileName>
<FileType>2</FileType>
<FilePath>.\Src\signal.s</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>

View file

@ -4,6 +4,7 @@
export calcul_dft export calcul_dft
import TabCos import TabCos
import TabSin import TabSin
; ;

View file

@ -1,18 +1,94 @@
#include "gassp72.h" #include "gassp72.h"
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#define taille 6
#define SYSTICK_PER 360000 // (360000 ticks équivaut à 5ms)
extern void timer_callback(void);
extern short TabSig[]; extern short TabSig[];
int etat = 0x00020000; int etat = 0x00020000;
extern int calcul_carre(int); extern int calcul_carre(int);
extern int calcul_dft(short *, int); extern int calcul_dft(unsigned short *, int);
int res_dft[64];
int res_dft = 0;
unsigned short dma_buf[64];
int compteurs[taille];
int scores[taille];
int k_values[] = {17,18,19,20,23,24};
int M2TIR = 985507;
void checkCounter(void){
for(int i=0; i<taille; i++) {
if(compteurs[i] == 13){
compteurs[i]=0;
scores[i]++;
}
}
}
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<taille; i++){
res_dft = calcul_dft(dma_buf, k_values[i]);
if(res_dft > M2TIR){
compteurs[i]++;
}else{
compteurs[i] = 0;
}
}
checkCounter();
}
int main(void) int main(void)
{ {
for(int k=0; k<64; k++){ for(int i=0; i<6; i++){
res_dft[k] = calcul_dft(TabSig,k); compteurs[i] = 0;
scores[i] = 0 ;
} }
// activation de la PLL qui multiplie la fréquence du quartz par 9
CLOCK_Configure();
// PA2 (ADC voie 2) = entrée analog
GPIO_Configure(GPIOA, 2, INPUT, ANALOG);
// PB1 = sortie pour profilage à l'oscillo
GPIO_Configure(GPIOB, 1, OUTPUT, OUTPUT_PPULL);
// PB14 = sortie pour LED
GPIO_Configure(GPIOB, 14, OUTPUT, OUTPUT_PPULL);
// 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){
}
} }

View file

@ -1,76 +0,0 @@
AREA Signal, DATA, READONLY
export TabSig
; fonction cosinus, frequence relative 1, phase -45 degres, amplitude max
; valeurs attendues pour k = 1 :
; Re 0x5A82562C env +sqrt(0.5) * 2^31
; Im 0x5A82562C env +sqrt(0.5) * 2^31
; M2 0x3FFFCDE5 env 2^30
; pour 1 < k < 63
; M2 < 0x0000000F
TabSig
dcw 0x0da8 ; 0 3496 0.85352
dcw 0x0e2f ; 1 3631 0.88647
dcw 0x0ea7 ; 2 3751 0.91577
dcw 0x0f0e ; 3 3854 0.94092
dcw 0x0f64 ; 4 3940 0.96191
dcw 0x0fa8 ; 5 4008 0.97852
dcw 0x0fd9 ; 6 4057 0.99048
dcw 0x0ff6 ; 7 4086 0.99756
dcw 0x0fff ; 8 4095 0.99976
dcw 0x0ff6 ; 9 4086 0.99756
dcw 0x0fd9 ; 10 4057 0.99048
dcw 0x0fa8 ; 11 4008 0.97852
dcw 0x0f64 ; 12 3940 0.96191
dcw 0x0f0e ; 13 3854 0.94092
dcw 0x0ea7 ; 14 3751 0.91577
dcw 0x0e2f ; 15 3631 0.88647
dcw 0x0da8 ; 16 3496 0.85352
dcw 0x0d13 ; 17 3347 0.81714
dcw 0x0c72 ; 18 3186 0.77783
dcw 0x0bc5 ; 19 3013 0.73560
dcw 0x0b10 ; 20 2832 0.69141
dcw 0x0a53 ; 21 2643 0.64526
dcw 0x0990 ; 22 2448 0.59766
dcw 0x08c9 ; 23 2249 0.54907
dcw 0x0800 ; 24 2048 0.50000
dcw 0x0737 ; 25 1847 0.45093
dcw 0x0670 ; 26 1648 0.40234
dcw 0x05ad ; 27 1453 0.35474
dcw 0x04f0 ; 28 1264 0.30859
dcw 0x043b ; 29 1083 0.26440
dcw 0x038e ; 30 910 0.22217
dcw 0x02ed ; 31 749 0.18286
dcw 0x0258 ; 32 600 0.14648
dcw 0x01d1 ; 33 465 0.11353
dcw 0x0159 ; 34 345 0.08423
dcw 0x00f2 ; 35 242 0.05908
dcw 0x009c ; 36 156 0.03809
dcw 0x0058 ; 37 88 0.02148
dcw 0x0027 ; 38 39 0.00952
dcw 0x000a ; 39 10 0.00244
dcw 0x0000 ; 40 0 0.00000
dcw 0x000a ; 41 10 0.00244
dcw 0x0027 ; 42 39 0.00952
dcw 0x0058 ; 43 88 0.02148
dcw 0x009c ; 44 156 0.03809
dcw 0x00f2 ; 45 242 0.05908
dcw 0x0159 ; 46 345 0.08423
dcw 0x01d1 ; 47 465 0.11353
dcw 0x0258 ; 48 600 0.14648
dcw 0x02ed ; 49 749 0.18286
dcw 0x038e ; 50 910 0.22217
dcw 0x043b ; 51 1083 0.26440
dcw 0x04f0 ; 52 1264 0.30859
dcw 0x05ad ; 53 1453 0.35474
dcw 0x0670 ; 54 1648 0.40234
dcw 0x0737 ; 55 1847 0.45093
dcw 0x0800 ; 56 2048 0.50000
dcw 0x08c9 ; 57 2249 0.54907
dcw 0x0990 ; 58 2448 0.59766
dcw 0x0a53 ; 59 2643 0.64526
dcw 0x0b10 ; 60 2832 0.69141
dcw 0x0bc5 ; 61 3013 0.73560
dcw 0x0c72 ; 62 3186 0.77783
dcw 0x0d13 ; 63 3347 0.81714
end