本人新手,用的是EASYARM2200,自己按照UART0的实验改写了一个程序,使用了EINT1这个外部中断,串口接收正常,可是发送的数据不正确,而且EINT1中断只能产生一次,请高手指教,谢谢。下面是程序:
#include "config.h"
#define UART_BPS 115200
#define IRQ_EINT1 0x00008000
uint8 rcv_buf[8];
void UART0_Init(void)
{
uint16 Fdiv;
U0LCR = 0x83;
Fdiv = (Fpclk/16)/UART_BPS;
U0DLL = Fdiv<<8;
U0DLM = Fdiv>>8;
U0LCR = 0x03;
}
void senddata(uint8 data)
{
U0THR = data;
while ((U0LSR & 0x20) == 0);
}
void __irq IRQ_EINT1_Send(void)
{
uint8 i = 0;
for(i = 0;i<8;i++)
{
senddata(rcv_buf);
}
EXTINT = 0x02;
VICVectAddr0 = 0x00;
}
void __irq IRQ_UART0(void)
{ uint8 i;
for(i=0; i<8; i++)
{
rcv_buf = U0RBR;
}
VICVectAddr = 0x00;
}
int main (void)
{// add user source code
PINSEL0 = 0x20000005;
EXTMODE = 0x00;
U0FCR = 0x81;
U0IER = 0x01;
VICIntSelect = 0x00000000;
VICVectCntl0 = 0x26;
VICVectCntl1 = 0x2f;
VICVectAddr0 = (int)IRQ_UART0;
VICVectAddr1 = (int)IRQ_EINT1_Send;
EXTINT = 0x02;
VICIntEnable = 0x00008040;
UART0_Init();
while(1);
return 0;
}
|
|