Re: 為何APP0001板之RS-232收不到資料?
|
||||
---|---|---|---|---|
初級會員
|
有的!在InitializeUSART()這個FUNCTION CALL就有設定了.
這個程式是修改WAP002LAB之ANS4內程式(放在init_MCU.c中),不過已經被我改成4800bps了.不過還是謝謝您! 更希望MicroChip的高手及版主們,可以幫忙解決! 謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝 /************************************************ //* Function: Initialize USART * //* - Initialize the RS-232 communication * //* - Disable Interrupr for TxD * //* - Enable Interrupt fro Rxd * //* - Format: 4800, N, 8, 1 * //************************************************ void InitializeUSART(void) { TRISCbits.TRISC7=1; // Set input for RXD TRISCbits.TRISC6=0; // Set output for TXD RCSTAbits.SPEN=1; // Enable USART Module 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 ,207); // Set SPBRG=207, Baud Rate = 4800 @16MHz IPR1bits.RCIP=1; // Set Receive of USART are High priority PIE1bits.RCIE=1; // Enable RxD Interrupt } [quote] Herry 寫道: Hello rtaur ... 我也是玩PIC沒有多久... 我想你的程式裡面沒有見到USART的設定的部份...如baud rate,USART_RX_INT_ON等....
發表於: 2005/3/31 10:22
|
|||
|
Re: 為何APP0001板之RS-232收不到資料?
|
||||
---|---|---|---|---|
新會員
|
Hello rtaur ...
我也是玩PIC沒有多久... 我想你的程式裡面沒有見到USART的設定的部份...如baud rate,USART_RX_INT_ON等.... OpenUSART( USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH ,129); 還有相對應的中斷致能的bit要設定或啟動喔... 這是我注意到的部份...如有錯誤請多多包含...也希望你寫程式順利囉!!!
發表於: 2005/3/31 8:41
|
|||
|
Re: 為何APP0001板之RS-232收不到資料?
|
||||
---|---|---|---|---|
初級會員
|
有沒想到人知道程式那裡有問題?
謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝!
發表於: 2005/3/30 19:23
|
|||
|
Re: 為何APP0001板之RS-232收不到資料?
|
||||
---|---|---|---|---|
初級會員
|
附上main.h的資料
//* 宣告所使用的含入檔 //*********************************************************** #include <p18f452.h> #include <delays.h> #include <stdlib.h> #include <string.h> #include <timers.h> #include <i2c.h> #include <adc.h> #include <usart.h> //* 函數原型宣告 //*********************************************************** // Declaration file for Main.c related subroutines void LCD_Temp_Update(void) ; void VT_100_Update(void ); void Print_Temperature(int Data); void Print_Byte(unsigned char Byte); void EEPROM_Update(void); void EE_Write (unsigned char, unsigned char); unsigned char EE_Read (unsigned char); void isr_high_direct(void); void isr_high(void); void isr_low_direct(void); void isr_low(void); // Declaration file for Init_MCU.c related subroutines void InitializePORT(void) ; void InitializeTMR1(void) ; void InitializeINTs(void) ; void InitializeAD(void) ; void InitializeUSART(void ); void Initialize_I2C_Master(void); // Declaration file for WAP_LCD.c related subroutines void OpenLCD (void) ; void WriteCmdLCD ( unsigned char ) ; void WriteDataLCD( unsigned char ) ; void putsLCD( char * ) ; void putrsLCD( const rom char * ) ; void putcLCD( unsigned char ) ; void puthexLCD( unsigned char ) ; void LCD_Set_Cursor( unsigned char , unsigned char ) ; void LCD_CMD_W_Timing( void ) ; void LCD_L_Delay( void ) ; void LCD_S_Delay( void ) ; void LCD_DAT_W_Timing ( void ) ; // Declaration file for Read_Temp.c related subroutines unsigned Read_TC74_Temperature(void) ; int Read_TC1047_Temperature( void); // Declaration file for VT100.c related subroutines void VT100_puthex(unsigned char); void VT100_Fill_Screen(unsigned char); void InitializeVT100(void); void VT100_ESC(void); void VT100_Clear_Screen(void); void VT100_Clear_Right (void ); void VT100_Clear_Line (void); void VT100_Cursor_Up (unsigned char Xn); void VT100_Cursor_Down (unsigned char Xn); void VT100_Cursor_Right (unsigned char Yn); void VT100_Cursor_Left (unsigned char Yn); void VT100_Cursor_Position (unsigned char Xn, unsigned char Yn); void VT100_Cursor_Index (void); void VT100_Cursor_R_Index (void); void VT100_Cursor_Home (void); void VT100_Cursor_N_Line (void); // Declaration file for Rec_Cmd.c related subroutines void Rec_Cmd_Check(void); void Modify_T2_Max(void); void Modify_T2_Min(void); void Cooling_Auto(void); void Cooling_Shutdown(void); int Get_3_Digital(void);
發表於: 2005/3/30 15:53
|
|||
|
為何APP0001板之RS-232收不到資料?
|
||||
---|---|---|---|---|
初級會員
|
以下是用rs-232接收來自終端機字元,
然後顯示在LCD之程式,且輸出到port D 為何都收不到,那裡出錯? 謝謝 #include "main.h" #pragma idata access My_RAM_2 near unsigned char Rec_Data=0; #pragma idata void main(void) { char Title[16]="The DATA System"+0x00; char p; // Initial portD TRISD=0x00; PORTD=0x00; OpenLCD(); InitializeUSART(); LCD_Set_Cursor(0,0); putsLCD(Title); LCD_Set_Cursor(1,0); putcLCD('R'); LCD_Set_Cursor(1,1); putcLCD(':'); while (1) { p=Rec_Data; LCD_Set_Cursor(1,3); putcLCD(p); PORTD=P; Delay10KTCYx(500); } } //************************************************ //* Function: isr_high_direct * //* - Direct execution to the actual * //* Hi-priority interrupt code. * //************************************************ #pragma code isrhighcode = 0x0008 void isr_high_direct(void) { _asm //begin in-line assembly goto isr_high //go to isr_high function _endasm //end in-line assembly } #pragma code //************************************************ //* Function: isr_high(void) * //* High priority interrupt: * //* - Received a serial data from RS-232 * //* Save the received data to buffer Rec_Data* //************************************************ #pragma interrupt isr_high void isr_high(void) { if (DataRdyUSART()) { Rec_Data=ReadUSART(); // Get RS-232 data } } #pragma code
發表於: 2005/3/30 7:39
|
|||
|