• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: 如何在PIC30f5015上使用c language的scanf
#2
版主
版主


查看用戶資訊
實在看不懂你的程式,不過 Enter Key 的 ASCII Code 是 0x0D,我在你的程式並沒有看對 Enter Key 的檢查。

發表於: 2008/10/13 8:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


如何在PIC30f5015上使用c language的scanf
#1
新會員
新會員


查看用戶資訊
各位好,

本人最近想使用scanf來讀取來自uart的輸入字元,從microchip文件讀到必須修改read.c 的檔案. 我把它放入MPLAB IDE project 裏,因為5015只有 一個UART, 我就修改成如下所示,我就在程式裡使用scanf來讀取我從PC上的hyper terminal輸入的字元,可是當我只按了一個字元scanf就執行完畢,理論上應該是我按下幾個字元再按 Enter後scanf才算執行完畢,一直百思不解,不知各位先進有何解答,
本人不甚感激


#include <p30f5015.h>
#include <stdio.h>


int __attribute__((__weak__, __section__(".libc")))
read(int handle, void *buffer, unsigned int len)
{
int i;
volatile UxMODEBITS *umode = &U1MODEbits;
volatile UxSTABITS *ustatus = &U1STAbits;
volatile unsigned int *rxreg = &U1RXREG;
volatile unsigned int *brg = &U1BRG;


if (_Files[0]->_Lockno == 0)
{

for (i = len; i; --i)
{

while ((ustatus->URXDA) == 0);
*(char*)buffer++ = *rxreg;
}
len -= i;

}
return(len);
}

發表於: 2008/10/10 22:07
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... ]

教育訓練中心

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