• 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: Byte資料個別定義
#9
資深會員
資深會員


查看用戶資訊
>>>C18不支援8bit以上。 C18是用在PIC18 ?
是的

>>>那PIC18以上的晶片,是否有支援到8bit以上呢??(好像是C30?)
沒試過, 不知

>>>另外C18最大能訂到多大的DATA呢??
多大的DATA??
不明白意思? DATA是指什麼單位??



建議是不是自己舉一反三, 實際用mplab 的SIM試看看呢?
試過還不了解再上來問會比較有效率, 也學的比較多

發表於: 2009/4/3 23:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#8
初級會員
初級會員


查看用戶資訊
不好意思,再次請教。
C18不支援8bit以上。 C18是用在PIC18 ?

那PIC18以上的晶片,是否有支援到8bit以上呢??(好像是C30?)

另外C18最大能訂到多大的DATA呢??
下面是應該是PR為兩個BYTE資料??

不知道能否訂到 unsigned long?? (4 Byte)

又再一次請教,謝謝大家
-======================
union{
unsigned int byte;
struct{
unsigned x:2;
unsigned o:6;
unsigned w:2;
unsigned a:2;
unsigned e:4;
} bit;
}PR;

發表於: 2009/4/3 23:00
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#7
資深會員
資深會員


查看用戶資訊
因為C18不支援到8bit以上

發表於: 2009/4/3 17:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#6
初級會員
初級會員


查看用戶資訊
請問不能超過8 bits主要是因為??

MCU的關係??還是COMPILE的關係??
還是無法一次定2 BYTE ??

感謝解答

發表於: 2009/4/3 16:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#5
資深會員
資深會員


查看用戶資訊
不能超過8bit
unsigned o:9; //錯誤

真需要9bit,
只能先用int變數來運算,然後再想辦法轉換到bit裡面去

發表於: 2009/4/3 9:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#4
初級會員
初級會員


查看用戶資訊
謝謝 nicecookie 的詳細解惑。
不過又有一個問題又想請教。
如果我有兩個BYTE 資料。
分別為 2bits 9 bits 2bits 2 bits 1bit

xxoooooo ooowwaae
由於那9bits是要做計算 0x000 ~ 0x1FF
又不要影響到 其他bits資料。
不知道該如何定義?(下面的定義不知道是否正確)
再一次謝謝大家

===============================
union{
unsigned int byte;
struct{
unsigned x:2;
unsigned o:9;
unsigned w:2;
unsigned a:2;
unsigned e:1;
} bit;
}PR;

PR.bit.x = 2;
PR.bit.o = 511;
PR.bit.w = 1;
PR.bit.a = 0;
PR.bit.e = 1;
PR.byte = 0xBFE9;

發表於: 2009/4/2 22:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#3
版主
版主


查看用戶資訊
當然可以,多看一下 相關元件的 H 裡的定義。

nicecookie 提供了很好的範例說明。

發表於: 2009/4/2 10:10

Edited by Ryang on 2009年04月03日 14:38:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Byte資料個別定義
#2
資深會員
資深會員


查看用戶資訊
union{
unsigned char byte;
struct{
unsigned a:3;
unsigned b:4;
unsigned c:1;
};
}RR;

RR.a=5;
RR.b=0xA;
RR.c=1;
RR.byte=0x66;

發表於: 2009/4/2 0:25
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Byte資料個別定義
#1
初級會員
初級會員


查看用戶資訊
一個Byte有8個bits
在C18定義變數時,可以把一個變數設定byte也可以定義bit

但不知道有沒有辦法把1個byte設定不同的bits ?

如我有3個變數。我想設定他們在同一個byte..
但a 有3 bits b有 4 bits c 有1 bit

不知道在c18下能不能這樣設定?

謝謝大家~

發表於: 2009/4/2 0:12
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... ]

教育訓練中心

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