• 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: 請問位元組合的寫法
#5
資深會員
資深會員


查看用戶資訊
struct
{
unsigned int Commmand : 3 ;
unsigned int Seg : 7 ;
unsigned int Com : 4 ;
unsigned int Non : 2 ;
} Flags ;


Flags.Commmand=0b101;
Flags.Seg=0;
Flags.Com=0b0010;
Flags.Non=0;

Flags=0x0805
============================

struct
{
unsigned int Non : 2 ;
unsigned int Com : 4 ;
unsigned int Seg : 7 ;
unsigned int Commmand : 3 ;
} Flags ;

Flags.Commmand=0b101;
Flags.Seg=0;
Flags.Com=0b0010;
Flags.Non=0;

Flags=0xA008 <==正確
===============================
struct定義排序不同

struct的定義是由L_byte排到H_byte??

發表於: 2009/12/24 17:55
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問位元組合的寫法
#4
資深會員
資深會員


查看用戶資訊
請自行動手試試看(try and error).
你將會得到答案與經驗. 謝謝

發表於: 2009/12/24 16:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問位元組合的寫法
#3
資深會員
資深會員


查看用戶資訊
參照:

jason680 寫道:
Flags.Commmand=0b101;
Flags.Seg=0;
Flags.Com=0b0010;
Flags.Non=0;

如果位元值,由大到小
  3     7       4    2
 101 0
,0000,00 00,10 00 => 0xA008

如果位元值
,由小到大
  2   4      7      3
 00 00
,10 00,0000,0 101 => 0x0805  你得這個值嗎?



沒錯是得到0x0805

要如何修正bit數由大到小?

發表於: 2009/12/24 16:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問位元組合的寫法
#2
資深會員
資深會員


查看用戶資訊
Flags.Commmand=0b101;
Flags.Seg=0;
Flags.Com=0b0010;
Flags.Non=0;

如果位元值,由大到小
  3     7       4    2
 101 0
,0000,00 00,10 00 => 0xA008

如果位元值
,由小到大
  2   4      7      3
 00 00
,10 00,0000,0 101 => 0x0805  你得這個值嗎?

發表於: 2009/12/24 15:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問位元組合的寫法
#1
資深會員
資深會員


查看用戶資訊
請問位元組合的寫法:

struct
{
unsigned int Commmand : 3 ;
unsigned int Seg : 7 ;
unsigned int Com : 4 ;
unsigned int Non : 2 ;
} Flags ;


Flags.Commmand=0b101;
Flags.Seg=0;
Flags.Com=0b0010;
Flags.Non=0;

Flags=0xA008

但是組合起來Flags卻不是0XA008

請各位先進指導謝謝^^

發表於: 2009/12/24 14:54
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... ]

教育訓練中心

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