All pastes #1795889 Raw Edit

navaburo

public c v1 · immutable
#1795889 ·published 2010-02-14 03:12 UTC
rendered paste body
// demonstration of "volatile zeroing bug"//// run on an ATmega168//// note that this bug occurs with and without optimization//#define F_CPU 1000000UL#include<avr/io.h>#include<averlicht/usart.h>#include<inttypes.h>uint8_t a;volatile uint8_t b;void main ( void ) {	usart_init(12); 	a = 0;	usart_putc(a); // sends 0x00, as expected	b = 1;	usart_putc(b); // sends 0x01, as expected	b = 0;	usart_putc(b); // sends 0x31, a bug	b = 1;	b--;	usart_putc(b); // sends 0x00, as expected	while(1);}