Tom2
Full Member level 5
I try to implement a standard uart communication using p33fj64gp802.h microcontroller.
The code which i use is presented bellow :
The problem is that some errors appear :
In function 'initU2':
error: 'TRISFbits' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
error: 'RTS' undeclared (first use in this function)
In function 'putU2':
'_RF12' undeclared (first use in this function)
In function 'getU2':
'RTS' undeclared (first use in this function)
warning: no newline at end of file
Is anyone who know how to fix these errors??????
The code which i use is presented bellow :
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 #include <libpic30.h> #include <p33fj64gp802.h> #include <stdio.h> #include <math.h> #define CTS _RF12 //#define RTS _RF13 #define TRTS TRISFbits.TRISF13 // timing and baud rate calculations #define BRATE 34 // 115200 baud (BREGH=1) #define U_ENABLE 0x8008 // enable the UART peripheral (BREGH=1) #define U_TX 0x0400 // enable transmission // initialize the UART2 serial port void initU2( void) { U2BRG = BRATE; U2MODE = U_ENABLE; U2STA = U_TX; TRTS = 0; // make RTS output RTS = 1; // set RTS default status } // initU2 // send a character to the UART2 serial port int putU2( int c) { while ( CTS); // wait for !CTS, clear to send while ( U2STAbits.UTXBF); // wait while Tx buffer full U2TXREG = c; return c; } // putU2 // wait for a new character to arrive to the UART2 serial port char getU2( void) { RTS = 0; // assert Request To Send !RTS while ( !U2STAbits.URXDA); // wait for a new character to arrive RTS = 1; return U2RXREG; // read the character from the receive buffer }// getU2 int main() { char c; // 1. init the UART2 serial port initU2(); // 2. prompt putU2( '>'); // 3. main loop while ( 1) { // 3.1 wait for a character c = getU2(); // 3.2 echo the character putU2( c); } // main loop return 0; }
The problem is that some errors appear :
In function 'initU2':
error: 'TRISFbits' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
error: 'RTS' undeclared (first use in this function)
In function 'putU2':
'_RF12' undeclared (first use in this function)
In function 'getU2':
'RTS' undeclared (first use in this function)
warning: no newline at end of file
Is anyone who know how to fix these errors??????
Last edited by a moderator: