[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] printf not working, i'm linking the libs
From: |
Carlos Becker |
Subject: |
[avr-gcc-list] printf not working, i'm linking the libs |
Date: |
Sat, 27 Mar 2004 10:06:03 -0300 |
Hi all..
I have a problem with printf. It's not working.. maybe it's the simulator
(proteus ISIS) but I don't know.. fputc() works perfectly, but for instance
fputs() doesn't.. I believe it's because fputs uses a char* and I don't know
where the strings are being stored..
Here is the program.. oh, and i'm linking with minimalistic printf support. I'm
using atmega8
#include <stdio.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
int USART_putc(char c)
{
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
int USART_getc(void)
{
while( !(UCSRA & (1<<RXC)) ); //wait for char
return (int)UDR;
}
FILE* USART_init(void)
{
UBRRH = 0; // 4800 bps @ 1MHz
UBRRL = 12;
UCSRB = (1<<RXEN) | (1<<TXEN);
UCSRC = (1<<URSEL) | (3<<UCSZ0);
return fdevopen(&USART_putc,&USART_getc,0);
}
int main(void)
{
unsigned char i;
FILE* USART_stream = USART_init();
fprintf(USART_stream,"sarasasa")); // THIS DOESN'T
work.. all that's sent is 0xFF and a leading 0x00
fputc('b',USART_stream); // this works perfectly
for (;;);
return 0;
}
thanks
carlos
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
- [avr-gcc-list] printf not working, i'm linking the libs,
Carlos Becker <=