智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 19878|回复: 16
打印 上一主题 下一主题

[软件类] spi双机通讯的程序问题

[复制链接]

35

主题

168

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1215
威望
416
贡献
249
兑换币
22
注册时间
2009-9-10
在线时间
275 小时
1#
发表于 2009-11-15 17:36:19 | 显示全部楼层
通过串口,在pc机上得不到正确的数据,这是为什么啊 请指教



#include <hidef.h>      /* common defines and macros */
#include <MC9S12XS128.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"



/*************锁相环******************/
void PLL_Init(void){
  //锁相环设置:频率40M
         SYNR=0x49;
         REFDV=0x43;
         while(CRGFLG_LOCK!=1);
         CLKSEL_PLLSEL=1;
}
/***********************************/
void uart_Init(void) {    //40MHZ  波特率9600   8位无校验。
  SCI0CR2=0x0c;
  SCI0BD=0x104;

    SCI0CR2_RIE=0;

}

void uart_sendchar(char *cs) {  //单字符发送函数
  while(SCI0SR1_TDRE==0);
  SCI0DRL=*cs;
}

void uart_sendstring(char *ss){  //字符串发送函数
  while(*ss){
    uart_sendchar(ss);
    ++ss;
  }
}
//***********************************************

void main(void) {
  PLL_Init();
  uart_Init();
  DisableInterrupts;

  uart_sendstring("Hello World!");
   
  for(;;) {} /* wait forever */
  /* please make sure that you never leave this function */
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关于我们|联系我们|小黑屋|亿加合和智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-5-6 21:18 , Processed in 0.056876 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表