高手帮忙看看啊,一直不进中断,发送的信号有,接收的信号也有
#include "uart1_display.h"
#define FPCLK 2764800L
UARTMODE uart1_set;
uint8 num_uart1_receive[50];
uint8 num1_receive;
uint8 receive_buf[50]; //
/*******************************************/
uint8 UART1_Init(uint32 baud,UARTMODE set)
{
uint32 bak;
/*????*/
if((0==baud)||(baud>115200))return(0);
if((set.datab<5)||(set.datab>8))return(0);
if((0==set.stopb)||(set.stopb>2))return(0);
if(set.parity>4)return(0);
PINSEL0 |= (0x01<<16|0x01<<18); //
PINSEL1 |= 0x00000000;
/*???????*/
U1LCR=0x80; //DLAB??1
bak=(FPCLK>>4)/baud;
U1DLM=bak>>8;
U1DLL=bak&0xff;
/*??????*/
bak=set.datab-5; //?????
if(2==set.stopb)bak|=0x04; //?????2????
if(0!=set.parity){set.parity=set.parity-1;bak|=0x08;}
bak|=set.parity<<4; //??????
U1LCR=bak;
return(1);
}
/*******************************************/
void UART1_Set(uint32 baud)
{
uart1_set.datab=8; //8????
uart1_set.stopb=1; //1????
uart1_set.parity=0; //??????
UART1_Init(baud,uart1_set); //???????
U1FCR=0x81; //??FIFO,???????8??
U1IER=0x01; //??RBR??,?????
/*??????*/
VICIntSelect=0x00000000; //???????IRQ??
VICVectCntl0=0x27; //UART0???????IRQ Slot0,??????
VICVectAddr0=(int)IRQ_UART1; //??UART0????
VICIntEnable=0x00000080; //??UART0??
}
/*******************************************/
void __irq IRQ_UART1(void)
{
uint8 i;
if((U1IIR&0X0F)==0X04) //u0 interrupt identification register
{
num_uart1_receive[num1_receive++] = U1RBR;
if(num1_receive==7)
num1_receive=0;
}
VICVectAddr = 0x00;
}
/******************************************/
void Uart1_Send_Byte(uint8 data)
{
IO1SET|= (0X01<<4); //
U1THR = data; //
while( (U1LSR&0x40)==0); //
IO1SET&=~(0X01<<4); //
}
/******************************************/
void UART1_Operate(uint8 *p)
{
uint8 i;
for(i=8;i>0;i--)
Uart1_Send_Byte(*(p++));
}
/******************************************/
void Display_Hand(void)
{
uint8 hand[8]={0xaa,0x00,0xcc,0x33,0xc3,0x3c};
UART1_Operate(hand);
}
/*************************************************/
void Sensor_Data_Display(uint8 num,uint8 *p,uint16 x,uint16 y)
{
uint8 i;
uint8 data[50];
uint8 code1[6],code2[4];
for(i=0;i<num;i++)
{
data[i]=p[i];
}
code1[0] = 0xaa; //
code1[1] = 0x6f; //
code1[2] = (uint8)x>>8; //
code1[3] = (uint8)x;
code1[4] = (uint8)y>>8; //
code1[5] = (uint8)y;
UART1_Operate(code1);
UART1_Operate(data);
code2[0] = 0xcc; //
code2[1] = 0x33;
code2[2] = 0xc3;
code2[3] = 0x3c;
UART1_Operate(code2);
} |