summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2014-10-23 21:36:56 +0200
committerFlorian Baumann <derflob@derflob.de>2014-10-23 21:36:56 +0200
commit0b6bc53bf73bcf4c8c71471c348503453eaa46eb (patch)
tree66480e20e0181b853dd954e138bb3bfdc80ef084
parentd9089467f9ae0ac09040784dc7f1393f3991c432 (diff)
downloadStripClock-0b6bc53bf73bcf4c8c71471c348503453eaa46eb.tar.gz
StripClock-0b6bc53bf73bcf4c8c71471c348503453eaa46eb.tar.bz2
attiny4313 adjustments
-rw-r--r--Makefile4
-rw-r--r--StripClock.c22
-rw-r--r--i2cmaster.S21
3 files changed, 27 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index c2a94b0..02e0b2a 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ AVRDUDE_MCU = t4313
# Main Oscillator Frequency
# This is only used to define F_OSC in all assembler and c-sources.
-F_OSC = 20000000
+F_OSC = 8000000
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -93,7 +93,7 @@ EXTRAINCDIRS =
CSTANDARD = -std=gnu99
# Place -D or -U options here
-CDEFS = -DF_CPU=20000000UL
+CDEFS = -DF_CPU=8000000UL
# Place -I options here
CINCS =
diff --git a/StripClock.c b/StripClock.c
index fca7176..174ff47 100644
--- a/StripClock.c
+++ b/StripClock.c
@@ -42,11 +42,14 @@ uint8_t updateStrip(void);
int main(void)
{
cli();
+ //set INT0 from sqw as input
+ PORTD &= ~(1 << DDD2);
+
//enable INT0 on falling edges
MCUCR |= (1 << ISC01);
- //enable INT0 on falling edges
+ //enable INT1 on falling edges
MCUCR |= (1 << ISC11);
- GIMSK |= ((1 << INT1) | (1 << INT0));
+ GIMSK |= ((1 << INT0) | (1 << INT1));
//set BTN_* as input and pull-ups high
BTN_INC_DDR &= ~(1 << BTN_INC);
@@ -54,8 +57,6 @@ int main(void)
BTN_MODE_DDR &= ~(1 << BTN_MODE);
BTN_MODE_PORT |= (1 << BTN_MODE);
- //set INT0 from sqw as input
- PORTD &= ~(1 << DDD2);
i2c_init();
@@ -65,9 +66,19 @@ int main(void)
ds1307_getDateTime(&dt);
+ dt.hour = 15;
+ dt.minute = 45;
+ dt.second = 0;
+ dt.year = 2014;
+ dt.month = 10;
+ dt.day = 23;
+
+ ds1307_setDateTime(&dt);
+ ds1307_getDateTime(&dt);
+
sei();
- for(;;) {
+ for (;;) {
if (mode == DM_NONE && updated) {
ds1307_getDateTime(&dt);
updateStrip();
@@ -142,7 +153,6 @@ ISR(INT1_vect)
mode++;
-
//ctc mode
TCCR1A = 0;
//ctc && precale 1024
diff --git a/i2cmaster.S b/i2cmaster.S
index 37ad5a3..bd6c3f6 100644
--- a/i2cmaster.S
+++ b/i2cmaster.S
@@ -68,10 +68,10 @@
; For I2C in normal mode (100kHz), use T/2 > 5us
; For I2C in fast mode (400kHz), use T/2 > 1.3us
;*************************************************************************
- .stabs "",100,0,0,i2c_delay_T2_
- .stabs "i2cmaster.S",100,0,0,i2c_delay_T2_
- .func i2c_delay_T2_ ; delay 5.0 microsec with 4 Mhz crystal
-i2c_delay_T2_: ; 4 cycles
+ .stabs "",100,0,0,i2c_delay_T2
+ .stabs "i2cmaster.S",100,0,0,i2c_delay_T2
+ .func i2c_delay_T2 ; delay 5.0 microsec with 4 Mhz crystal
+i2c_delay_T2: ; 4 cycles
rjmp 1f ; 2 "
1: rjmp 2f ; 2 "
2: rjmp 3f ; 2 "
@@ -82,14 +82,11 @@ i2c_delay_T2_: ; 4 cycles
ret ; 3 "
.endfunc ; total 20 cyles = 5.0 microsec with 4 Mhz crystal
- .func i2c_delay_T2 ; calling i2c_delay_T2_ five times gives about
- ; the right timing for 20Mhz crystals +- a bit.
-i2c_delay_T2:
- rcall i2c_delay_T2_
- rcall i2c_delay_T2_
- rcall i2c_delay_T2_
- rcall i2c_delay_T2_
- rcall i2c_delay_T2_
+ .func i2c_delay_T2a ; calling i2c_delay_T2_ two times gives about
+ ; the right timing for 8Mhz crystals +- a bit.
+i2c_delay_T2a:
+ rcall i2c_delay_T2
+ rcall i2c_delay_T2
ret
.endfunc