[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] printf_P + PSTR("\n\r") does not seem to work, however (
From: |
Bernard Fouché |
Subject: |
[avr-gcc-list] printf_P + PSTR("\n\r") does not seem to work, however ("\r\n") is okay |
Date: |
Thu, 12 Aug 2004 12:26:32 +0200 |
Hi there.
Following a typo in a string, it seems that the sequence "\r\n" is not
correctly processed
by printf_P. I'm running the following code on a ATMEGA162V. The serial port
is setup at 4800 bps.
If I do printf_P(PSTR("\r\n")); everything is okay, however if I switch it
to "\n\r", I get no output. Did I miss something or is it a bug?
Thanks!
Bernard
// Uncomment the following define to show the problem
//#define SHOW_PROBLEM
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdio.h>
int myputc(char c)
{
/* output character to UART0 */
while ((UCSR0A & BV(UDRE0)) == 0)
wdt_reset();
UDR0 = c;
return 0;
}
int main()
{
wdt_enable(WDTO_2S);
// port_init();
// Quartz is at 4Mhz, go down to 1Mhz
cli();
CLKPR=0x80;
CLKPR=0x02;
sei();
// Setup UART
UCSR0B = 0x00;
UCSR0A = 0x00;
UBRR0L = 0x0C;
UBRR0H = 0x00;
UCSR0A = 0x00;
UCSR0B = (1<<RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
fdevopen(myputc,NULL,0);
printf_P(PSTR("\n\rHello 1!\n\r"));
printf_P(PSTR("\n\rHello 2!\n\r"));
#ifdef SHOW_PROBLEM
printf_P(PSTR("\r\nHello 3!\r\n"));
printf_P(PSTR("\r\nHello 4!\r\n"));
#endif
while(1)
wdt_reset();
}
- [avr-gcc-list] printf_P + PSTR("\n\r") does not seem to work, however ("\r\n") is okay,
Bernard Fouché <=
- Re: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem to work, however ("\r\n") is okay, Joerg Wunsch, 2004/08/12
- RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem to work,however ("\r\n") is okay, Bernard Fouché, 2004/08/12
- FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay], Bernard Fouché, 2004/08/12
- Re: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay], Theodore A. Roth, 2004/08/12
- Re: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay], E. Weddington, 2004/08/12
- Re: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay], E. Weddington, 2004/08/12
- RE: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay], Bernard Fouché, 2004/08/13
- Re: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay], Joerg Wunsch, 2004/08/13
- RE: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P +PSTR("\n\r") does not seem towork,however ("\r\n") is okay], Bernard Fouché, 2004/08/13