avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] how is PGM_P supposed to be used?


From: Graham Davies
Subject: Re: [avr-chat] how is PGM_P supposed to be used?
Date: Fri, 10 Jan 2014 11:56:16 -0500

Britton Kerin wrote (in part):

... this ... prints garbage:
    PGM_P hello_string = "hello\n";
    printf_P (hello_string);

That's because it IS garbage. You have declared variable 'hello_string' as a pointer to program memory and then initialized it with the address of a string in data memory. What you need is this:

PGM_P hello_string = PSTR( "hello\n" );

Graham.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]