Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Get readable temperature on serial port ATmega32, C

Status
Not open for further replies.

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:

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:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top