From b9a7ad4a88fad4e0f2cfb2f4602250386ca379cc Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Fri, 25 Dec 2009 17:55:36 +0200 Subject: [PATCH] Example of writing value directly to PORTD. --- til311/firmware/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/til311/firmware/main.c b/til311/firmware/main.c index decc656..041efcc 100644 --- a/til311/firmware/main.c +++ b/til311/firmware/main.c @@ -36,7 +36,12 @@ int main(void) { while (value < 16) { /* Toggle led at PORTB5 */ PORTB ^= _BV(PORTB5); - + + /* Short way would be to directly write the value to PORTD. */ + /* Shift by 2 because first TIL311 port is PORTD2. However */ + /* This would zero PORTD0, PORTD1, PORTD6 and PORTD7. */ + /* PORTD = value << 2; */ + /* TIL311 pin 3, latch data input A (1). */ if (0 == BIT_AT(value, 0)) { PORTD &= ~(_BV(PORTD2)); @@ -64,6 +69,7 @@ int main(void) { } else { PORTD |= _BV(PORTD5); } + value++; _delay_ms(500); }