本程序是從國(guó)外一個(gè)論壇下載的用51單片機(jī)+dac0832 播放wav音樂(lè),音樂(lè)數(shù)據(jù)可以從串行輸入,如果聲音很小的話可以把數(shù)據(jù)接入功放的輸入端.完整的程序源代碼從這里下載http://www.51hei.com/f/waefd.rar下面是main文件:/***************************************************************name : main.cdesctiption : mp3 main file for testing serial portauthor : coolfireupdate : 6/17/07/***************************************************************/#include #include "compiler.h"#include "initinit.h"#include "bufferuffer.h"#include "serialserial.h"extern Uint32 wav_len_w;extern Uint32 wav_len_r;mode_t mode=download;void main(){init();loop: switch(mode){case idle:while(mode==idle);break;case download:while(mode==download){if(!wav_len_w)write_buffer(serial);read_buffer(flash);}break;case play:while(mode==play){if(!wav_len_r)write_buffer(flash);read_buffer(dac);}break;}goto loop;}
評(píng)論