0

I have some problem with reading string from program memory:

const char str[] PROGMEM = "Test string here\r\n";

Here are my printing routines:

/** Send string over UART */
void uart_puts(char* str)
{
    while (*str) {
        uart_tx(*str++);
    }
}

/** Send progmem string over UART */
void uart_puts_pgm(const char* str)
{
    char c;
    while (0 != (c = pgm_read_byte(&str))) {
        uart_tx(c);
        str++;
    }
}

The normal one works just fine, but the progmem one prints infinite stream of 0xFF. Where is the mistake?

I've worked with progmem before, and it always worked.. I can't seem to find the problem here.

MightyPork
  • 18,270
  • 10
  • 79
  • 133

1 Answers1

0

D'oh, I shouldn't dereference the pointer there...

pgm_read_byte(&str)

should be just

pgm_read_byte(str)

It's working now.

MightyPork
  • 18,270
  • 10
  • 79
  • 133