• 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: UART UART2_ReadBuffer() & UART2_RxDataAvailable() 的使用問題
#4
新會員
新會員


查看用戶資訊
Hi,

(1) 用記事本開啟檔案,是很正常的中文,就是英文不好,才要寫中文,很難盡量耶...

(2) 用 MCC 產生的程式碼,就是 uart2.c,也就是我上次上傳的貼圖 (因為不知如何上傳 程式碼 uart2.c,所以用貼圖表示內容)。
正常之下,我們要增加操作的程式,也一定要寫在 main.c 裡面

MCC 產生的程式碼,使用了 static 修飾函式,依照 C 規矩只能在 uart2.c 檔案裏面寫程式,然後去呼叫它(如下面,前一次的貼圖連結的表示文字)

uart.c.jpg (107.45 KB)
50242_6614f8c34896d.jpg 787X637 px

將需要操作的程式,因為 static 修飾函式,
static uint8_t UART2_RxDataAvailable(void)

而改寫在 uart2.c 裡面,而不寫在 main.c 裡面(因為 static 修飾函式),才可以正常的 compiler,是可以正常執行程式。
但是,之後又操作 MCC 時,不會出問題嗎?

發表於: 4/11 18:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: UART UART2_ReadBuffer() & UART2_RxDataAvailable() 的使用問題
#3
管理員
管理員


查看用戶資訊
Hi,

(1) 原則上 Encoding 選擇 Big 5, utf-8 等可以在呈現中文。但還是根據您所使用的MPLAB XIDE 的版本可能還是有些差別,目前確認 v6.05 上還可以使用,您可以再試試看。另外,雖然在MPLAB XIDE上呈現的是亂碼,但您若使用其他例如Visual Studio Code打開檔案的話,呈現出來的還是為中文。
建議您能使用英文還是盡量使用英文呦!

(2) 在使用 static 修飾函式的時候,這個函式只能在該檔案中調用,不能在其它檔中調用喔!
因此請選擇其他函式做使用喔! 當然,您也可以將 static 刪掉之後調用該函式,但是並不建議。

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


Re: UART UART2_ReadBuffer() & UART2_RxDataAvailable() 的使用問題
#2
新會員
新會員


查看用戶資訊
加上 uart2.c 的截圖

Attach file:



jpg  uart.c.jpg (107.45 KB)
50242_6614f8c34896d.jpg 787X637 px

發表於: 4/9 16:14
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


UART UART2_ReadBuffer() & UART2_RxDataAvailable() 的使用問題
#1
新會員
新會員


查看用戶資訊
版主您好,
IC:dsPIC33CK256MP506
MPLAB® XC16-ld:v2.00 (B)

(1) 開新專案時,已經有選擇 Encoding = big5,但是還是無法在 XIDE 上顯示中文,請問還有什麼地方要設定呢?
(2) 使用 UART RX,無法正常編寫以下程式,必須要將 MCC 產生的 uart2.c 內容,第 329 行的 "static" 刪除,程式才會正常的 compiler,這應該不是正確的方式,請問要如何正確的修改,才可以正常的 compiler。

#include "mcc_generated_files/system.h"

uint8_t     U2TXDATA[12]; 
uint8_t     RX_NUM;

       
uint8_t UART2_RxDataAvailable(void);    /// 取消 uart2.c 前面的字 "static"    //  
unsigned int                             UART2_ReadBufferuint8_t *buffer ,  unsigned int numbytes);            

/*
                         Main application
 */
int main(void)
{
    
// initialize the device
    
SYSTEM_Initialize();
    while (
1)
    {
        
// Add your application code
        
RX_NUM UART2_RxDataAvailable();    // delete uart2.c "row 329 - static"
        
UART2_ReadBufferU2TXDATA RX_NUM); 
        
Nop();
        
// delay_ms(1000);
    
}
    return 
1
}

Attach file:



jpg  MCC-1.jpg (87.76 KB)
50242_6614d427bf84b.jpg 978X580 px

發表於: 4/9 13:38
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... ]

教育訓練中心

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