• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






Re: dsPIC30F3011 UART問題
#2
版主
版主


查看用戶資訊
1. 請再看一下 dsPIC30F4011 的 UASRT 方塊圖。傳送事先送到 UxTXERG 的 4 層 FIFO 的暫存區,之後資料會在載入到 U2TSR 傳送出去。看不到 FIFO U2TXREG 是正常的。
同樣接收也是有四層接收 FIFO的。

2. TRMT status bit in the UxSTA SFR
Bit is cleared if Transmit Shift Register (UxTSR) is busy or a transmission is pending
建議先檢查 TRMT 位元的狀態後再傳送資料。

3. 你有使用 dsPIC30F4011 的周邊函數庫,所以需使用 C30 的編譯器,XC16 線不支援就的周邊函數改由MCC 來支援爭邊函數。

4. 你的問題我無法一行一行的看,建議你參考我之前寫的教材:

http://www.microchip.com.tw/RTC/RTC_DVD/
16-Bits MCU 相關課程 -->
dsPICMOD dsPIC30F Module Training

裡面有USART 的章節,有投影教材及三個城市範例可以參考看看。

發表於: 2021/7/7 14:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dsPIC30F3011 UART問題
#1
新會員
新會員


查看用戶資訊
各位先進好:
小弟目前使用dsPIC30F3011做UART傳輸,在寫入U2TXREG的時候不管怎樣都寫不進去,以下為我的程式碼


#include "uart.h"



void InitUART2(void);
void WriteUART2(unsigned int data);
void WriteUART2dec2string(unsigned int data);
void WriteStringUART2(const char * s);

#define FCY (unsigned long)20000000 //add your operating frequency

#define UART2_BAUD 9600

#define UBRG2_VALUE (FCY/UART2_BAUD)/16 - 1


void InitUART2(void)
{
U2BRG = UBRG2_VALUE; // baud rate 9600
U2STAbits.URXISEL = 0; // Interrupt flag bit is set for every character received.
IPC6bits.U2RXIP = 5; // UART2 Receive Interrupt Priority = 4.
U2STAbits.OERR = 0; // Clear the Receive Overflow Flag.
IFS1bits.U2RXIF = 0; // Clear the UART2 Receive Interrupt flag.
IEC1bits.U2TXIE = 0;
IEC1bits.U2RXIE = 1; // Enable UART2 Receive Interrupt.
U2MODEbits.UARTEN = 1; // Enable UART2.
U2STAbits.UTXEN = 1; // Enable UART2 Transmit.
/*
U2STA &= 0xfffc;
IEC1bits.U2RXIE = 1; // enable RX2 interrupt
U2MODEbits.UARTEN = 1; // UARTEN: UART Enable bit
U2STAbits.UTXEN = 1; // transmition ON
*/
}
void WriteUART2 (unsigned int data)
{
U2TXREG = data;
while(!U2STAbits.TRMT){}
}

從watch去看的時候,data是有值的,但U2TXREG卻都是0,請問各位先進能幫我解答嗎?
謝謝!

Attach file:



jpg  問題.JPG (81.20 KB)
76998_60e41fabc3cbd.jpg 909X725 px

發表於: 2021/7/6 17:17
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... ]

教育訓練中心

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