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

論壇索引


Board index » All Posts (ivkeytt)




Re: do while 輸出問題
#1
新會員
新會員


引言: 瘋曰:「屁股那去了?」
抱歉聽不懂

我發現第三回圈input輸入要快,才能夠跑第三回圈的程式,感謝各位的指教

發表於: 2009/10/22 12:06
頂部


Re: do while 輸出問題
#2
新會員
新會員


感謝各位的熱心解答

我將各位的方式都試了一試,把while(input_2 != 0x0c);中的分號拿掉會有compiler錯誤情形。

也感謝版主的指導,上列程式的結果也跑出來了,是我想要的結果。於是我做些修改想再做第三個迴圈試試看,我依序給予的輸入是 0x0a,0x03,0x0b,但他做完第二個迴圈(0x03輸出結束)就停止了
請問一下問題出在哪?

#include<pic.h>
main()

{
TRISD=0B00000000;
TRISC=0B11111111;
unsigned char input_1=0,input_2=0,input_3=0;
do
{
input_1= PORTC & 0x0f;
}
while(input_1 != 0x0a);
PORTD=input_1;

do
{
input_2= PORTC & 0x0f;
}
while(input_2 == input_1);
PORTD=input_2;

do
{
input_3= PORTC & 0x0f;
}
while(input_3 == input_2);
PORTD=input_3;
}

發表於: 2009/10/21 20:11
頂部


do while 輸出問題
#3
新會員
新會員


各位好,我使用的是 pic16f877 用hi-tech compiler

我想利用程式做兩個do while迴圈讀portc資料作判斷,再將資料由portd顯示

我在mplab跑時,沒發現問題

但在實際板子上做時,第一迴圈可以按照我的程式跑出0x03,但是第二個回圈卻無法跳出做0x06

我懷疑是portc的問題,但又不知從何改起

懇請大家幫幫忙

以下程式
#include<pic.h>
main()

{
TRISD=0B00000000;
TRISC=0B11111111;
int input_1,input_2;
do
{
input_1= PORTC & 0x0f;
}
while(input_1 != 0x03);

PORTD=input_1;

do
{
input_2= PORTC & 0x0f;
}
while(input_2 != 0x0c);
PORTD=0X06;
}

發表於: 2009/10/11 10:03
頂部






:::

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... ]

教育訓練中心

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