Browsing this Thread:
1 Anonymous Users
|
Re: 在請教uart的問題
|
|
版主
Joined
: 2004/4/30 10:53 最後登入時間
: 2021/11/30 18:11
From CAE, Microchip
Group:
站務管理者 註冊會員
Level : 75 HP : 744 / 1861 MP : 5367 / 111025 EXP : 45
|
因為有使用 PIC24F 的周邊函數庫,所以在 Project 的 Libraries 要加入其周邊函數庫。 C:\Program Files\Microchip\MPLAB C30\lib\PIC24F\libpPIC24Fxxx-coff.a
發表於: 2008/10/29 14:34
|
|
|
在請教uart的問題
|
|
新會員
Joined
: 2008/10/20 17:20 最後登入時間
: 2008/11/3 13:15
Group:
註冊會員
Level : 1 HP : 0 / 5 MP : 1 / 254 EXP : 21
|
一塊P24FJ16GA002電路板,有接一顆75176 RS485的IC,我想要透過這顆IC和電腦的RS232溝通,目前已經有RS232轉RS485的轉接頭了硬體方面改好了 目前剩下程式這塊不是很懂~請各位大大教導一下小弟 目前我的程式如下
#include<P24FXXXX.h> #include "uart.h" //#include "ReadUART1.h"
void Init_PORT(void); void isr_high(void); void Init_UART(void);
unsigned int Rec_Data;
int main( void ) {
Init_UART( ); // UART 模組測試程式 Init_PORT( ); isr_high( ); while(1); { if (Rec_Data=='s') // Received 's' from RS-232 { PORTB=0XF0; } if (Rec_Data=='p') // Received 'p' from RS-232 { PORTB=0XFF; } if (Rec_Data=='r') // Received 'r' Read Cmmand from RS-232 { PORTB=0X0F; } } }
/***********************************************/ // Subroutine to initialize UART module
void Init_UART(void) { U1BRG=95; //Set Baudrate IPC3bits.U1TXIP2 = 1; //Set Uart TX Interrupt Priority IPC3bits.U1TXIP1 = 0; IPC3bits.U1TXIP0 = 0; IPC2bits.U1RXIP2 = 1; //Set Uart RX Interrupt Priority IPC2bits.U1RXIP1 = 0; IPC2bits.U1RXIP0 = 0; U1STA = 0; U1STAbits.ADDEN = 1; //Address detect enabled U1MODE = 0x8080; //Enable Uart for 8-bit data //no parity,1 STOP bit,wake enabled// U1STAbits.UTXEN = 1; //Enable Transmit IEC0bits.U1TXIE = 1; //Enable Transmit Interrupt IEC0bits.U1RXIE = 1; // Enable RxD Interrupt// }
void Init_PORT(void) { PORTB=0x00; TRISB=0x00; // Set PORTB as Output port }
//#pragma interrupt isr_high
void isr_high(void) {
Rec_Data= ReadUART1( ); // Read data from Receiver FIFO }
編譯完就會出現 C:\pic\001\main.c:77: undefined reference to `ReadUART1' 是部會我沒有這各檔案的關係 還是是我程式哪裡出了問題 請各位前輩指導
發表於: 2008/10/29 11:03
|
|
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.