📄 f2812 fft 源程序 ti例程 - 21ic中国电子网.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://www.21ic.com/news/n7160c81.aspx -->
<HTML lang=gb2312 xmlns="http://www.w3.org/1999/xhtml" xmlns:o =
"urn:schemas-microsoft-com:office:office"><HEAD><TITLE>F2812 fft 源程序 TI例程 - 21IC中国电子网</TITLE>
<META http-equiv=content-type content=text/html;charset=gb2312><LINK
href="favicon.ico" type=image/x-icon rel=icon><LINK href="favicon.ico"
type=image/x-icon rel="shortcut icon">
<META content="F2812 fft 源程序 TI例程" name=description>
<META content=21IC.com name=keywords><LINK
href="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/style.css" type=text/css
rel=stylesheet>
<SCRIPT src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/flash.js"
type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
var thumbWidth=120;var thumbHeight=0;
var thumbHWidth=thumbWidth;var thumbHHeight=thumbHeight;
</SCRIPT>
<SCRIPT src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/thumbnail.js"
type=text/javascript></SCRIPT>
<SCRIPT language=javaScript src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/scroll.js"
type=text/javascript></SCRIPT>
<SCRIPT language=javaScript
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/imgResize.js"
type=text/javascript></SCRIPT>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY><SPAN id=printScript>
<SCRIPT language=javascript type=text/javascript>
<!--
function ContentSize(size)
{
var obj=document.all.BodyLabel;
obj.style.fontSize=size+"px";
}
-->
</SCRIPT>
</SPAN>
<SCRIPT language=javascript src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/print.js"
type=text/javascript></SCRIPT>
<TABLE id=navbar cellSpacing=0 cellPadding=0 align=center>
<TBODY>
<TR>
<TD class=l></TD>
<TD class=m>
<SCRIPT language=javascript1.2
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/popmenu.js"
type=text/javascript></SCRIPT>
<SPAN id=dlSortNav><SPAN><A href="http://21ic.com/">首页</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A
href="http://www.21ic.com/news/html/8/list1.htm">新闻</A> </SPAN><SPAN><IMG
alt="" src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,29,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c29.aspx">应用</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,26,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c26.aspx">新品</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,27,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c27.aspx">市场</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,28,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c28.aspx">专访</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,5,1,false)
onmouseout=delayhidemenu()
href="http://www.21ic.com/news/html/5/list1.htm">人才</A> </SPAN><SPAN><IMG
alt="" src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,62,1,false)
onmouseout=delayhidemenu()
href="http://www.21ic.com/news/html/62/list1.htm">下载</A> </SPAN><SPAN><IMG
alt="" src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,2,1,false)
onmouseout=delayhidemenu() href="http://21icsearch.com/">资料(PDF)</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,31,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c31.aspx">活动</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,7,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c7.aspx">厂商</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A href="http://kucun.21ic.com/">库存</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,4,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c4.aspx">热卖</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A href="http://www.21icbbs.com/">社区</A>
</SPAN><SPAN><IMG alt=""
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/navbar_separator.gif"
align=absMiddle> </SPAN><SPAN><A onmouseover=showmenu(event,41,1,false)
onmouseout=delayhidemenu() href="http://www.21ic.com/news/c41.aspx"
target=_blank>专题</A> </SPAN></SPAN></TD>
<TD class=r></TD></TR></TBODY></TABLE>
<TABLE id=navsub cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD class=l></TD>
<TD class=m> <A
href="http://www.21ic.com/news/default.aspx">21IC中国电子网</A> → <A
href="http://www.21ic.com/news/c62.aspx">下载</A> → <A
href="http://www.21ic.com/news/c81.aspx">DSP</A> </TD>
<TD class=r></TD></TR></TBODY></TABLE>
<DIV class=mframe>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD class=tl></TD>
<TD class=tm><SPAN class=tt>详文</SPAN> </TD>
<TD class=tr></TD></TR></TBODY></TABLE>
<DIV id=printBody>
<TABLE id=middle
style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all; TEXT-ALIGN: left"
cellSpacing=0 cellPadding=0 align=center>
<TBODY>
<TR>
<TD class=ml></TD>
<TD class=mm vAlign=top><BR>
<DIV align=center>
<H1 class=aTitle>F2812 fft 源程序 TI例程</H1></DIV>
<TABLE width="97%" align=center>
<TBODY>
<TR>
<TD width=120>[日期:<SPAN id=TimeLabel>2005-4-18</SPAN>]</TD>
<TD align=middle>来源:<SPAN id=SourceLabel></SPAN> 作者:<SPAN
id=AuthorLabel>网友推荐</SPAN></TD>
<TD align=right width=100>[字体:<A
href="javascript:ContentSize(16)">大</A> <A
href="javascript:ContentSize(14)">中</A> <A
href="javascript:ContentSize(12)">小</A>] </TD></TR></TBODY></TABLE>
<DIV class=content id=BodyLabel
style="PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"><!--DVNEWS_AD_BEGIN--><A
href="http://wwwd.national.com/event/SignalPathChinaB.nsf/Registration?OpenForm"
target=_blank><IMG onmousewheel="return bbimg(this)"
style="BORDER-LEFT-COLOR: #ffffff; FILTER: ; BORDER-BOTTOM-COLOR: #ffffff; BORDER-TOP-COLOR: #ffffff; BORDER-RIGHT-COLOR: #ffffff"
onclick=ImgClick(this) alt="" hspace=6
src="F2812 fft 源程序 TI例程 - 21IC中国电子网.files/news_banner.gif" align=left
border=10 resized="0"></A> <!--DVNEWS_AD_END-->
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><STRONG><SPAN
style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></STRONG><STRONG><SPAN
lang=EN-US
style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; COLOR: #333333"><o:p></o:p></SPAN></STRONG> </P><SPAN
lang=EN-US
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">/**************************************************************/
<BR>/* */ <BR>/* fft.c */ <BR>/* */
<BR>/**************************************************************/
<BR><BR>/* <BR>Fast Fourier Transform (FFT). <BR>Using 8 points, takes
about 1.2 ms to execute one FFT. <BR>Sets up General Purpose Timer 1 to
generate events at 10 kHz. <BR>Will produce 10 kHz output on T1PWM and
T1PWM pins. <BR>*/ <BR><BR>#include "system.h" <BR>#include "eva.h"
<BR>#include "io2407.h" <BR>#include "adc.h" <BR>#include "interrup.h"
<BR><BR>#include "fftcmplx.h" /* Complex structure definition*/
<BR><BR>extern void FFT(COMPLEX *Y, int N); /* FFT Function */ <BR><BR>/*
The following define gives the number of samples. */ <BR>/* It should
divide exactly into 512 */ <BR>/* Should N be increased, to say to 32,
then the execution */ <BR>/* time of the FFT would increase */
<BR><BR>#define N 8 <BR><BR>unsigned int perform_fft = 0; /* Flag driven
by interrupt */
<BR><BR>/*************************************************************/
<BR>/* <BR>Initialise General Purpose Timers GPT1 and GPT2 <BR>*/
<BR>/*************************************************************/
<BR><BR>/* Initialise General Purpose Timer 1. */ <BR><BR>void
init_GPT1(void) <BR>{ <BR>MCRA |= T1PWM; /* Turn on T1PWM */ <BR>T1CON =
0x8142; /* Turn off GPT1 */ <BR>GPTCONA = 0x0041; /* Active low. */
<BR>T1PR = 1475; /* Sample at 10 kHz */ <BR>T1CMPR = 0; /* Duty = 0% */
<BR>T1CNT = 0xFFFE; /* Set to -2 */ <BR>T1CON = 0x9142; /* Start timer 1
*/ <BR><BR>EVAIFRA = 0xFFFF; /* Clear any pending interrupts */
<BR>EVAIMRA |= T1PINT_FLAG; /* Enable T1 period interrupt */ <BR>}
<BR><BR>/* Initialise General Purpose Timer 2 */ <BR><BR>void
init_GPT2(void) <BR>{ <BR>MCRA |= T2PWM; /* Turn on T2PWM */ <BR>T2CON =
0x8142; /* Turn off GPT2 */ <BR>GPTCONA |= 0x0008; /* Controlled from GPT1
*/ <BR>T2PR = 1475; /* Sample at 10 kHz */ <BR>T2CMPR = 0; /* Duty cycle
0% decimal */ <BR>T2CNT = 0xFFFE; /* Set to -2 */ <BR>T2CON = 0x9142; /*
Start timer 2 */ <BR>}
<BR><BR>/**************************************************************/
<BR><BR>void init_ADC() <BR>{ <BR>/* Non Cascade for 8 measurements. */
<BR>/* Will affect RESULT0 to RESULT7 only */ <BR><BR>ADCCTRL1 = (ADC_SOFT
| ADC_CPS /*| ADC_ACQ_PS3 | ADC_ACQ_PS2*/ ); <BR><BR>CHSELSEQ1 = 0x3210;
/* 8 measurements 0 */ <BR>CHSELSEQ2 = 0x0000; <BR>CHSELSEQ3 = 0xFFFF;
<BR>CHSELSEQ4 = 0xFFFF; <BR>MAX_CONV = 0x0007; /* 8 measurements, not 0 */
<BR><BR>/* Reset sequence at zero and software start of conversion */
<BR><BR>ADCCTRL2 = ( RST_SEQ1 | SOC_SEQ1); <BR><BR>} /* No semicolon here
*/ <BR><BR>/***********************************************************/
<BR><BR>int input_buffer[N] = {8191, 8191, 8191, 8191, 0, 0, 0, 0};
<BR><BR>COMPLEX y[N]; /* Variable passed to FFT and modified */
<BR><BR>/***********************************************************/
<BR>/* <BR>Shuffle input buffer along one place. <BR>Put latest input from
ADC into first buffer location. <BR>Input from ADCIN2 lies in range 0 to
FFC0h (65472 decimal). <BR>Divide by 8 to limit range from 0 to 8184.
<BR>*/ <BR>/***********************************************************/
<BR><BR>void shuffle_and_read(void) <BR>{ <BR>signed int i; <BR><BR>for (
i = N-1 ; i > 0 ; i--) <BR>{ <BR>input_buffer[i] = input_buffer[i-1];
<BR>} <BR><BR>input_buffer[0] = (RESULT2 >> 3); <BR>}
<BR><BR>/***********************************************************/
<BR>/* <BR>Copy from input buffer to complex structure. <BR>When FFT is
performed, the complex structure is overwritten <BR>by the return values.
<BR>*/ <BR>/***********************************************************/
<BR><BR>void copy_input_to_complex(void) <BR>{ <BR>unsigned int i;
<BR><BR>for ( i = 0 ; i < N; i++) <BR>{ <BR>(y[i]).real =
input_buffer[i]; <BR>(y[i]).imag = 0; <BR>} <BR>}
<BR><BR>/***********************************************************/
<BR>/* <BR>Main program <BR>Uses timers to read analog input on ADCIN2
into a buffer <BR>and then perform an 8-point FFT on it. <BR>*/
<BR>/**********************************************************/
<BR><BR>void main(void) <BR>{ <BR>signed int output1, output2; <BR>signed
int x; /* General purpose variable. */ <BR>signed int i; /* Counter */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -