// wait for a new character to arrive to the UART2 serial portchar 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

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}// main

May i know what do i need to change from the code above in order to display "CO2 READING" ?THANK YOU VERY MUCH.

Number one. b and c are char c[16],b; (as you defined them)when you will assign c to b, b will only contain the first character of b. you won't get all the characters in c, one by one into b, because what an array of char returns is always a pointer to the first element.what you want is b = c[ i];

Two. You ever heard about scope? If you declare a global variable gigi, it will be seen everywhere. If you'll declare a gigi variable inside function fute() it won't be seen outside fute(). You declared your variables in main(), so they are not global. However, you are using them inside another function. How do you expect THAT to work?

Alas, remember to declare variables used in both procedural code and interrupt as volatile, such as volatile int ana;

« Last Edit: October 10, 2008, 06:31:13 AM by izua »

Logged

Check out my homepage for in depth tutorials on microcontrollers and electronics.