新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > FFT算法在單片機(jī)中的使用&&LCD12864驅(qū)動(dòng)

FFT算法在單片機(jī)中的使用&&LCD12864驅(qū)動(dòng)

作者: 時(shí)間:2016-11-30 來源:網(wǎng)絡(luò) 收藏

void initw(); //初始化旋轉(zhuǎn)因子

void bitReverse(); //比特反轉(zhuǎn)

void FFT();

complex x[N];

uchar vis[N];

void delayms(uint ms)

{

uint i,j;

for(i=0;i{

for(j=0;j<3;j++);

}

}

//此處定義字符串

//寫數(shù)據(jù)

void WriteDataLCM(unsigned char WDLCM) //寫數(shù)據(jù)函數(shù)

{

// ReadStatusLCM(); //檢測忙

delayms(1);

PORTA|=RS; //RS=1

delayms(1);

PORTA&=~RW; //RW=0

delayms(1);

PORTA|=EN; //EN=1

delayms(1);

PORTB=WDLCM; //輸出數(shù)據(jù)

delayms(1);

PORTA&=~EN; //EN=0

delayms(1);

}

//寫指令

void WriteCommandLCM(unsigned char WCLCM) //寫命令函數(shù)

{

// ReadStatusLCM(); //根據(jù)需要檢測忙

delayms(1);

PORTA&=~RS; //RS=0

delayms(1);

PORTA&=~RW; //RW=0

delayms(1);

PORTA|=EN; //EN=1

delayms(1);

PORTB=WCLCM; //輸出指令

delayms(1);

PORTA&=~EN; //EN=0

delayms(1);

}

//讀狀態(tài):檢測忙

void ReadStatusLCM() //讀狀態(tài)函數(shù)

{

uchar temp;

uchar flag = 1;

while(flag==1)

{

PORTB=0xff;

delayms(1);

DDRB=0x00; //端口B改為輸入

delayms(1);

PORTA&=~RS; //RS=0

delayms(1);

PORTA|=RW; //RW=1

delayms(1);

PORTA|=EN; //EN=1

delayms(10);

temp = PINB; //讀端口B

delayms(10);

DDRB=0xff; //端口B改為

delayms(10);

PORTA&=~EN; //EN=0

delayms(1);

if(temp>>7==0)

flag = 0;

}

}

uchar read_data() //讀數(shù)據(jù)函數(shù)

{

uchar lcd_data;

PORTB=0xff;

DDRB=0x00;

PORTA|=RW;

PORTA|=RS;

delayms(10);

PORTA|=EN;

delayms(10);

lcd_data=PINB;

delayms(10);

PORTA&=~EN;

DDRB=0xff;

return(lcd_data) ;

}

void point(uchar x,uchar y) //打點(diǎn)函數(shù),最重要的函數(shù),GUI的基礎(chǔ)

{

uchar x_Dyte,x_byte;

uchar y_Dyte,y_byte;

uchar GDRAM_hbit,GDRAM_lbit;

WriteCommandLCM(0x36);

x_Dyte=x/16;

x_byte=x&0x0f;

y_Dyte=y/32;

y_byte=y&0x1f;

WriteCommandLCM(0x80+y_byte);

WriteCommandLCM(0x80+x_Dyte+8*y_Dyte);

read_data();

GDRAM_hbit=read_data();

GDRAM_lbit=read_data();

delayms(10);

WriteCommandLCM(0x80+y_byte);

WriteCommandLCM(0x80+x_Dyte+8*y_Dyte);

delayms(10);

if(x_byte<8)

{

WriteDataLCM(GDRAM_hbit|(0x01<<(7-x_byte)));

WriteDataLCM(GDRAM_lbit);

}

else

{

WriteDataLCM(GDRAM_hbit);

WriteDataLCM(GDRAM_lbit|(0x01<<(15-x_byte)));

}

WriteCommandLCM(0x30);

}

//LCM初始化

void LCMInit(void)

{

WriteCommandLCM(0x30); //三次顯示模式設(shè)置,不檢測忙信號

delayms(10);

WriteCommandLCM(0x30);

delayms(10);

WriteCommandLCM(0x30);

delayms(10);

WriteCommandLCM(0x30); //顯示模式設(shè)置,開始要求每次檢測忙信號

WriteCommandLCM(0x08); //關(guān)閉顯示

WriteCommandLCM(0x01); //顯示清屏

WriteCommandLCM(0x06); //顯示光標(biāo)移動(dòng)設(shè)置

WriteCommandLCM(0x0C); //顯示開及光標(biāo)設(shè)置

}



評論


技術(shù)專區(qū)

關(guān)閉