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


Browsing this Thread:   1 Anonymous Users






Re: 請問C18如何宣告位元變數
#6
資深會員
資深會員


查看用戶資訊
我已經會用位元變數了,謝謝大大們指導。

發表於: 2007/1/2 14:17
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C18如何宣告位元變數
#5
版主
版主


查看用戶資訊
在你的宣告裡用了 extern 代表這個變數與結構是別的程式已經宣告過了,請確定該變數的原始宣告是否存在。

發表於: 2007/1/2 10:35
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C18如何宣告位元變數
#4
高級會員
高級會員


查看用戶資訊
小弟的方式...

union tbyte
{
unsigned char byte;
struct
{
unsigned b0 : 1;
unsigned b1 : 1;
unsigned b2 : 1;
unsigned b3 : 1;
unsigned b4 : 1;
unsigned b5 : 1;
unsigned b6 : 1;
unsigned b7 : 1;
};
};

union tbyte flag0 = 0;
#define fbit0 flag0.b0
#define fbit1 flag0.b1


void main ()
{
flag0.byte = 0xff;
fbit0 = 0;
fbit7 = 0;
flag0.b3 = 0;
while (1);
}

我用起來滿方便的..
不用再去宣告 union...struct 每個bit 都去定義名稱
參考看看....




發表於: 2006/12/29 18:43
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C18如何宣告位元變數
#3
資深會員
資深會員


查看用戶資訊
請問版主:
我寫了一個結構變數宣告如下:
extern volatile unsigned FG1;
extern volatile struct {
unsigned DIR_C:1;
} FG1bits;

這樣宣告編譯的時候沒有問題,但是若在程式中要使用DIR_C這個位元變數時,例如寫這行指令:
FG1bits.DIR_C=1;
編譯時就會出現下面這一行錯誤:
239:Error [1205] unknown member 'FG1bits' in '__tag_136'

請問我是哪裡語法不正確嗎?
謝謝。


發表於: 2006/12/29 17:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C18如何宣告位元變數
#2
版主
版主


查看用戶資訊
應該用位元結構的方式宣告,使用方式請看 W401 workshop 講義的第四章 STRUCT & UNION 的使用方式

發表於: 2006/12/29 10:17
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問C18如何宣告位元變數
#1
資深會員
資深會員


查看用戶資訊
請問版主:
我用 bit Flag; 這樣寫想宣告一個名稱為Flag的位元變數,但是無法編譯,請問應該怎麼宣告才正確?
謝謝。

發表於: 2006/12/29 10:03
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... ]

教育訓練中心

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