Difference between revisions of "U23 2008/Gruppe1"

From C4 Wiki
Jump to: navigation, search
(Sourcecode, Projektabend2:)
(Sourcecode, Projektabend1:)
Line 135: Line 135:
  
 
===Sourcecode, Projektabend1: ===
 
===Sourcecode, Projektabend1: ===
 
+
<source lang="c">
 
/*Dieses Programm lässt ein bestimmtes Muster auf unserem Testboard ablaufen*/
 
/*Dieses Programm lässt ein bestimmtes Muster auf unserem Testboard ablaufen*/
  
Line 178: Line 178:
 
   
 
   
 
  }
 
  }
 
+
</source>
  
 
===Sourcecode,TEST: ===
 
===Sourcecode,TEST: ===

Revision as of 12:00, 26 August 2008

Gruppe1

Hier eine Neuerung zum Einfügen von Sourcecode:
Bisher wurde der Code zerpflückt, wenn nicht vor jeder Zeile eine "Leertaste" stand.
Nun kann man per <source lang ="language"> HIER KOMMT DER CODE REIN!</source>
wunderbar der Code eingefügt werden und er wird, wie formatiert eingefügt, dargestellt!
Für C verwendet man "c" und für assembler "asm".

Mitglieder:


-...(Hier eure Namen eintragen)
-Maike
-skullbocks
-Gesche
-Trella
-Smasher (Brille und anthrazit-farbenes dell notebook ;) )


Taster

<source lang="c">

//CODE ANFANG

#include <avr/io.h>
#include <util/delay.h>

uint8_t zeit;
uint8_t richtung;
uint8_t anaus;

uint8_t t0, temp0;

/*void lauflicht(void)
{
  
}*/ 

void main(void)
{
  DDRC &= ~(_BV(PC0)|_BV(PC1)|_BV(PC2)|_BV(PC3)); //Schalter
  DDRC &= _BV(PC4); //Lampe4
  DDRD &= _BV(PD3) | _BV(PD6) | _BV(PD7); //Lampe 1-3
  PORTC = _BV(PC0)|_BV(PC1)|_BV(PC2)|_BV(PC3); //Pullups


  t0= 0;
  anaus = 0x00; //0x00 = aus; 0xff = an

  _delay_loop_2(0); //Kurz warten, bis pullups ready

 while(1){
  	temp0 = PINC & _BV(PC0);
	_delay_loop_2(0);
	if((PINC & _BV(PC0)) == temp0){

t0 = temp0;

	}

	if (t0 == 0)

PORTD = 128; else PORTD = 0;


}
 
 

}



/*if( (PINC & _BV(PC0)) == 0){ _delay_loop_2(0); if( (PINC & _BV(PC0)) == 0 ){ //anaus != anaus; PORTD = 0xff; }

 }*/

//CODE ENDE!

</source>

Sourcecode, Projektabend2:

<source lang="c">

 #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 ( ;; ) ;
  }

</source>

Sourcecode, Projektabend1:

<source lang="c"> /*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 ( ;; ) ;

}

</source>

Sourcecode,TEST:

<source lang="asm">

.def temp = r16 .def temp1=r20 .equ enable=5 .equ rs=4 .equ LCD_PORT = PORTD .equ LCD_DDR = DDRD

.org 0x0000

       rjmp    main

</source>