• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 呼叫回傳值不正確
#8
資深會員
資深會員


查看用戶資訊
那把VIEW中DISASSEMBLY LISTING開出來

看在展開後的組語把數值丟到哪

還有把
k = TouKey_Read(0x08, 2);
改成
k =unsigned char TouKey_Read(0x08, 2);

有的c會要求在遞回前設定送回的格式

發表於: 2010/1/28 14:03
My name is jan,Jan是棒的
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 呼叫回傳值不正確
#7
新會員
新會員


查看用戶資訊
這個動作我已做過了,
是照著流程跑的沒錯

發表於: 2010/1/28 13:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 呼叫回傳值不正確
#6
資深會員
資深會員


查看用戶資訊
把breakpoint 設在return 5 及return 0
看執行的流程是不是照你的意思走

再來分析問題吧

發表於: 2010/1/28 13:40
My name is jan,Jan是棒的
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 呼叫回傳值不正確
#5
新會員
新會員


查看用戶資訊
我試了
但結果還是0x61

發表於: 2010/1/28 13:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 呼叫回傳值不正確
#4
版主
版主


查看用戶資訊
將 unsigned char k; 拉出 main( ) 成 Global Variable 後再用 Watch window 監看一下其值。

發表於: 2010/1/28 13:15
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 呼叫回傳值不正確
#3
新會員
新會員


查看用戶資訊
我的return 是5 or 0,
根i無關

發表於: 2010/1/28 12:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 呼叫回傳值不正確
#2
資深會員
資深會員


查看用戶資訊
參照:

sushying 寫道:
您好:
我目前使用APP023 v8.0 + MPLAB c18 V3.34開發,
我在main底下呼叫一個副程式, 不管副程式的回傳值如何變化,得到的值永遠是0x61, 是設定上問題嗎?

void main( void )
{
unsigned char k;
..
TouKey_Write(0x05, i);
k = TouKey_Read(0x08, 2);
if (k != 0)
{
setcurGLCD(3,0) ;
putrsGLCD( "Touch ") ;
My_Temp = I2CReDa1[0];
setcurGLCD(3,3) ;
itoa(My_Temp , TempASCII) ;
putsGLCD(TempASCII) ;

My_Temp = I2CReDa1[1];
setcurGLCD(3,5) ;
itoa(My_Temp , TempASCII) ;
putsGLCD(TempASCII) ;
}
...
}

unsigned char TouKey_Read(unsigned char address, unsigned char lenth)
{
char i;

I2CTrDa1[0] = 0x00; // Start Process2
I2CTrDa1[1] = address; // Address
i = I2CByteWri1(0xE0, 2);
if (i!=0)
{
putrsUART1( "ERROR: TouKey Read Fail") ;
return 5;
}
I2CCurrRead1(0xE0, lenth);
return 0;
}


兩個i又不一樣,主程式要對遞回的數值,另設一個變數呀

發表於: 2010/1/28 12:10
My name is jan,Jan是棒的
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


呼叫回傳值不正確
#1
新會員
新會員


查看用戶資訊
您好:
我目前使用APP023 v8.0 + MPLAB c18 V3.34開發,
我在main底下呼叫一個副程式, 不管副程式的回傳值如何變化,得到的值永遠是0x61, 是設定上問題嗎?

void main( void )
{
unsigned char k;
..
TouKey_Write(0x05, i);
k = TouKey_Read(0x08, 2);
if (k != 0)
{
setcurGLCD(3,0) ;
putrsGLCD( "Touch ") ;
My_Temp = I2CReDa1[0];
setcurGLCD(3,3) ;
itoa(My_Temp , TempASCII) ;
putsGLCD(TempASCII) ;

My_Temp = I2CReDa1[1];
setcurGLCD(3,5) ;
itoa(My_Temp , TempASCII) ;
putsGLCD(TempASCII) ;
}
...
}

unsigned char TouKey_Read(unsigned char address, unsigned char lenth)
{
char i;

I2CTrDa1[0] = 0x00; // Start Process2
I2CTrDa1[1] = address; // Address
i = I2CByteWri1(0xE0, 2);
if (i!=0)
{
putrsUART1( "ERROR: TouKey Read Fail") ;
return 5;
}
I2CCurrRead1(0xE0, lenth);
return 0;
}

發表於: 2010/1/28 12:02
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... ]

教育訓練中心

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