直接测量微控制器总线时钟的程序

2012-08-29 10:34:01   来源:21ic   

关键字: 测量  微控制器  总线时钟

|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->|| window.event; var mousePos = mouseCoords(ev); xpos = mousePos.x; ypos = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop }; } function getPos(elem) { var offsetY=elem.offsetTop; var offsetX=elem.offsetLeft; while(elem.offsetParent!=null) { elem = elem.offsetParent; offsetY+=elem.offsetTop; offsetX+=elem.offsetLeft; } return [offsetX,offsetY]; } /* display company keywords. */ var companyAdEvent = {}; companyAdEvent.firstShow = true; companyAdEvent.show = function(ele,recId,offset){ //var eP = companyAdEvent.getPosition(ele); if(!offset) offset = [0,0]; clearTimeout(this.outEvent); if (this.firstShow) { var pos = getPos(ele); xpos = pos[0]; ypos = pos[1]; this.firstShow = false; this.outEvent = setTimeout(function(){ $(recId).style.display="none"; },3000); } $(recId).setStyle({ "left":(xpos+offset[0])+"px", "top":(ypos+offset[1])+"px", display:"block" }); xpos = 0; ypos = 0; } companyAdEvent.getPosition = function(tag){ var Position = [0,0]; while (tag) { tn = tag.tagName.toUpperCase(); Position[0] += tag.offsetLeft; Position[1] += tag.offsetTop; if(tn == "BODY") break; tag = tag.offsetParent; } return Position; } companyAdEvent.showCompanyAd = function(){ clearTimeout(this.outEvent); } companyAdEvent.out = function(recId){ companyAdEvent.outEvent = setTimeout(function(){ $(recId).setStyle({ display:"none" }); },100); } //-->

  飞思卡尔(Freescale)公司的HC08与最新HCS08微控制器系列都是多功能的外设模块。它们使用的时钟发生器也没有特殊之处,可以是内部时钟(省出了I/O脚),也可以是外接晶体或振荡器。一旦选定了时钟源,就有多种选择控制最终的总线频率。例如,为MC9S08GB微控制器连接一个32768Hz晶体就可以使用FLL(锁频环)生成高达18.874MHz的多个总线频率。选择时钟源、分频器和FLL设置固然能实现多功能性,但也带来了复杂性。

表1


  一旦编写完总线时钟初始化例程,可能希望先验证一下总线是否确实以期望的速度运行,然后再进入项目的其它部分。本设计实例的例程,可在任何I/O端口输出一个精确等于1/10总线速度的方波(表1与表2)。只要在这个端口连接一台频率计数器,就可以显示出总线频率。所要做的只是将小数点向右移动一位。一旦验证了总线速度,就能很有信心地去编写定时器、串行I/O和其它依赖于时钟的例程了。

  需要编写的代码只是先禁止中断和禁止COP(公共片上处理器)。在总线时钟初始化例程中,要确保将准备使用的I/O端口初始化为输出。然后,直接跳转到触发时钟,它会一直输出除10后的总 线频率,直到断电为止。本设计实例使用了HC08版的PB0端口(表1)和HCS08版的PD0端口(表2)。可以使用任何一个可用的I/O端口,只要修改设定端口的第一行代码,以及选择一个位的第二行代码。另外,本设计实例用老的PB标识作端口命名,而不是今天更流行的PTB。

本网站转载的所有的文章、图片、音频视频文件等资料的版权归版权所有人所有,本站采用的非本站原创文章及图片等内容无法一一联系确认版权者。如果本网所选内容的文章作者及编辑认为其作品不宜公开自由传播,或不应无偿使用,请及时通过电子邮件或电话通知我们,以迅速采取适当措施,避免给双方造成不必要的经济损失。