Hi Vincent, If I understand correctly, the word "volatile" itself is to tell the compiler not to ignore the statement. I am not sure if your statement is correct, but I have used
"asm volatile ("nop"::);" and the compiler never removed the "nop"s from code. Nayani --- On Thu, 2/19/09, Vincent Trouilliez <vincent.trouill...@modulonet.fr> wrote: From: Vincent Trouilliez <vincent.trouill...@modulonet.fr> Subject: [avr-gcc-list] How to force GCC to not to remove "nop" statements ? To: "avr-gcc-list@nongnu.org" <avr-gcc-list@nongnu.org> Date: Thursday, February 19, 2009, 11:31 PM Hi list, Like many people I guess, I am using in-lined "nop" asm statements to respect the timing of external devices, when toggling their control lines. In the case at hand I am driving a text LCD module, and the "Enable" line must be pulsed low for 250ns. void lcd_send_nibble(uint8_t data) { ... //pulse Enable line LCD_PORT |= LCD_E; __asm__ volatile("nop"); __asm__ volatile("nop"); __asm__ volatile("nop"); __asm__ volatile("nop"); LCD_PORT &= ~LCD_E; } My AVR was running at 8MHz, so an instruction cycle of 125ns, so two nop in-lined were spot on, just perfect, and it ran fine. Today I pushed the AVR (ATmega32) up to its maximum of 16MHz. So I now need 4 nops not two. So I did that.. and the LCD doesn't work reliably. Suspecting the problem, I went straight to the generated assembly, and horror, my 4 nop statements have disappeared ! I made a few trials. It appears that up to and including 3 nop statements, GCC leaves them alone. But if I put 4 of them, it removes them all ! Any way to instruct GCC to leave my 4 nops ? Am using avr-gcc 4.3.2 Regards, -- Vince _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
_______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list