#include "SEED-DSK2407.H" int transfer=0,sign=0; void UARTRec(); void UARTSent();
void inline disable() { asm(" SETC INTM ");//DINT; asm(" SETC SXM "); }
void inline enable() { asm(" CLRC INTM "); }
main() { int i; disable(); *IFR=0XFFFF; *SCSR1=0X81fe;//0X81FE; *WDCR=0XE8; *SCICCR=0X7; *SCICTL1=0X13; *SCICTL2=0X3; *SCIHBAUD=0X1;/*波特率9600,注意串口波特率更改后,串口软件要重新启动一次串口。且波特率是系统时钟SYSCLK频率和波特率选择寄存器决定的。SYSCLK由系统时钟输入倍频得来,见书P237页*SCSR1=0X81FE那行。波特率要用书上P230页的例题公式计算*/ *SCILBAUD=0X7f; *SCICTL1=0X33; *SCIPRI=0X60; *MCRA=0X3; *PADATDIR=0X100; *IMR=0X10; enable(); *SCITXBUF=0x55; while(1) { //UARTSent(); //*SCITXBUF=0X55; //for(i=0;i<10000;i++); if(sign) { } //transfer++; }; }
void UARTRec() { //static int receive[10],j=0; //receive[j++]=*SCIRXBUF; transfer=*SCIRXBUF;
*IFR=0x0010;//在中断响应后IFR会自动清0
//*PIVR=0; enable(); } void UARTSent() { //const char *var="F2407"; //static int i=0; //if(i>strlen(var))return; //*SCITXBUF=var[i++]; *SCITXBUF=transfer; transfer++; *IFR=0X0010;//将串口中断位写1,既是清零 enable(); //return; }
void interrupt UART() { //sign=*PIVR; switch(*PIVR) { case 6: { UARTRec(); sign=1; } case 7: { UARTSent(); sign=0; } default:break; } /*if(*PIVR==6) { UARTRec(); sign=1; } else*/ /*if(*PIVR==7) { //UARTSent(); *SCITXBUF=transfer; transfer++; *IFR=0X0010;//将串口中断位写1,既是清零 enable(); }*/ }
void interrupt nothing() { return; }
我只想发送一个字节,可是程序不断跳入中断,不断发送。 |