欢迎来到天天文库
浏览记录
ID:34415324
大小:79.71 KB
页数:6页
时间:2019-03-05
《c8051f040的比较器程序new》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//-----------------------------------------------------------------------------//F04x_Comparator0_ResetSource.c//-----------------------------------------------------------------------------//Copyright2006SiliconLaboratories,Inc.//http://www.silabs.com////ProgramDescripti
2、on:////SiliconLaboratoriesMCUscanusedifferentmechanismstoresetthedevice.////ThissoftwareshowsthenecessaryconfigurationtouseComparator0as//aresetsource.Thecodeexecutestheinitializationroutinesandthen//spinsinaninfinitewhile()loop.IfthebuttononP1.6(onthetarget//board)ispres
3、sed,thenthecomparatorspostiveinput(CP0+)inputwilldrop//belowthecomparator'snegativeinput(CP0-).Whenthishappens,//Comparator0willcausethedevicetobereset.////Whenthecodeiswaitingforthebuttontobepressed,theLEDison.////Uponeverydevicereset,thecodecheckstheRSTSRCregistertodete
4、rmine//ifthelastresetwasduetoacomparatorreset.Ifitwasa//comparatorreset,thecodewillblinktheLEDconstantly.////HowToTest:////1)Compileanddownloadcodetoa'F04xtargetboard//2)Onthetargetboard,connectP2.6toP3.7andP2.7toP1.6//3)RunthecodeandverifythattheLEDison//4)PresstheP3.7sw
5、itch(thiscausesacomparatorreset)//5)VerifythattheLEDisblinking//////FID:04X000003//Target:C8051F04x//Toolchain:KeilC517.50/KeilEVALC51//CommandLine:None//////Release1.0//-InitialRevision(GP)//-17MAY2006////------------------------------------------------------------------
6、-----------//IncludeFiles//-----------------------------------------------------------------------------#include//-----------------------------------------------------------------------------//GlobalConstants//-------------------------------------------------
7、----------------------------#defineSYSCLK24500000//ClockspeedinHz#defineCOMPARATOR_SETTLE10//SettletimeinussbitLED=P1^6;//GreenLedsbitSWITCH=P3^7;//Push-buttonswitchonboard//-----------------------------------------------------------------------------//FunctionPrototypes/
8、/-----------------------------------------------------------------------------voidOSCILLATOR_Ini
此文档下载收益归作者所有