|
程序执行到最后一句return时出现异常,帮帮忙!
[复制链接]
ARM7 44b0,用ADS1.20编译调试。
代码中定义了这样一个函数device_run,如下。
BOOL device_run(BYTE type)
{
BYTE setAttributeValue;
MAC_ENUM status;
PAN_DESCRIPTOR *pPanDescriptor;
UINT8 n;
ADDRESS coordAddr;
MAC_SCAN_RESULT scanResult; // take( 6 + 23 * 4 = 98 ) bytes
//Initialize variables
myShortAddr = 0xFFFF;
coordAddr.Extended=coorExtendaddr;
mlmeResetRequest(TRUE);
// Scan for coordinators
mlmeScanRequest(ACTIVE_SCAN, CHANNEL_SCAN, 5, &scanResult);
while (mscInfo.scanStatus == MSC_STATUS_ACTIVE);
// Go through the result list and pick a coordinator to associate with
pPanDescriptor = NULL;
for (n = 0; n resultListSize; n++) {
if ((mscInfo.pScanResult->a).pPANDescriptorList[n].superframeSpec & SS_ASSOCIATION_PERMIT_BM) {
pPanDescriptor = &(mscInfo.pScanResult->a).pPANDescriptorList[n];
goto next;
}
}
next:
if (!pPanDescriptor)
return FALSE;
// Set variables
panId = pPanDescriptor->coordPanId;
coordAddr = pPanDescriptor->coordAddress;
// Update PIB attributes
mlmeSetRequest(MAC_PAN_ID, &panId);
setAttributeValue = TRUE;
mlmeSetRequest(MAC_RX_ON_WHEN_IDLE, &setAttributeValue);
setAttributeValue = BF(pPanDescriptor->superframeSpec, SS_BEACON_ORDER_BM, SS_BEACON_ORDER_IDX);
mlmeSetRequest(MAC_BEACON_ORDER, &setAttributeValue);
setAttributeValue = BF(pPanDescriptor->superframeSpec, SS_SUPERFRAME_ORDER_BM, SS_SUPERFRAME_ORDER_IDX);
mlmeSetRequest(MAC_SUPERFRAME_ORDER, &setAttributeValue);
// Associate with the selected coordinator
mlmeAssociateRequest(pPanDescriptor->logicalChannel, pPanDescriptor->coordAddrMode, panId, &coordAddr, 0x0E, TRUE);
while (myShortAddr == 0xFFFF);
if(type==FFD)
{
mlmeSetRequest(MAC_SHORT_ADDRESS, (BYTE*) &myShortAddr);
setAttributeValue=TRUE;
mlmeSetRequest(MAC_ASSOCIATION_PERMIT, &setAttributeValue);
mlmeStartRequest(panId, CHANNEL, 15, 15, TRUE, FALSE, FALSE, FALSE);
}
return TRUE;
}
device_run函数在main函数中以这样的形式调用:
while ( !device_run(FFD) ){...}
问题是这样的:当程序执行到最后一句return TRUE时,按理说应该回到调用它的main函数中,可是,每次都是回到evice_run()里面的return FALSE中(红色标出来了),然后再接着执行时到最后一个}前,接着就异常了,怎么也回不到main函数中。
为什么会这样?大家帮我分析分析,代码贴得有点长,但问题的现象挺明显的。谢谢大家!!
|
|