• 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: PIC24F的UART使用問題
#2
版主
版主


查看用戶資訊
暫時沒有時間可以一行一行的看程式,請先參考 203 PRC 教材裡的練習六,那裡有使用 PIC24FJ 的 UART 的說明與範例。

http://www.microchip.com.tw/modules/w ... nglefile.php?cid=4&lid=44

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


PIC24F的UART使用問題
#1
新會員
新會員


查看用戶資訊
使用PIC24FJ128GA006的IC,
板子頻率8MHz,Baud Rate設9600,
想從PC經RS232寫字元進IC並存入data1,data2,data3,data4,
但是在debug mode按下暫停並在watch視窗看值,但data都是0,
量測RX有看到從PC送進來的信號,
請問是那個環節出問題?
程式不知道是不是有進入中斷?在debug mode要如何查呢?
程式內容如下:


#include<P24FXXXX.h>
#include<stdio.h>


_CONFIG2(IESO_OFF & POSCMOD_HS & FNOSC_PRI& FCKSM_CSDCMD )
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx1 & FWDTEN_OFF & WINDIS_OFF )

#define INPUT 1
#define OUTPUT 0
#define Ctrl_U1RX TRISFbits.TRISF2
#define Ctrl_U1TX TRISFbits.TRISF3

int data1,data2,data3,data4;


void _ISR _U1RXInterrupt(void)
{
IFS0bits.U1RXIF = 0;
data1 = U1RXREG;
data2 = U1RXREG;
data3 = U1RXREG;
data4 = U1RXREG;
}


//-----------------------------------------------------------------------------
int main(void)
{
int WriteEnable = 0;
char Buff[64];
int Index = 0;
int Count = 0;

Ctrl_U1RX = INPUT ;
Ctrl_U1TX = OUTPUT ;
U1BRG = 25; // Baud-Rate = 9600 when Fcy = 4M , BRGH = 0
U1MODEbits.PDSEL = 0;
U1MODEbits.STSEL = 0; //Stop bit number = 1

U1STAbits.URXISEL = 3;

IPC2bits.U1RXIP = 4;
IFS0bits.U1RXIF = 0;
IEC0bits.U1RXIE = 1;

U1MODEbits.UARTEN = 1;
U1STAbits.UTXEN = 1;


Nop();
while(1) ;

}

//-----------------------------------------------------------------------------

發表於: 2008/9/29 15:23

Edited by g863989 on 2008年09月29日 15:51:55
Edited by g863989 on 2008年09月29日 15:52:40
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... ]

教育訓練中心

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