我的电路是这样的,内部RC,内部复位,UART0和UART1分别外接RSM3485,实现两个独立的RS485接口。
UART0--RSM3485_0--P4^6控制读写
UART1--RSM3485_1--P4^4控制读写
测试程序:
#include "REG952.h"
#include <INTRINS.H>
#define NOP10 {_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();}
sbit test =P0^0;
void dlylittle()
{
unsigned char i;
for(i=0;i<128;i++);
}
void main()
{
P0M1 =0x00;
P0M2 =0x00;
P4M1 =0x00;
P4M2 =0x00;
S1CON =0x50;
S1STAT =0x60;
BRGCON_1 =0X00;
BRG0_1 =0XF0;
BRG1_1 =0X02;
BRGCON_1 =0X03;
TEST =0;
P4 &=0xEF
dlylittle();
while(1)
{
test =~test;
S1BUF =0X55;
while(S1CON&0x02 == 0);
S1CON &=0xFD;
NOP10;
}
} |