• 首页
  • 文章
  • 论坛
  • 专题讨论
  • 在线问答
  • 资料下载
  • 广告
个人中心
瑞萨电子MCU社区论坛
  • DALI技术专题讨
  • 8位MCU
  • 16位MCU
  • 32位MCU
  • 工业控制
  • 通信设备
  • 汽车电子
  • 消费电子
首页 >>瑞萨电子MCU社区论坛 >>8位MCU 论坛规则 | 收藏本版 | RSS订阅
2 1/1 共1页 1
  • 发布新帖
  • 发布投票
  •        
哪位大侠帮忙看下这个uart0的串口程序啊
nust2010
精华:
0
积分:
9
等级:
学徒
登陆次数:
6 
发表帖子:
5 
注册时间:
2011-12-21 
最后登陆:
2012-03-18 
状态:
离线

查看详细资料


积分:9
帖子:5
精华:0
等级:学徒
注册时间:2011-12-21
最后登录:2012-03-18
我的博客 发短消息
我的相册 当前离线
发表于2011-12-30 16:13
1#
哪位大侠帮忙看下这个uart0的串口程序啊
波特率用的是115200,内部时钟8M,可是不通啊,哪位帅哥给点建议啊
#include "io78f0411.h"
#include "intrinsics.h"
#pragma location= 0x0080
__root const unsigned char optbyte[4]={0x7e,0x01,0x00,0x03}; //0x7e:看门狗定时器允许计数,窗口周期100%,看门狗的溢出时间选择了496.48ms,内部低速振荡时钟可由软件中止
//0x01:POCMODE模式选择2.7/1。59V模式
//0x00:0082H、0083H保留区域
//0x03:允许操作,在确定片上调试安全ID失效时可以擦除Flash存储器数据
typedef unsigned long u32;
typedef unsigned int u16;
typedef unsigned char u8;
unsigned char flag=0;
char TxStx[5]= {0x77,0x77,0x77,0x77,0x77};
char RxStx[5]={0x77,0x77,0x77,0x77,0x77};
unsigned int i=0;
unsigned int m=0;
void uart0_init(unsigned char br,unsigned char as)
{
BRGC0=br;
ASIM0=as;

PM1=0xf7;
PU1=0x04;
P1=0x04;
STIF0=0;
SRIF0=0;
STMK0=0;
SRMK0=0;
POWER0=0;
}
void uart0_en(void)
{
POWER0=1;
}
void uart0_dis(void)
{
POWER0=0;
}
void uart0_en_tx(void)
{
TXE0=1;
}
void uart0_dis_tx(void)
{
TXE0=0;
}
void uart0_en_rx(void)
{
RXE0 = 1;
}
void uart0_dis_rx(void)
{
RXE0 = 0;
}
void uart0_clr_tx_Int_F(void)
{
STIF0 = 0;
}
void uart0_clr_rx_Int_F(void)
{
SRIF0 = 0;
}
unsigned char uart0_read_State_Reg(void)
{
unsigned char byte;
byte=ASIS0;
return (byte);
}
void uart0_sendbyte(unsigned char byte)
{
TXS0=byte;
}
void uart0_sendstring(void)
{
while(m<5)
{
uart0_sendbyte(TxStx[i]);
while(STIF0==0);
STIF0=0;
m++;
}
}
unsigned char uart0_receivebyte(void)
{
unsigned char byte;
while(SRIF0==0);
if(0x00==uart0_read_State_Reg())
byte=RXB0;
else
byte=0xff;
SRIF0=0;
// i++;
return byte;
}
#pragma vector=INTSR0_vect
__interrupt void INTSR0_Server(void)
{
unsigned char rx_data;
rx_data=uart0_receivebyte();
if(i<5)
{
RxStx[i]=rx_data;
i++;
}
else if(i==5)
{
flag=1;
i=0;
}
// uart0_receivestring();
}
void init_cpu()
{
IMS=0x04;
IXS=0X0c;

OSCCTL=0x00;
MCM=0x00;
PCC=0x40;
MOC=0x80;
while(RSTS==0);
uart0_init(0x51,0x0d);
}
void watchdog(void)
{
WDTE=0xac;
}
void delay_10us(void)
{
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();
__no_operation();


}
void delay_500ms(void)
{
for(unsigned int i=0;i<50000;i++)
delay_10us();
}
void main()
{
__disable_interrupt();
asm("SEL RB0");
/*设置低电压检测复位,LIVM寄存器设置LVISEL、LVION、LVIF、LVIMD,还有屏蔽LVIMK中断位,还有用于设置
检测电压等级的LVIS
LVIon=1,低电压检测使能
LVIMK=1,屏蔽低电压检测产生的中断
LVISEL=0,检测供电电压VDD
LVIMD=1,产生复位信号
LVIS=0,产生电压登记,从4.24V下降
*/
LVION=0;
LVIMK=1;
LVISEL=0;
LVIMD=1;
LVIS=0;
delay_10us();
delay_10us();
delay_10us();
LVION=1;
delay_500ms();
watchdog();
while(LVIF==1);
watchdog();
init_cpu();
__enable_interrupt();
uart0_en();
uart0_en_rx();
uart0_en_tx();
while(1)
{
if(flag)
{
uart0_sendstring();
flag=0;
}
}
}
 
相关主题
...
回复 链接 收藏
 
nust2010
精华:
0
积分:
9
等级:
学徒
登陆次数:
6 
发表帖子:
5 
注册时间:
2011-12-21 
最后登陆:
2012-03-18 
状态:
离线

查看详细资料


积分:9
帖子:5
精华:0
等级:学徒
注册时间:2011-12-21
最后登录:2012-03-18
我的博客 发短消息
我的相册 当前离线
发表于2011-12-30 16:14
2#
RE:哪位大侠帮忙看下这个uart0的串口程序啊
自己顶一下,希望有人可以过来帮忙啊
 
...
回复 链接 收藏
 
2 1/1 共1页 1
  • 发布新帖
  • 发布投票
  •        
您尚未 登录 | 注册
© 2006-2012 与非门科技(北京)有限公司关于与非网 | 法律及版权声明 | 网站地图