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


Browsing this Thread:   1 Anonymous Users




(1) 2 »


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#11
版主
版主


查看用戶資訊
還是要 include <usart.h> 的,其實所有的周邊函數庫的使用在 C:\MCC18\doc\periph-lib 裡都有詳細的說明。但真的沒注意到是使用 18F8720 的元件。


2.9         ReadUSART[color=ff0000]
Read1USART
Read2USART
[/color]
getcUSART
getc1USART
getc2USART

Function:
    

Read a byte (one characterout of the USART receive buffer,
including the 9th bit if enabled.

Include:   
usart.h

Prototype
:
    
char ReadUSART(  void );
char Read1USARTvoid );
char Read2USARTvoid );
char getcUSART(  void );
char getc1USARTvoid );
char getc2USARTvoid );

Remarks:
    
This function reads a byte out of the USART receive buffer
The Status bits and the 9th data bits are saved in a union 
with the following declaration
:

 

  
union USART

  
{

    
unsigned char val;

    
struct

    
{

      
unsigned RX_NINE:1;

      
unsigned TX_NINE:1;

      
unsigned FRAME_ERROR:1;

      
unsigned OVERRUN_ERROR:1;

      
unsigned fill:4;

    };

  };

 

The 9th bit is read-only if 9-bit mode is enabledThe Status 
bits are always read
.

On a part with a single USART peripheralthe getcUSART and
 
ReadUSART functions should be used and the status 
information is read into a variable named USART_Status 
which is of the type USART described above
.


On a part with multiple USART peripheralsthe getcxUSART 
and ReadxUSART functions should be used and the status 
information is read into a variable named USARTx_Status 
which is of the type USART described above
.


Return 
Value:
    

This function returns the next character in the USART receive buffer.

File Name:
    

uread.c

u1read
.c

u2read
.c

#define in usart.h

#define in usart.h

#define in usart.h

Code Example:
    

int result;

result ReadUSART();

result |= (unsigned int)

          
USART_Status.RX_NINE << 8;

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#10
中級會員
中級會員


查看用戶資訊
解決了

後來我發現

如果可以載入 ReadUSART() 的ic..像是4620之類的

那就算不 #include<usart.h> 神奇的是他竟然也能讀到函式..


似乎讀不讀的到 ReadUSART 的關鍵不是在於有的有#include<usart.h>


而我這個7820讀不到ReadUSART的原因是..7820有兩個TX RX腳

要載入 Read1USART 或 Read2USART 即可

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#9
中級會員
中級會員


查看用戶資訊
還是無法呢...

主要是他的錯誤訊息是

Error - could not find definition of symbol 'ReadUSART' in file './a.o'.

感覺上, 它不是沒找到 .h 檔...而是在ojb和lib裡面找不到函式


我有試著不要用使用ReadUSART..且把所有的#include< >改為#include" "

發現 " " (雙引號) 他找.H的流程是...先在自己的project找尋

如果找不到的話, 也會至設定目錄找...


所以, 應該不是#include的地方有問題



我程式改成 < > 上傳一下

Attach file:


Link only for registered users

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#8
版主
版主


查看用戶資訊
抱歉! 出在 Windows 所提供的ZIP程式打不開,改安裝正式版的 ZIP就好了。

看你的程式對 H 檔的路徑錯誤 :
#include <P18F8720.H>
#include "usart.h"
#include "stdio.h"

使用 ”xxxxx" 的引號是叫 MPLAB IDE 到目前 Project 的目錄下去尋找 H 檔。請改用 <xxxxx> 的方式,如此 MPLAB IDE 就會到 Default mcc18\h 的目錄去尋找。

#include <P18F8720.H>
#include <usart.h>
#include <stdio.h>

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#7
版主
版主


查看用戶資訊
參照:

elfria 寫道:
這些我都有載進去

真奇怪

到現在還是不行

可否幫忙看一下...

我上傳程式


抱歉!我用 Wondows 所附的 UNZIP 程式打不開你的檔案。

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#6
中級會員
中級會員


查看用戶資訊
奇怪了

我都有設定啊

我剛剛看了一下

設定的沒錯...@@

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#5
新會員
新會員


查看用戶資訊
應該是MPLAB include 路徑沒指定吧
Projece→Buidle Options→Project
在Directories頁面將include路徑指到C18安裝目錄的.\h
應該就可以使用了

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#4
中級會員
中級會員


查看用戶資訊
這些我都有載進去

真奇怪

到現在還是不行

可否幫忙看一下...

我上傳程式

Attach file:


Link only for registered users

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


Re: 不好意思..我用8720的ic載入USART讀RS232似乎無法?
#3
版主
版主


查看用戶資訊
抱歉 RAR 打不開,只用 ZIP 格式。

兩種原因 1. 是否忘了使用 UART 的函數要 #include <usart.h> 的宣告。2. lkr 檔一定要使用 MCC18 所提供的 LKR 檔,MPLAB IDE 目錄下所提供的LKR檔是給組合語言使用的,這兩者檔案名稱相同但內容不同,需注意。

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


不好意思..我用8720的ic載入USART讀RS232似乎無法?
#2
中級會員
中級會員


查看用戶資訊
我程式寫好後

像一般的方式使用Usart..結果似乎讀不到ReadUSART的lib

出現如下的訊息

Error - could not find definition of symbol 'ReadUSART' in file



不知道板大的經驗, 知道是發生什麼錯誤嗎?

我幾天前初學當晶片, 下載的程式都是滿新的板本, 應該不是版本問題吧??


我把有問題的專案上傳了

Attach file:


Link only for registered users

發表於: 2009/2/5 20:19
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... ]

教育訓練中心

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