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


Browsing this Thread:   1 Anonymous Users






请版主和各位同行帮助解决一个485通讯的问题,急!!!
#1
新會員
新會員


查看用戶資訊
我现在用DSPIC30F6014作一个项目,在调试串口2时,遇到问题。请帮我看一下用串口2发送数据的测试程序。我现在用一个RS232转RS485的转换器进行调试,一端接PC机,一端接我的PCB板,调试中出现的问题是:发出去的数,接收的不对。我测试了RS232转RS485的转换器,收发没有问题。测试了我的PCB板上的RS485转换器DS75176B,没问题,我想请您看一下我的程序是否正确,哪位有已测试好的程序请给我发一份。谢谢!我的邮箱是:kscg1234@126.com

//*******************************************************************************//
int main(void)
{
INT8U i;
INIUART2();
commdelaynms(10);
for(;;)
//for(i=0;i<2;i++)
{
while(U2STAbits.UTXBF);
U2TXREG=0x01;
while(U2STAbits.TRMT==0);
IFS1bits.U2TXIF = 0;
U2STAbits.UTXBRK=1;
commdelaynms(20);
U2STAbits.UTXBRK=0;
commdelaynms(10);
}
}
//*******************************************************************************//
void INIUART2(void) //串口初始化
{
TRISCbits.TRISC14 =0; //RE
TRISFbits.TRISF5 =0; //TXD1
TRISFbits.TRISF4 =1; //RXD1
//TRISFbits.TRISF2 =1; //RXD0
//TRISFbits.TRISF3 =0; //TXD0
U2BRG =103;
U2MODE =0x0000;
//IEC1bits.U2RXIE=1;
IEC1bits.U2TXIE=1;
IPC6bits.U2TXIP=7;
IPC6bits.U2RXIP=5;
U2STAbits.UTXISEL=0;
U2MODE =0x8000; //使能UART
IFS1bits.U2TXIF = 1;
IFS1bits.U2RXIF = 1;
PORTCbits.RC14 =1; //使SN75176B处于发送状态
U2STAbits.UTXEN = 1; //使能发送
}
//***********************************************************************************//
//*********************************************************//
void __attribute__((__interrupt__)) _U2RXInterrupt(void)
{
IFS1bits.U2RXIF = 0;
}
//*********************************************************//
void _ISR _U2TXInterrupt()
{
IFS1bits.U2TXIF=0; //Reset uart interrupt flag
}
//*********************************************************//

發表於: 2006/5/19 11:03
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... ]

教育訓練中心

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