中级会员
- 积分
- 285
- 威望
- 143
- 贡献
- 86
- 兑换币
- 87
- 注册时间
- 2012-11-8
- 在线时间
- 28 小时
|
代码没问题吧!!!8M
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include <MC9S12XS128.h>
void Sci_Init()
{
SCI0BD =52; //((16000000UL /* OSC fr.................eq */ / 2) / 9600 /* baud rate */ / 16 /*factor*/);
SCI0CR1=0x00; /*normal,no parity 一个起始位,8个数据位,1个停止位*/
SCI0CR2=0X2C; /*RIE=1,TE=1,RE=1*/
}
/*-------发射端程序----------------------*/
void Sci_Tx(char text)
{
while (!SCI0SR1_TDRE); /* wait for output buffer empty */
SCI0DRL=text;
}
void Sci_pwm_speed_s_send(int num)
{ unsigned char SCI_PWM_L,SCI_PWM_H;
SCI_PWM_L = (unsigned char)(num&0x00FF);//拆分低字节
SCI_PWM_H = (unsigned char)(num>>8); //拆分高字节
while(!SCI0SR1_TDRE); // 等待发送缓冲区非空
SCI0DRL = SCI_PWM_H; //发送高字节
while(!(SCI0SR1&0x80)); // 等待发送缓冲区非空
SCI0DRL = SCI_PWM_L; //发送低字节
}
|
|