Browsing this Thread:
1 Anonymous Users
|
Re: 如何在PIC30f5015上使用c language的scanf
|
|
版主
Joined
: 2004/4/30 10:53 最後登入時間
: 2021/11/30 18:11
From CAE, Microchip
Group:
站務管理者 註冊會員
Level : 75 HP : 744 / 1861 MP : 5367 / 111040 EXP : 45
|
實在看不懂你的程式,不過 Enter Key 的 ASCII Code 是 0x0D,我在你的程式並沒有看對 Enter Key 的檢查。
發表於: 2008/10/13 8:44
|
|
|
如何在PIC30f5015上使用c language的scanf
|
|
新會員
Joined
: 2008/7/12 19:58 最後登入時間
: 2011/2/10 22:31
Group:
註冊會員
Level : 1 HP : 0 / 5 MP : 1 / 258 EXP : 21
|
各位好,
本人最近想使用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
|
|
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.