lcd_init(); lcd_light(true); lcd_print(string1); lcd_nextline(); lcd_print_P(PSTR("I2CLCD V0.11")); // always set all three parameters (ON/OFF) when using this command lcd_command(LCD_DISPLAYON | LCD_CURSORON | LCD_BLINKINGON); _delay_ms(1000); lcd_command(
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
verschickt wird. Text kannst Du dann zB mit printf("Wert: %u", var); oder printf_P(PSTR("Wert: %u"), var); aussenden. Die richtige Library muß natürlich auch dazu gelinkt werden. Siehe Doku. Volkmar
und die zeiger direkt auf den flash-bereich zeigen. laut den beispielen geht sowas für fkt mit PSTR. aber dieser mechanismus versagt natürlich bei dem o.g. beispiel. ich brauche das, da ich (mal wieder) exzessiv mit dem präprozessor hantiere, der code der ausgespuckt wird aber dafür sorgt das der
ganz hülfreich. Gern übersehen wird, daß string literals standardmäßig (also wenn sie nicht via PSTR() deklariert werden und einer auf _P endenden Routine übergeben werden) auch RAM benötigen (damit sie mit den normalen String-Funktionen aus <string.h> kompatibel sind). Vielleicht hast Du davon
ks0108ClearScreen(); // Set a position ks0108GotoXY(15,10); // Print some text ks0108Puts_P(PSTR("www.mikrokontroller.net")); // a nice little round rect ks0108DrawRoundRect(5, 5, 117, 20, 8, BLACK); }
ob Schleife bis hierher gelangt, wenn ja, wird uart_gets abgearbeitet lcd_puts_p(small_font,PSTR("Line")); _delay_ms(12000); lcd_clear(); _delay_ms(1500); } return 0; } [/C]
ks0108ReadFontData, BLACK); // Set a position ks0108GotoXY(1,1); // Print some text ks0108Puts_P(PSTR("Hallo Welt -> 1")); // a nice little round rect ks0108DrawRoundRect(5, 5, 117, 20, 8, BLACK); wait(1); ... ------------- Richtig eingebunden sind die Dateien, denn immerhin bekomme
automatically put a string constant into program memory */ #define uart0_puts_P(__s) uart0_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
1 unknown type name 'prog_char' In der entsprechende Zeile steht: DisplayStr(const prog_char* pstr); und diese Datei ist eingebunden #include <avr/pgmspace.h> In der pgmspace.h ist das prog_char auch enthalten. Weiß jemand, wieso das AVR Studio 6 mit einmal darüber stolpert und wie ich es zum
Bootloadersektor vom Atmega (0x1E000), setzt memcpy alle bits auf 1. memcpy_P(uip_ethaddr.addr, PSTR("ac:de:48:fd:0f:d0"), 6); Da kommt dann wenn es in der bootloader section steht nurnoch ff:ff:ff:ff:ff:ff raus... im unteren Programmspeicher klappts problemlos. memcpy(uip_ethaddr.addr, "ac:de
ich hab mir für strings immer die LCD funktionen gleich als lcd_P() gebastelt aufruf dann lcd_P( PSTR("text") ); oder eben über arrays im flash bei sehr vielen menütexten und einen zeiger drauf aber auch hier brauch man fast nur lcd_P ebenso UART_P wenn ich strings verschicken will .. alles
Ersetze alle Vorkommnisse von strcmp (Variable, "abcdefgh") durch strcmp_P (Variable, PSTR("abcdefgh")) Dann bleiben die Stringkonstanten im Flash. Das Makro PSTR liefert eine Adresse aus dem Flash und nicht aus dem RAM zurück, strcmp_P() ist die äquivalente Form von strcmp, liest aber
deutlich mehr drin: [c] int isodd(int a) { char buf[7]; int n; n = snprintf_P(buf,6,PSTR("%i"),a); return buf[--n]=='1'; } [/c] So versteht es selbst ein Grundschüler.