Difference between revisions of "U23 2008/Gruppe1"
< U23 2008
m (Category) |
|||
Line 16: | Line 16: | ||
+ | ===Sourcecode, Projektabend2: === | ||
+ | #include <avr/io.h> | ||
+ | #include <util/delay.h> | ||
+ | |||
+ | #define GET_LAMPE(tl) ( (tl) & 0b11 ) | ||
+ | #define GET_ZEIT(tl) ( (tl) >> 2 ) | ||
+ | |||
+ | #define GET_TL(l,t) ( ((t)<<2) | ((l)&0b11) ) | ||
+ | |||
+ | void lampe(uint8_t l) | ||
+ | { | ||
+ | switch (l) | ||
+ | { | ||
+ | case 0: PORTC ^= _BV(PC4); | ||
+ | break; | ||
+ | case 1: PORTD ^= _BV(PD3); | ||
+ | break; | ||
+ | case 2: PORTD ^= _BV(PD6); | ||
+ | break; | ||
+ | case 3: PORTD ^= _BV(PD7); | ||
+ | break; | ||
+ | default: break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void zehntelsekunde(uint8_t f) | ||
+ | { | ||
+ | uint8_t i; | ||
+ | for (i = 0; i < 8*f; i++) | ||
+ | /* wait 4 * 65536 cycles */ | ||
+ | _delay_loop_2(0); | ||
+ | } | ||
+ | |||
+ | void schritt(uint8_t tl) | ||
+ | { | ||
+ | lampe(GET_LAMPE(tl)); | ||
+ | zehntelsekunde(GET_ZEIT(tl)); | ||
+ | } | ||
+ | |||
+ | |||
+ | void main(void) { | ||
+ | DDRC = _BV(PC4); | ||
+ | DDRD = _BV(PD3) | _BV(PD6) | _BV(PD7); | ||
+ | |||
+ | uint8_t ls[] = {GET_TL(0,10),GET_TL(2,20),GET_TL(1,50)}; | ||
+ | uint8_t p=0; | ||
+ | |||
+ | for ( ;p <3;p++) | ||
+ | schritt(ls[p]); | ||
+ | |||
+ | for ( ;; ) ; | ||
+ | |||
+ | } | ||
Revision as of 18:28, 25 August 2008
Contents
Gruppe1
Mitglieder:
-...(Hier eure Namen eintragen)
-Maike
-skullbocks
-Gesche
-Trella
-Smasher (Brille und anthrazit-farbenes dell notebook ;) )
Sourcecode, Projektabend2:
#include <avr/io.h> #include <util/delay.h>
#define GET_LAMPE(tl) ( (tl) & 0b11 ) #define GET_ZEIT(tl) ( (tl) >> 2 )
#define GET_TL(l,t) ( ((t)<<2) | ((l)&0b11) )
void lampe(uint8_t l) { switch (l) { case 0: PORTC ^= _BV(PC4); break; case 1: PORTD ^= _BV(PD3); break; case 2: PORTD ^= _BV(PD6); break; case 3: PORTD ^= _BV(PD7); break; default: break; } } void zehntelsekunde(uint8_t f) { uint8_t i; for (i = 0; i < 8*f; i++) /* wait 4 * 65536 cycles */ _delay_loop_2(0); }
void schritt(uint8_t tl) { lampe(GET_LAMPE(tl)); zehntelsekunde(GET_ZEIT(tl)); }
void main(void) { DDRC = _BV(PC4); DDRD = _BV(PD3) | _BV(PD6) | _BV(PD7); uint8_t ls[] = {GET_TL(0,10),GET_TL(2,20),GET_TL(1,50)}; uint8_t p=0; for ( ;p <3;p++) schritt(ls[p]); for ( ;; ) ; }
Sourcecode, Projektabend1:
/*Dieses Programm lässt ein bestimmtes Muster auf unserem Testboard ablaufen*/
#include <avr/io.h> #include <util/delay.h> void lampe(uint8_t l) { switch (l) { case 0: PORTC ^= _BV(PC4); break; case 1: PORTD ^= _BV(PD3); break; case 2: PORTD ^= _BV(PD6); break; case 3: PORTD ^= _BV(PD7); break; default: break; } } void main(void) { /* config PD7 as output */ DDRC = _BV(PC4); DDRD = _BV(PD3) | _BV(PD6) | _BV(PD7); uint8_t ls[] = {0, 1, 0, 2, 1, 3, 2, 1, 3}; uint8_t p=0; while(1) { //PORTD ^= _BV(PD7); uint8_t i; lampe(ls[p]); p++; for (i = 0; i < 76; i++) { /* wait 4 * 65536 cycles */ _delay_loop_2(0); } } for ( ;; ) ; }