• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::

論壇索引


Board index » All Posts (Issac)




詢問pic18f452 USART傳送問題
#11
新會員
新會員


void isr_high(void)
{
Rec_Data=ReadUSART(); Data_Buffer[i]=Rec_Data;
Data_Temp[j]=Data_Buffer[i];
if(Data_Temp[12]==0xA7 && Data_Temp[13]==0xA5 && Data_Temp[14]==0x5A )
{
while(TXSTAbits.TRMT=0);
putcUSART(0xA7);
while(TXSTAbits.TRMT=0);
putcUSART(0xA5);
while(TXSTAbits.TRMT=0);
putcUSART(0x5A);
}
if (i<3)
{
i++;
}
else
{
i=0;
}
j++;
}

這是我進入中斷後的副程式,當我判斷得知收到的資料為A7A55A時
我必須接著回傳A7A55A給傳輸端
但是當我使用MPLAB IDE的Watch來觀看TXREG這個變數時
雖然都有跟隨我的指令動作
可是在我使用邏輯分析儀實際測量USART的TX腳位時卻遲遲收不到訊號
所以想要請問各位大大這是那邊出了問題
還請麻煩一解迷津
下面是我USART的Initialize的Code
void InitializeUSART(void)
{
OpenUSART( USART_TX_INT_OFF // Set TXSTA Reg. =0b00100100
& USART_RX_INT_ON // Set RCSTA Reg. =0b10010000
& USART_ASYNCH_MODE
& USART_EIGHT_BIT
& USART_CONT_RX
& USART_BRGH_HIGH
,103); // Set SPBRG=103, Baud Rate = 9600

RCSTAbits.SPEN=1;
TRISCbits.TRISC7=1; // Set input for RXD
TRISCbits.TRISC6=0; // Set output for TXD
TXSTA=0b00100100;
PIR1bits.RCIF=0;
PIR1bits.TXIF=0;
IPR1bits.RCIP=1; // Set Receive of USART are High priority
}

發表於: 2007/3/20 22:02
頂部



« 1 (2)



:::

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... ]

教育訓練中心

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