KiuFelix
Newbie level 5
Hi all,
I am new in mikro-c compiler. I am trying to read temperature values and pass it to rs232 for logging. In my code, I am able to do so through UART1_WRITE() or even UART1_WRITE_TEXT(). I can out-put text well through UART1_WRITE_TEXT() though. Like UART1_WRITE_TEXT("test"). Data sent is test.Successful in this case. But passing values like UART1_WRITE_TEXT(12) or UART1_WRITE(12) I get pointer errors. How do one concatenate values in this case? Somebody help.Here is my code.
Kindly Locate
That is the area of interest.
Expected output is something like 20_N21_N22_N for normal temperature for example. 22,21 etc are the calculated temperature values.
Thanks in advance.
I am new in mikro-c compiler. I am trying to read temperature values and pass it to rs232 for logging. In my code, I am able to do so through UART1_WRITE() or even UART1_WRITE_TEXT(). I can out-put text well through UART1_WRITE_TEXT() though. Like UART1_WRITE_TEXT("test"). Data sent is test.Successful in this case. But passing values like UART1_WRITE_TEXT(12) or UART1_WRITE(12) I get pointer errors. How do one concatenate values in this case? Somebody help.Here is my code.
Code:
unsigned int t;
float temp;
void main(){
ADCON1 = 0x00;// Set all PORTA pins as analog
TRISA = 0xFF; // PORTA is input
TRISB = 0x00; // PORTB is output
PORTA=0; //clear PORTA
PORTB=0; //clear PORTB
PORTC=0; //clear PORTC
UART1_Init(9600);
Delay_ms(100);
while(1) {
PORTB=0; //clear PORTB
PORTC=0; //clear PORTC
t=ADC_Read(0);
Delay_ms(100);
temp=(t*500)/1023;
delay_us(100);
UART1_Write_Text(temp); //Output temperature values
delay_us(100);
if(temp>35){
PORTB.RB0=1;
UART1_Write_Text("_H");
}
else if(temp<10)
{
PORTB.RB0=0;
UART1_Write_Text("_L");
}
else
{
PORTB.RB0=0;
UART1_Write_Text("_N");
}
Delay_ms(400);
}
}
Kindly Locate
Code:
UART1_Write_Text(temp); //Output temperature values
Expected output is something like 20_N21_N22_N for normal temperature for example. 22,21 etc are the calculated temperature values.
Thanks in advance.