网站大量收购独家精品文档,联系QQ:2885784924

MC9S12XS128 串口操作例程.doc

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
MC9S12XS128 串口操作例程

MC9S12XS128 串口操作例程 Code Warrior 4.7 Target : MC9S12XS128 Crystal: 16.000Mhz busclock: 8.000MHz pllclock:16.000MHz 本程序主要包括以下功能: 1.设置锁相环和总线频率; 2.IO口使用; 3.共四路ATD使用及显示方法。 LED计数,根据灯亮可以读取系统循环了多少次 *****************************************************************************************/ #include hidef.h????? /* common defines and macros */ #include MC9S12XS128.h???? /* derivative information */ #include ctype.h #include string.h #include stdarg.h #pragma LINK_INFO DERIVATIVE mc9s12xs128 #pragma CODE_SEG DEFAULT #define CR_as_CRLF? TRUE???????????? // if true , you can use \n to act as CR/LF, ???????????????????????????????????? // if false, you have to use \n\r,but can get a higher speed? static int do_padding; static int left_flag; static int len; static int num1; static int num2; static char pad_character; unsigned char uart_getkey(void) {? ?? while(!(SCI0SR10x80)) ; ?? //keep waiting when not empty? ?? return SCI0DRL; } /* void uart_init(void) { ? SCI0CR2=0x0c; ? SCI0BDH=0x00;//16MHz,19200bps,SCI0BDL=0x1a ? SCI0BDL=0x34;//16MHz,9600bps,SCI0BDL=0x34 } */ void uart_putchar(unsigned char ch) { ? if (ch == \n)? ? { ????? while(!(SCI0SR10x80)) ;???? ????? SCI0DRL= 0x0d;?????? ???? //outputCR ???? return; ? } ? while(!(SCI0SR10x80)) ; ????? //keep waiting when not empty? ? SCI0DRL=ch; } void putstr(char ch[]) { ? unsigned char ptr=0; ? while(ch[ptr]){ ????? uart_putchar((unsigned char)ch[ptr++]); ? }???? ? } ???????????????????????????????????????????????? static void padding( const int l_flag) { ?? int i; ?? if (do_padding l_flag (len num1)) ????? for (i=len; inum1; i++) ????????? uart_putchar( pad_character); } static void outs( char* lp) { ? /* pad on left if needed????????????????????????? */ ? len = strlen( lp); ? padding( !left_flag); ? /* Move string to the buffer????????????????????? */ ? while (*lp num2--)? uart_putchar( *lp++); ? /* Pad on right if needed???????????????????????? */ ? len = strlen( lp); ? padding( left_flag); } static void reoutnum(unsigned long

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档