欢迎来到天天文库
浏览记录
ID:56785432
大小:46.00 KB
页数:11页
时间:2020-07-11
《C8051F350单片机1602液晶显示程序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#include#include//-----------------------------------------------------------------------------//16-bitSFRDefinitionsfor'F35x//-----------------------------------------------------------------------------sfr16TMR2RL=0xCA;//Timer2reloadvaluesfr16T
2、MR2=0xCC;//Timer2countersfr16ADC0DEC=0x9A;//ADC0DecimationRatioRegister//sfr16ADC0=0xbd;//-----------------------------------------------------------------------------//GlobalCONSTANTS//-----------------------------------------------------------------------------#defineSYSCLK//SYSCLK
3、frequencyinHz#defineMDCLK//ModulatorclockinHz(idealis//(2.4576MHz)#defineOWR960//DesiredOutputWordRateinHzADC0输出字速率,最大960#defineBAUDRATE//BaudrateofUARTinbps#defineucharunsignedchar#defineuintunsignedint#defineDataPortP0sbitLCM_EN=P1^0;sbitLCM_RS=P1^1;unsignedcharD1,D2,D3,D4,D5,D6,D7
4、,D8;//sbitLED=P0^7;unsignedintk;//-----------------------------------------------------------------------------//FunctionPROTOTYPES//-----------------------------------------------------------------------------voidOscillator_Init(void);voidPort_Init(void);voidUART0_Init(void);voidADC
5、0_Init(void);voiddelay(inti);voidWriteCommandLCM(ucharCMD);voidWriteDataLCM(uchardataW);voidInitLcd();voidlcd_write_char(ucharx,uchary,uchardataW);//-----------------------------------------------------------------------------//MAINRoutine//-------------------------------------------
6、----------------------------------voidmain(void){PCA0MD&=~0x40;//WDTE=0(clearwatchdogtimer//enable)Oscillator_Init();//InitializesystemclockPort_Init();//InitializeCrossbarandGPIO//UART0_Init();//InitializeUART0forprintf'sInitLcd();ADC0_Init();//InitializeADC0AD0INT=0;ADC0MD=0x83;//S
7、tartcontinuousconversionsEA=1;//Enableglobalinterruptswhile(1){//Spinforever}}//-----------------------------------------------------------------------------//InitializationSubroutines//-----------------------------------------------------------------------------voiddelay(inti)//大概0.
8、43ms{intj,k;
此文档下载收益归作者所有