|
本帖最后由 zsp06312222 于 2017-6-28 20:14 编辑
新塘最新的单片机N76E003,配置好时钟串口定时器,就是接受不了DMX512通讯协议的数据。仿真能进中断。
程序如下:(欢迎大侠指点赐教)
void SerialPort0_ISR(void) interrupt 4 //4
{
UINT8 rece_data;
if(RI)
{ /* if reception occur */
clr_RI; /* clear reception flag for next reception */
if(RB8==0) //RB8
{
rec_ok = 1;
dmx_channel = 0;
Adr = Address - 1; //Address = dmx;
Point = 100; //3ms*250
}
else
{
if(rec_ok) //bit rec_ok;
{
if(Adr == 0) //uint Adr,Address;
{
recbuf[dmx_channel] = SBUF; //½ÓÊÜ
dmx_channel ++;
if(dmx_channel > RECCHANNEL) //RECCHANNEL = 2;
{
rec_ok = 0;
dmx_recok = 1; //
}
}
else Adr--;
}
}
}
}
void InitialUART0_Timer1(UINT32 u32Baudrate) //T1M = 1, SMOD = 1
{
P05_PushPull_Mode; //P05
P06_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
P07_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
TIMER1_MODE2_ENABLE; //
/*0x70*/
SCON = 0x70; //UART0 Mode1,REN=1,TI=1
TMOD |= 0x20; //Timer1 Mode2
set_SMOD; //UART0 Double Rate Enable
set_T1M; //
clr_BRCK; //Serial port 0 baud rate clock source = Timer1
TH1 = 256 - (1000000/u32Baudrate+1); /*16 MHz */
clr_ET1;
set_TR1;
set_RB8; //This bit is for setting the stop bit 2 high/low status
set_ES; //enable UART interrupt
set_EA; //enable global interrupt
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|