Browsing this Thread:
1 Anonymous Users
|
Re: RS-232 程式問題
|
|
中級會員
Joined
: 2007/12/26 17:11 最後登入時間
: 2009/6/16 14:53
Group:
註冊會員
Level : 6 HP : 0 / 128 MP : 17 / 6276 EXP : 12
|
問題已解決...抱歉...佔了版面......
發表於: 2008/11/18 16:07
|
|
|
RS-232 程式問題
|
|
中級會員
Joined
: 2007/12/26 17:11 最後登入時間
: 2009/6/16 14:53
Group:
註冊會員
Level : 6 HP : 0 / 128 MP : 17 / 6276 EXP : 12
|
下面是一段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
|
|
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.