# HG changeset patch # User Matt Johnston # Date 1336487698 -28800 # Node ID e36ee3e156c1f41f30616413b7c8820c4062dcb6 # Parent e50091063890376691d5c0a6fb5bb19315cd6bb2 switch to atmega328 diff -r e50091063890 -r e36ee3e156c1 Makefile --- a/Makefile Mon May 07 00:14:53 2012 +0800 +++ b/Makefile Tue May 08 22:34:58 2012 +0800 @@ -17,8 +17,8 @@ # default_serial = "avrdoper" # FUSES ........ Parameters for avrdude to flash the fuses appropriately. -DEVICE = atmega8 -CLOCK = 8000000 +DEVICE = atmega328 +CLOCK = 1000000 PROGRAMMER = #-c stk500v2 -P avrdoper OBJECTS = main.o FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m diff -r e50091063890 -r e36ee3e156c1 main.c --- a/main.c Mon May 07 00:14:53 2012 +0800 +++ b/main.c Tue May 08 22:34:58 2012 +0800 @@ -18,8 +18,11 @@ // - number of sensors (and range?) // 1 second. we have 1024 prescaler, 32768 crystal. -static const uint8_t CNT2_COMPARE = 32; -static const int SECONDS_WAKE = 60; +#define SLEEP_COMPARE 32 +#define SECONDS_WAKE 60 + +#define BAUD 9600 +#define UBRR ((F_CPU)/16/(BAUD)-1) static int uart_putchar(char c, FILE *stream); static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, @@ -36,22 +39,22 @@ static uint8_t sec_count; static void -uart_init(unsigned int baud) +uart_init(unsigned int ubrr) { // baud rate - UBRRH = (unsigned char)(baud >> 8); - UBRRL = (unsigned char)baud; - UCSRB = (1<> 8); + UBRR0L = (unsigned char)ubrr; + UCSR0B = (1<