我是最近才开始学习ARM的,许多知识还不是很明白,今天简单测试一下ARM的UART端口的功能,结果是发送能正常发送,接收却不能正常接收,接收数据时根本就进不了中断处理程序,不知道为什么,这是我写的测试代码,有点乱,但还是希望各位兄弟能给个解决的方法,谢谢 #include "config.h" #include "stdlib.h" #include "string.h"
unsigned char Size(void) { // return sizeof(HEAPNODE); return 0; } unsigned char Free[1000]; extern void UartHandler(void); //复位FIFO操作使用的宏 #define OSRxFIFOReset(X) if(X)U1FCR |= (1<<1); else U0FCR |=(1<<1); #define OSTxFIFOReset(X) if(X)U1FCR |= (1<<2); else U0FCR |=(1<<2); #define OSUartDisable(X) #define OSUartEnable(X) #define OSUartIOConfig(X) if(X) PINSEL0 = (PINSEL0&0xFFF0FFFF)&0x00050000; else PINSEL0 = (PINSEL0&0xFFFFFFF0)&0x00000005;
char *Name="gwsino@landwind.com.cn
thank you for your going home!"; void UartSendNBytes(unsigned char *nBytes,unsigned char size); unsigned char idx = 0; void RxComplete(void) { unsigned char Rec[8]; unsigned char *read = Rec; unsigned char IIR; switch(U0IIR & 0x0F) { case 0x02: if(idx > strlen(Name)) break; U0THR = Name[idx++]; //idx++; break; case 0x04: case 0x0c: Rec[1] = U0RBR; break; } VICVectAddr = 0; } void UartSendByte(unsigned char nbyte) { U0THR = nbyte; while((U0LSR & 0x40)==0) continue; } void UartSendNBytes(unsigned char *nBytes,unsigned char size) { while(size--) { U0THR = *nBytes++; while((U0LSR & 0x40) == 0) continue; } }
int main (void) {// add user source code volatile unsigned int size; unsigned int value; unsigned short int fdiv; //{21,23,43,53,54,65,76,67,78,34,34,34,34,54,45,32,31,0,0,0,0,5,23,34,0,0,0,0,0,0,0,255}; // strcpy((char*)Name,"gwsino@landwind.com.cn
thank you for your going home!"); fdiv = (Fpclk / 16)/9600; U0LCR = 0X83; U0DLM =(unsigned char)( fdiv / 256); U0DLL = (unsigned char)(fdiv % 256); U0LCR = 0X03;
PINSEL0 = (PINSEL0&0xFFFFFFF0)|0x00000005; U0FCR = 0X07; U0FCR |= 0xC0; VICIntSelect = 0x0000000; VICIntEnable |= (1<<6); VICVectCntl0 = 0x26; VICVectAddr0 = (int) UartHandler; U0IER = 0X07; U0THR = 0x00; //UartSendNBytes((unsigned char*)Name,(unsigned char)strlen((char*)Name)); // OSRxFIFOReset(1); size = Size(); if(size != 0) { value = value+size; } while(1) { } return value; } |