• 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: RS-232 程式問題
#2
中級會員
中級會員


查看用戶資訊
問題已解決...抱歉...佔了版面......

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


RS-232 程式問題
#1
中級會員
中級會員


查看用戶資訊
下面是一段RS-232的程式
會一直從RS-232丟出123然後當按下s就暫停 按下o就繼續
不過現在有個問題 就是build ok 程式也donwload了
可是利用終端機來開啟RS-232接收資料...
終端機畫面都沒東西(123)丟出來......
不知道是那邊有問題....
不曉得有沒有高手可以先幫我看一下程式是不是那邊不對?
PS. 設定是 N,8,1 9600


#include <p18f2221.h>
#include <usart.h>

#pragma config OSC=HS, BOR=OFF, BORV=2, PWRT=ON, WDT=OFF, LVP=OFF

unsigned char RX_Temp;

void Rx_isr(void);

struct Flag{
unsigned TxD :1;
}FLAGbits;

#pragma code high_vector=0x08
void high_interrupt(void)
{
_asm GOTO Rx_isr _endasm
}
#pragma code

#pragma interrupt Rx_isr
void Rx_isr(void)
{
PIR1bits.RCIF=0;
RX_Temp = ReadUSART();
if(RX_Temp=='o') FLAGbits.TxD=0;
if(RX_Temp=='s') FLAGbits.TxD=1;
}

void main()
{
OpenUSART(USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
64);

PIR1bits.RCIF=0;
IPR1bits.RCIP=1;
RCONbits.IPEN=1;
PIE1bits.RCIE=1;
INTCONbits.GIEH=1;

FLAGbits.TxD=0;

while(1){
while(FLAGbits.TxD==0){
WriteUSART(0x31);
while(BusyUSART());
WriteUSART(0x32);
while(BusyUSART());
WriteUSART(0x33);
while(BusyUSART());
WriteUSART(0x0D);
while(BusyUSART());
}
}
}

發表於: 2008/11/18 10:55
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... ]

教育訓練中心

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