bitsurfer
Member level 3
- Joined
- Jul 19, 2012
- Messages
- 56
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Croatia
- Activity points
- 1,734
Hello,
I read a temperature from sensor 18b20 with ATmega32 like this:
This temperature value in 'i' is then showed with 7 segment display in my board.
Now I would like to send it to seial port to read in PC.
I setup communication OK but cant convert long unsigned integer to string and send it like bytes, one by one.
My approach:
Here I got compiling errors.
How to do that conversion and send bytes properly?
Exact error I get is:
I include <string.h> and <stdio.h> but compiler behaves like here is not sprintf?
I read a temperature from sensor 18b20 with ATmega32 like this:
Code:
unsigned long i;
unsigned char m;
io_init();
delay_ms((unsigned char)1600);
ds1820_reset();
while(1)
{
ds1820_start();
i = ds1820_read_temp();
i = (i * 1000) / 16;
... etc...
This temperature value in 'i' is then showed with 7 segment display in my board.
Now I would like to send it to seial port to read in PC.
I setup communication OK but cant convert long unsigned integer to string and send it like bytes, one by one.
My approach:
Code:
int t;
char temp[14] = {0};
sprintf(temp, "%ld", i);
for (t=0; t<strlen(temp); t++)
{
char *te;
strncpy(te, temp[t], 1);
}
USARTWriteChar(13);
USARTWriteChar(10);
Here I got compiling errors.
How to do that conversion and send bytes properly?
Exact error I get is:
Code:
C:\WinAVR-20100110\avr\lib\libc.a(vfprintf_std.o)||In function `vfprintf':| (.text.avr-libc+0xd4)||undefined reference to `__mulhi3'|
C:\WinAVR-20100110\avr\lib\libc.a(vfprintf_std.o)||In function `vfprintf':| (.text.avr-libc+0xe4)||undefined reference to `__mulhi3'|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
I include <string.h> and <stdio.h> but compiler behaves like here is not sprintf?
Last edited: