• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






Re: picc 18 好像不支援這樣的宣告,還是我錯了...!
#5
版主
版主


查看用戶資訊
可以參考 W 401 C18 workshop 教材的第四章,那裡有詳細的 Union & Struct 的說明。

發表於: 2006/10/2 16:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: picc 18 好像不支援這樣的宣告,還是我錯了...!
#4
初級會員
初級會員


查看用戶資訊
我也使用PIC18F6722

typedef union{
unsigned char Byte;
struct{
unsigned SOF1:1;
unsigned EOF1:1;
unsigned SOF2:1;
unsigned EOF2:1;
}bits;
}UART01s;


UART01s Uart01;
//---------------------------------------------------
//UART
//---------------------------------------------------
#define Uart1_Byte Uart01.Byte
//---------------------------------------------------
#define UART1bt_SOF Uart01.bits.SOF1
#define UART1bt_EOF Uart01.bits.EOF1
//---------------------------------------------------

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


Re: picc 18 好像不支援這樣的宣告,還是我錯了...!
#3
新會員
新會員


查看用戶資訊
謝謝! 因為我用別種C可以用我提出的方式宣告,程式比較容易閱讀,修改也很容易

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


Re: picc 18 好像不支援這樣的宣告,還是我錯了...!
#2
高級會員
高級會員


查看用戶資訊
unsigned char       _mp3_flag;
union {
  
struct {
    
unsigned play:1;
    
unsigned load:1;
    
unsigned rec:1;
    
unsigned save:1;
    
unsigned rb4:1;
    
unsigned rb5:1;
    
unsigned rb6:1;
    
unsigned lost:1;
  };
mp3_flag=0;

....................................

void main(void)
{
           if(
mp3_flag.play){....}
}

發表於: 2006/10/2 9:21
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


picc 18 好像不支援這樣的宣告,還是我錯了...!
#1
新會員
新會員


查看用戶資訊
union un_byte { /* union PORT1 */
unsigned char Byte; /* Byte Access */
struct { /* Bit Access */
unsigned char b0:1; /* Bit 0 */
unsigned char b1:1; /* Bit 1 */
unsigned char b2:1; /* Bit 2 */
unsigned char b3:1; /* Bit 3 */
unsigned char b4:1; /* Bit 4 */
unsigned char b5:1; /* Bit 5 */
unsigned char b6:1; /* Bit 6 */
unsigned char b7:1; /* Bit 7 */
} b;
};

union un_byte KEY_O0;

#define Page_Add KEY_00.b.b0
#define Page_Dec KEY_00.b.b1

picc 18 好像不支援這樣的宣告,還是我錯了...!

唉呀! 我"O" 跟 "0"(零)打錯了 謝謝大家!

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

教育訓練中心

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