From 92cb9ad8ba9c86d27cb725a007d503453d784c21 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Fri, 10 Feb 2017 22:00:11 +0100 Subject: [PATCH] Working version. NOW WITH UART DEBUG! --- AVR/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- AVR/makefile | 2 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/AVR/main.c b/AVR/main.c index 3e853b7..3eccf67 100644 --- a/AVR/main.c +++ b/AVR/main.c @@ -1,9 +1,34 @@ +#define F_CPU 8000000UL + #include "../avr-i2c-slave/I2CSlave.h" #include #include + #include -#define I2C_ADDR 0x30 +#define BAUDRATE 9600 +#define BAUD_PRESCALLER (((F_CPU / (BAUDRATE * 16UL))) - 1) + +#define I2C_ADDR 0x20 + +void USART_init(void){ + UBRR0H = (uint8_t)(BAUD_PRESCALLER>>8); + UBRR0L = (uint8_t)(BAUD_PRESCALLER); + UCSR0B = (1< 0) { PORTC |= 2 << 1; time_open -= 1; @@ -45,5 +82,10 @@ int main() { PORTC = 0; } _delay_ms(1); + if (i > 1000) { + char message[] = "Alive\n"; + USART_putstring(message); + i = 0; + } } } diff --git a/AVR/makefile b/AVR/makefile index 683efef..c1ec2fe 100644 --- a/AVR/makefile +++ b/AVR/makefile @@ -5,7 +5,7 @@ # (GNU make, BSD make, SysV make) -MCU = atmega88 +MCU = atmega328p FORMAT = ihex TARGET = main SRC = $(TARGET).c \