• 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: 電腦端傳送資料給dspic
#4
版主
版主


查看用戶資訊
gersUART 裡的 Length 是只接收該字串最大長度的設定,超過此長度即使未收到 Null Byte 以會跳出函數的。

int *Buffer 是指標形態,你可以宣告一著陣列後再將陣列名稱傳給他。

不過ㄧ般 UART建議是使用中斷來收資料,這樣程式會比較有彈性。
getsUART( ) 很容易就將程式卡死,

發表於: 2008/8/27 15:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 電腦端傳送資料給dspic
#3
新會員
新會員


查看用戶資訊
感謝回答
請問getsUART()中他始使用方式是
getsUART1(int length,int *buffer, int uart_data_wait)
其中length 為字串長度,buffer為暫存位址,uart_data_wait
為等待時間
想請問buffer的位置要如何得知,我是用測試版

發表於: 2008/8/26 9:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 電腦端傳送資料給dspic
#2
版主
版主


查看用戶資訊
ㄧ般在 C 裡分解資料可以使用 union 的資料結構來分解。因為是共用 memory 所以資料就可以被拆解成其他的格式。
如果不用 union 拆解資料就需使用指標方式來個別讀取了。

ReadUART( ) & getUART( ) 只能擷取一個 Byte 的資料而已,而 getsUART( ) 是讀取一完整字串的資料(直到讀取 0x00 為止)。

發表於: 2008/8/25 18:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


電腦端傳送資料給dspic
#1
新會員
新會員


查看用戶資訊
請問pic接收電腦傳來的字串,在pic端分解字串要用哪個指令?
先前我用過ReadUART1(),但只接收到第一個字元。
在書本上有看到getsUART1(),想請問要怎麼使用。

---------------------------------------------------------

void readstring(void)
{
char cmd,k;
cmd=0;
k=0;
while(cmd!='*') cmd=ReadUART1();

CommandBuffer[k]=cmd;

while( (cmd=ReadUART1()) !='@'&& k <= 30)CommandBuffer[++k]=cmd;
CommandBuffer[k+1]='@';
CommandBuffer[k+2]='\0';
}
----------------------------------------------------------------
以上是我用來分解字串的程式,但無法解讀整個字串。只讀取到第一個字元,想請問解決的方法。

發表於: 2008/8/25 17:29
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... ]

教育訓練中心

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