• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






區域變數的問題
#1
新會員
新會員


查看用戶資訊
我遇到了很奇怪的問題?

使用的MCU為PIC18F6520

程式段落如下:

副程式一:
unsigned char com2_check_recv(void)
{
    
unsigned char com2_check_temp1;
    
unsigned int com2_check_temp2,com2_check_temp3;
    
com2_check_temp1=0;
    
com2_check_temp2=modbus_crc(rxbuf2,0,6);
    
com2_check_temp3=a8(rxbuf2[6],rxbuf2[7]);
    if(
com2_check_temp2==com2_check_temp3)
    {
        
com2_check_temp1=rxbuf2[1];
    }
    return 
com2_check_temp1;
}

副程式二:
unsigned int modbus_crc(unsigned char buf[],int starts,int cnt)
{
    
unsigned char crc_i,crc_j;
    
unsigned int crc_temp,crc_temp2,crc_flag;
    
crc_temp=0xFFFF;
    for(
crc_i=starts;crc_i<cnt;crc_i++)
    {
        
crc_temp=crc_temp buf[crc_i];
        for (
crc_j=1;crc_j<=8;crc_j++)
        {
            
crc_flag=crc_temp 0x0001;
            
crc_temp=crc_temp >> 1;
            if(
crc_flag) {crc_temp=crc_temp^0xA001;}     
        }
    }    
    
crc_temp2=crc_temp >> 8;
    
crc_temp=(crc_temp << 8)|crc_temp2;
    
crc_temp &= 0xFFFF;
    return 
crc_temp;
}


當我的程式跑到副程式一時....會再呼叫副程式二.....但是..當副程式二跑完後,回到副程式一時...我發現原本副程式一所宣告的變數位址會不一樣!
請問一下為什麼會這樣子?

發表於: 2007/12/19 16:18
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------