使用E8ax先把程序当入R5F212B里,然后去除E8a连线,连接电源和PC机串口,无论是超级终端或者串口工具,上电后均无反应!
我是负责软件部分的。请哪位大侠帮忙分析问题出在哪?是否要把PD1_6清零,然后把CKDIR设为1接外部时钟?先谢了!
#include "sfr_r82b.h"
void Initial(void);
void UART1_SendByte();
void UART1_ReceiveByte();
unsigned int recevie_data;
void UART1_SendByte(unsigned char ch) //UART1 transmite
{
ti_u1c1 =0;
u1tb = ch;
while(!ti_u1c1);
ti_u1c1 =0;
}
void UART1_ReceiveByte(void) //UART1 receive
while(!ri_u1c1);
if(ri_u1c1)
{
ri_u1c1 = 0;
recevie_data = u1rb;
p2 = recevie_data;
}
}
void main(void)
{
Initial();
UART1_SendByte('a');
while(1)
{
UART1_ReceiveByte();
}
}
void Initial(void)
{
unsigned char i,j,temp;
asm(" fclr i"); //i=0,disable global interrupt
prc0 = 1; //enable configre oscillator mode
fra0 = 0b00000011;//internal high oscillator start
cm13=1;//xin-xout oscillator
cm10=0;
cm07=0;
cm06=0;
cm16=0;//main oscillator no prescaler
cm17=0;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
cm05=0;
ocd2=0;
prc0 = 0;//inhibit
//I/O direction,'1'=output, '0'=input
prcr |= 0b00000100;//prcr.2=1,enable port direction configuration
p0 = 0b00000000;
pd0 = 0b11111111;//LCD-data0-7
p1 = 0b00000000;
pd1 = 0b11011111;//QUIT DA RXD TXD CLK DROP Dog-1 KEYI1
p2 = 0b00000000;
pd2 = 0b11111111;//CLKD6 CLKD5 CLKD4 CLKD3 CLKD2 CLKD1 DAT1 DAT2
p2drr= 0b11111111;//Port2 drive capacity register.'1'=High,'0'=Low
p3 = 0b00000000;
pd3 = 0b00001111;//NC NC NC NC NC key_line3 key_line2 key_line1
p4 = 0b00000000;
pd4 = 0b00111000;//XOUT XIN NC DAT3 NC NO NO NO
p5 = 0b00000000;
pd5 = 0b00011001;//NO NO NO STCP SHCP key2_in key1_in CLKD7
p8 = 0b00000000;
pd8 =0b11111000; //NC R/D CLKD0 NC NC KEY3 KEY2 KEY1
//------------------------------------------------------------------------------------------
u1pinsel = 1; // enable UART1
p6 = 0b00000000;
pd6 &= 0x79; //0|1|1|1|1|0|0|1 ;p6_6 Txd1 output,p6_7 Rxd1 Input
u1mr = 0x05; // 8 bits;1 stop bit;disable parity
u1c0 = 0x00; //uart1 select f1
u1c1 =0x00; //disable transimit.receive.continuous receive
u1brg = 77; // 9600 bits = 12MHz/16*(brg+1)
s1tic = 0x05; // uart1 TI interrupt level 5
s1ric = 0x05; // uart1 RI interrupt level 5
te_u1c1 = 1; //enable uart1 transmit
re_u1c1 = 1; //enable uart1 receive
//------------------------------------------------------------------------------------------
asm(" fset i"); //i=1,enable interrupt
}
关键词:
帮忙
分析
R8C2B
串口
工作
原因