Gast
#100195
Hi!
Ich habe da mal eine Frage zu den "Registerdeklarationen":
Ist es nicht so, daß alle Register per deklaration für den Compiler
flüchtig (volatile) sind? Würde diese Voraussetzung das "asm volatile
("nop"::);" in einer warte-while-schleife (was'n Wort :) obsolet
machen?
>#include <inttypes.h>
>#include <avr/interrupt.h>
>
>void my_eeprom_write_byte(uint16_t *addr, uint8_t val)
>{
> cli(); /* disable all ints */
> /* Wait for completion of previous write */
> while(EECR & (1<<EEWE)) asm volatile ("nop"::);
> /* Set up address and Data Registers */
> EEAR = *addr;
> EEDR = val;
> /* Write logical one to EEMWE */
> EECR |= (1<<EEMWE);
> /* Start eeprom write by setting EEWE */
> EECR |= (1<<EEWE);
> /* Wait for completion of this write */
> while(EECR & (1<<EEWE)) asm volatile ("nop"::);
> sei(); /* re-enable all ints */
>}
Aus nem anderen Thread kopiert, weil mir das bei dem Beispiel wieder
eingefallen ist - neue Frage, neuer Thread ;)
Gruß,
Patrick...