From 4bc59d1a33bc5024cbb487c41536cd0904b27171 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 17 Dec 2017 10:53:38 +0100 Subject: [PATCH] Changed wrong CPU FREQ define to central correct one --- ds3231/twi-lowlevel.cpp | 2 +- ds3231/twi-lowlevel.h | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ds3231/twi-lowlevel.cpp b/ds3231/twi-lowlevel.cpp index aa051d7..c50f3b5 100644 --- a/ds3231/twi-lowlevel.cpp +++ b/ds3231/twi-lowlevel.cpp @@ -79,7 +79,7 @@ void twi_init(void) // initialize twi prescaler and bit rate cbi(TWSR, TWPS0); cbi(TWSR, TWPS1); - TWBR = ((CPU_FREQ / TWI_FREQ) - 16) / 2; + TWBR = ((F_CPU / TWI_FREQ) - 16) / 2; /* twi bit rate formula from atmega128 manual pg 204 SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR)) diff --git a/ds3231/twi-lowlevel.h b/ds3231/twi-lowlevel.h index d898f01..ec46eb1 100644 --- a/ds3231/twi-lowlevel.h +++ b/ds3231/twi-lowlevel.h @@ -22,11 +22,9 @@ #include -//#define ATMEGA8 +#include "clock.h" -#ifndef CPU_FREQ -#define CPU_FREQ 16000000L -#endif +//#define ATMEGA8 #ifndef TWI_FREQ #define TWI_FREQ 100000L