bugAVR C Runtime Library - Bugs: bug #13226, ERROR of PRINTF_LIB_FLOAT of...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #13226: ERROR of PRINTF_LIB_FLOAT of WinAVR-20050214.

Submitter:  None
Submitted:  Mon 30 May 2005 08:38:31 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid Assigned to:  None
Percent Complete:  0% Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  None
Fixed Release:  None

Tue 31 May 2005 09:24:36 AM UTC, comment #1: 

As replied in the mailing list: repeated calls to fdevopen()
without closing the handles eventually lead to malloc() running
out of space.

Joerg Wunsch <joerg_wunsch>
Group administrator
Mon 30 May 2005 08:38:31 AM UTC, original submission:  

email: -email is unavailable-
attn: Eric B. Weddington
from: rongjianwei/ rongjianwei@sina.com  /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
                  -email is unavailable-
**************************************************/

#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);
}
/****************************************************/










Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #3012:  4_1_6.rar added by None (14KiB - application/x-rar-compressed)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-05-31 joerg_wunsch StatusNone Invalid
    Open/ClosedOpen Closed
2005-05-30 None Attached File- Added 4_1_6.rar, #2550
    Carbon-Copy- Added rongjianwei --AT-- sina --DOT-- com

Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code