[ 2007-09-11 20:47:13 | Author:
Admin ]
问题现象: 在发书决的时候,接收"123",只接收到23,丢失数据概率很大
测试方法: 1、将uart的2、3pin短接
2、发送数据“123”
测试结果: 1、只接收到“23”
解决方法: 1、经过多次修改代码,并测试得到结论
代码按照以下修改,可以成功接收28个字符
(发送40个字符,第29个字符丢失,其余接收正确)
注:1、这个问题需要得到完整解决,有时间一定要深究一下
测试方法: 1、将uart的2、3pin短接
2、发送数据“123”
测试结果: 1、只接收到“23”
解决方法: 1、经过多次修改代码,并测试得到结论
代码按照以下修改,可以成功接收28个字符
(发送40个字符,第29个字符丢失,其余接收正确)
Quote
// Routine to clear any pending interrupts. Called from Init and PostInit
// to make sure we atart out in a known state.
VOID
ClearPendingInts(
PVOID pHead // @parm PVOID returned by HWinit.
)
{
PS2410_UART_INFO pHWHead = (PS2410_UART_INFO)pHead;
UINT32 tmpReg;
EnterCriticalSection(&(pHWHead->RegCritSec));
RETAILMSG(DEBUGMODE,(TEXT("ClearPendingInts /r/n")));
try {
//SETREG(pHWHead,rUFCON,0x6); // tx, rx fifo reset
//修改为
SETREG(pHWHead,rUFCON,0x4); // txfifo reset
//ClearSubINTPnd(pHWHead, pHWHead->bTxINT | pHWHead->bRxINT | pHWHead->bErrINT);
//修改为
ClearSubINTPnd(pHWHead, pHWHead->bTxINT| pHWHead->bErrINT);
ClearINTPnd(pHWHead, pHWHead->bINT);
tmpReg = INREG(pHWHead,rUERSTAT);
}
except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
RETAILMSG(1,(TEXT("SL_PostInit, 0x%X - ERROR/r/n"), pHWHead));
// Just fall through & release CritSec
}
LeaveCriticalSection(&(pHWHead->RegCritSec));
}
// to make sure we atart out in a known state.
VOID
ClearPendingInts(
PVOID pHead // @parm PVOID returned by HWinit.
)
{
PS2410_UART_INFO pHWHead = (PS2410_UART_INFO)pHead;
UINT32 tmpReg;
EnterCriticalSection(&(pHWHead->RegCritSec));
RETAILMSG(DEBUGMODE,(TEXT("ClearPendingInts /r/n")));
try {
//SETREG(pHWHead,rUFCON,0x6); // tx, rx fifo reset
//修改为
SETREG(pHWHead,rUFCON,0x4); // txfifo reset
//ClearSubINTPnd(pHWHead, pHWHead->bTxINT | pHWHead->bRxINT | pHWHead->bErrINT);
//修改为
ClearSubINTPnd(pHWHead, pHWHead->bTxINT| pHWHead->bErrINT);
ClearINTPnd(pHWHead, pHWHead->bINT);
tmpReg = INREG(pHWHead,rUERSTAT);
}
except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
RETAILMSG(1,(TEXT("SL_PostInit, 0x%X - ERROR/r/n"), pHWHead));
// Just fall through & release CritSec
}
LeaveCriticalSection(&(pHWHead->RegCritSec));
}