|
是SPI初始化代码,也不是每次都会有异常,偶尔重新烧写NK的时候才出现。奇怪这如果错误了,怎么不是每次都出现!
定义:
typedef struct __SPIRX_BUFFER_INFO {
ULONG Read;
ULONG Write;
UINT Length;
BOOL DataAvail;
HANDLE hReadEvent;
PUCHAR SPIRxCharBuffer;
CRITICAL_SECTION CS;
} SPIRX_BUFFER_INFO, *PSPIRX_BUFFER_INFO;
typedef struct __SPIHW_OPEN_INFO {
SPIRX_BUFFER_INFO SPIRxBufferInfo; // @field Pointer back to our HW_INDEP_INFO
} SPIHW_OPEN_INFO, *PSPIHW_OPEN_INFO;
PSPIHW_OPEN_INFO pSpiOpenHead;
代码:
InitializeAddresses();
InitSPI();
pSpiOpenHead=(PSPIHW_OPEN_INFO)LocalAlloc(LPTR, sizeof(PSPIHW_OPEN_INFO));
RETAILMSG(1,(TEXT("LocalAlloc PSPIHW_OPEN_INFO \r\n")));
//给SPI接收开辟一块缓存区,长度2048字节。
pSpiOpenHead->SPIRxBufferInfo.Length =2048;
pSpiOpenHead->SPIRxBufferInfo.SPIRxCharBuffer =
(PUCHAR)LocalAlloc(LPTR, pSpiOpenHead->SPIRxBufferInfo.Length);
RETAILMSG(1,(TEXT("LocalAlloc SPIRxCharBuffer \r\n")));
(有异常时的)调试信息:
SPI_InitializeAddresses - Success
LocalAlloc PSPIHW_OPEN_INFO
Data Abort: Thread=8ffa5a5c Proc=8e84bd60 'device.exe'
AKY=00000005 PC=03f92484(coredll.dll+0x00022484) RA=06049fb8(device.exe+0x00039fb8) BVA=0604a7b8 FSR=00000007
RaiseException: Thread=8ffa5a5c Proc=8e84bd60 'device.exe'
AKY=00000005 PC=03f8dfec(coredll.dll+0x0001dfec) RA=8c2c08d0(NK.EXE+0x000c08d0) BVA=00000001 FSR=00000001
Data Abort: Thread=8ffa5a5c Proc=8e84bd60 'device.exe'
AKY=00000005 PC=03f92484(coredll.dll+0x00022484) RA=06049fb8(device.exe+0x00039fb8) BVA=0604a7b8 FSR=00000007
RaiseException: Thread=8ffa5a5c Proc=8e84bd60 'device.exe'
AKY=00000005 PC=03f8dfec(coredll.dll+0x0001dfec) RA=8c2c08d0(NK.EXE+0x000c08d0) BVA=00000001 FSR=00000001
异常出现在红色标注之后,也就是说
pSpiOpenHead->SPIRxBufferInfo.SPIRxCharBuffer =
(PUCHAR)LocalAlloc(LPTR, pSpiOpenHead->SPIRxBufferInfo.Length);
出了问题,以前没怎么接触异常,没出有什么不对,请大家帮忙,分析分析!
|
|