FAQ | Points | Add... | Recent posts | Search | Register | Log in


[atmega8] [c++] konwersja float-->char[]


Post new topic  Reply to topic      Main Page -> Forum Index -> Microcontrollers Generally -> [atmega8] [c++] konwersja float-->char[]
Author
Message
esnow
Poziom 13
Poziom 13


Joined: 30 Jun 2008
Posts: 140
Location: Poznań

Post#1 Post from the author of the topic 28 Jul 2009 16:06   

[atmega8] [c++] konwersja float-->char[]


witam,
mam problem z konwersją float'a na tablice charów.

Code:
char tablica[4];
sprintf(tablica, "%G", temp_in);
USART_Transmit(tablica[0]);
USART_Transmit(tablica[1]);
USART_Transmit(tablica[2]);
USART_Transmit(tablica[3]);


w terminalu pokazuje się tylko znak zapytania "?". sama funkcja USART_Transmit zaczerpnięta z noty katalogowej i działa np. dla tekiego fragmentu kodu:
Code:

char a[4] = "abcd";
USART_Transmit(a[0]);
USART_Transmit(a[1]);
USART_Transmit(a[2]);
USART_Transmit(a[3]);

w teminulu otrzymuje: abcd

i funkcja USART_Transmit():
Code:
void USART_Transmit( unsigned char data )
{
   while ( !( UCSRA & (1<<UDRE)) );             // Wait for empty transmit buffer
   UDR = data;                              // Put data into buffer, sends the data
}

Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 28 Jul 2009 16:06   





Back to top
   
Freddie Chopin
Poziom 25
Poziom 25


Joined: 12 Dec 2005
Posts: 7290
Location: Zawiercie

Post#2 28 Jul 2009 17:47   

Re: [atmega8] [c++] konwersja float-->char[]


No proszę! Że też nikt o tym nigdzie nie napisał!

http://www.google.com/search?client=opera&rls=pl&q=avr+gcc+sprintf+float&sourceid=opera&ie=utf-8&oe=utf-8

->

http://winavr.scienceprog.com/avr-gcc-tutorial/using-sprintf--function-for-float-numbers-in-avr-gcc.html

albo

http://www.elektroda.pl/rtvforum/topic1059204.html

ale kto by to czytał

4\/3!!
Back to top
   
Post new topic  Reply to topic      Main Page -> Forum Index -> Microcontrollers Generally -> [atmega8] [c++] konwersja float-->char[]
Page 1 of 1
Similar topics
Jak zmienić tekst char * nazwa na typ float w c++?? (4)
Tablica char na float - czy funkcja poprawna? (5)
[Keil] Char na float jak? (2)
[avr-gcc] Float -> char[] (5)
[STR912FAW44] int to char, float to char (4)
Konwersja float/double/int na char/string na microBlaze (2)
[stm32] konwersja typów (float-> char[]) (15)
Konwersja char* -> float - problem [avr/atmega8][c/winavr (9)
[WinAVR][C] Część całkowita z liczby FLOAT/DOUBLE na CHAR (5)
[C++] Konwersja float na int. (4)

Page generation time: 0.121 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed