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


Browsing this Thread:   2 Anonymous Users






Re: 24HJ128GP502的UART RX無法接收
#4
版主
版主


查看用戶資訊
我先建議用示波器看一下 RxD1 (RP1) 這隻腳是否有訊號進來?

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


24HJ128GP502的UART RX無法接收
#3
新會員
新會員


查看用戶資訊
我用24HJ128GP502作UART傳輸,TX有輸出,但是用電腦終端機送出Data,RX都收不到資料也跳不進去中斷,但是設定成Loopback時,TX丟出資料時,RX就可以進中斷也收的到資料,請問是哪邊設定有錯

這是我的程式

int main(void)
{
Initialize_PPS();
Initialize_UART();
while(1)
{
ClrWdt();

}
}


//PPS設定
void Initialize_PPS(void)
{
PPSUnLock; //Unlock the PPS lock feature
iPPSOutput(OUT_PIN_PPS_RP0,OUT_FN_PPS_U1TX); //Uart1 Tx
iPPSInput(IN_FN_PPS_U1RX,IN_PIN_PPS_RP1); //Uart1 Rx
iPPSOutput(OUT_PIN_PPS_RP4,OUT_FN_PPS_U2TX); //Uart2 Tx
iPPSOutput(OUT_PIN_PPS_RP3,OUT_FN_PPS_OC1); //PWM
iPPSOutput(OUT_PIN_PPS_RP15,OUT_FN_PPS_C1TX); //ECAN1 Tx
iPPSInput(IN_FN_PPS_C1RX,IN_PIN_PPS_RP14); //ECAN1 Rx
PPSLock;
}

//UART 設定
void Initialize_UART(void)
{
UINT16 UxMODEvalue,UxSTAvalue;
CloseUART1();
ConfigIntUART1(UART_RX_INT_EN & UART_RX_INT_PR5 & UART_TX_INT_EN & UART_TX_INT_PR2);
UxMODEvalue = UART_EN & UART_IDLE_CON & UART_IrDA_DISABLE & \
UART_MODE_SIMPLEX & UART_UEN_00 & UART_DIS_WAKE & \
UART_DIS_LOOPBACK & UART_DIS_ABAUD & UART_UXRX_IDLE_ONE & \
UART_BRGH_FOUR & UART_NO_PAR_8BIT & UART_1STOPBIT;

UxSTAvalue = UART_INT_TX_BUF_EMPTY & UART_IrDA_POL_INV_ZERO & UART_SYNC_BREAK_DISABLED & \
UART_TX_ENABLE & UART_INT_RX_CHAR & UART_ADR_DETECT_DIS & \
UART_RX_OVERRUN_CLEAR;

OpenUART1(UxMODEvalue,UxSTAvalue,51); //38400 FCY=FOSC/2
/*UxBRG = ( (FCY/Desired Baud Rate)/4)-1
EX:((8MHz/38400)/4)-1=25
*/

CloseUART2();
ConfigIntUART2(UART_RX_INT_DIS & UART_RX_INT_PR0 & UART_TX_INT_EN & UART_TX_INT_PR2);

UxMODEvalue = UART_EN & UART_IDLE_CON & UART_IrDA_DISABLE & \
UART_MODE_SIMPLEX & UART_UEN_00 & UART_DIS_WAKE & \
UART_DIS_LOOPBACK & UART_EN_ABAUD & UART_UXRX_IDLE_ONE & \
UART_BRGH_SIXTEEN & UART_NO_PAR_8BIT & UART_1STOPBIT;

UxSTAvalue = UART_INT_TX_LAST_CH & UART_IrDA_POL_INV_ZERO & UART_SYNC_BREAK_DISABLED & \
UART_TX_ENABLE & UART_INT_RX_CHAR &UART_ADR_DETECT_DIS & \
UART_RX_OVERRUN_CLEAR;
OpenUART2(UxMODEvalue,UxSTAvalue,51); //9600
/*UxBRG = ( (FCY/Desired Baud Rate)/16)-1
EX:((8MHz/9600)/16)-1=51
*/
}


//UART RX中斷
void __attribute__((interrupt,no_auto_psv)) _U1RXInterrupt(void)
{
unsigned char Key_code;
IFS0bits.U1RXIF = 0;
Key_code = ReadUART1();
}

發表於: 2010/2/12 14:24
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... ]

教育訓練中心

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