[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #13226] ERROR of PRINTF_LIB_FLOAT of WinAVR-20050214
From: |
anonymous |
Subject: |
[avr-libc-dev] [bug #13226] ERROR of PRINTF_LIB_FLOAT of WinAVR-20050214. |
Date: |
Mon, 30 May 2005 08:38:32 +0000 |
User-agent: |
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) |
URL:
<http://savannah.nongnu.org/bugs/?func=detailitem&item_id=13226>
Summary: ERROR of PRINTF_LIB_FLOAT of WinAVR-20050214.
Project: AVR C Runtime Library
Submitted by: None
Submitted on: Mon 05/30/05 at 04:38
Category: None
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: None
Status: None
Privacy: Public
Percent Complete: 0%
Assigned to: None
Originator Email: address@hidden
Open/Closed: Open
_______________________________________________________
Details:
email: address@hidden
attn: Eric B. Weddington
from: rongjianwei/ address@hidden /Beijing,
China
subject: ERROR of PRINTF_LIB_FLOAT of WinAVR-20050214.
Good moring,
I have met a problem about "PRINTF_LIB_FLOAT". In the
endless loop, it will occur a problem. After running a
few minutes, the sentence of "printf("%5.1f
%9.2f\n",fahrenheit, (5.0/9.0) * (fahrenheit - 32.0))
" will display wrong characters. How to resolve it?
The Source Code as follows.
*********************************************************************************************
/***************************************************
Title: 4_1_6.c
Author: ÈÖ½¨Î°(rongjianwei)
Date: 2005/01/15
Purpose:
ͨ¹ý´®¿Ú¸ø¿ØÖÆ̨Êä³ö»ªÊÏÉãÊÏζȱ仯±í£¬µÚÈýÖÖ³ÌÐòд·¨¡£ÒýÈë·ûºÅ³£Á¿¡£
needed
Software: AVR-GCC
needed
Hardware:
Note: To contact me, mail to
address@hidden
****************************************************/
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/io.h>
/*
* System clock in Hz.
*/
#define SYSCLK 3686400UL //4000000 //14745600UL /*
Note [2] */
/*
* Compatibility defines. This should work on
ATmega8, ATmega16,
* ATmega163, ATmega323 and ATmega128 (IOW: on all
devices that
* provide a builtin TWI interface).
*
* On the 128, it defaults to USART0.
*/
#ifndef UCSRB
# ifdef UCSR0A /* ATmega128 */
# define UCSRA UCSR0A
# define UCSRB UCSR0B
# define UBRR UBRR0L
# define UDR UDR0
# else /* ATmega8 */
# define UCSRA USR
# define UCSRB UCR
# endif
#endif
#ifndef UBRR
# define UBRR UBRRL
#endif
#define lower 0 /* lower limit of table */
#define upper 300 /* upper limit */
#define step 20 /* step size */
void
ioinit(void)
{
UCSRB = _BV(TXEN); /* tx enable */
// UBRR = (SYSCLK / (16 * 9600UL)) - 1; /* 9600 Bd
4M¾§Õñ×î¸ßËÙÂÊ¿É´ï19200*/
// UBRR = (SYSCLK / (16 * 115200UL)) - 1; /* 115200
Bd */
UBRR = (SYSCLK / (16 * 57600UL)) - 1;
}
/*
* Note [4]
* Send character c down the UART Tx, wait until tx
holding register
* is empty.
*/
int
uart_putchar(char c)
{
if (c == '\n')
uart_putchar('\r');
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
int main(void)
{ /* print fahrenheit--celsius table for
f=0,20,'..,300 */
double fahrenheit;
double celsius;
ioinit();
for(;;){
fdevopen(uart_putchar, NULL, 0);
printf("Fahrenheit celsius\n");
printf("»ªÊÏ ÉãÊÏ\n"); // could not
display the chinese charaters(GB2312) 2004/08/10
for(fahrenheit = lower; fahrenheit <= upper;
fahrenheit = fahrenheit + step ){
printf("%5.1f %9.2f\n",fahrenheit, (5.0/9.0)
* (fahrenheit - 32.0));
}
}
return(0);
}
/****************************************************/
_______________________________________________________
Carbon-Copy List:
CC Address | Comment
------------------------------------+-----------------------------
rongjianwei --AT-- sina --DOT-- com | Originator Email
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Mon 05/30/05 at 04:38 Name: 4_1_6.rar Size: 13.58KB By: None
<http://savannah.nongnu.org/bugs/download.php?item_id=13226&item_file_id=2550>
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?func=detailitem&item_id=13226>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [avr-libc-dev] [bug #13226] ERROR of PRINTF_LIB_FLOAT of WinAVR-20050214.,
anonymous <=