/* --------------------------------------------------------------------------- ** This software is in the public domain, furnished "as is", without technical ** support, and with no warranty, express or implied, as to its usefulness for ** any purpose. ** ** ioisr.c ** ** Beschrijving: ISR on PORTD demonstrattion ** Target: AVR mcu ** Build: avr-gcc -std=c99 -Wall -O3 -mmcu=atmega128 -D F_CPU=8000000UL -c ioisr.c ** avr-gcc -g -mmcu=atmega128 -o ioisr.elf ioisr.o ** avr-objcopy -O ihex ioisr.elf ioisr.hex ** or type 'make' ** Author: dkroeske@gmail.com ** -------------------------------------------------------------------------*/ #define F_CPU 8000000UL //CPU op 8MHz #include #include #include int opdr; /******************************************************************/ void wait( int ms ) /* short: Busy wait number of millisecs inputs: int ms (Number of millisecs to busy wait) outputs: notes: Busy wait, not very accurate. Make sure (external) clock value is set. This is used by _delay_ms inside util/delay.h Version : DMK, Initial code *******************************************************************/ { for (int i=0; i>1); else PORTC = (PORTC<<1); //Als het looplicht aan het einde is if (PORTC >= 0x80) { PORTC= 0x01; } //Als het looplicht aan het begin is else if (PORTC < 0x1) { PORTC= 0x80; } } void opgave3() { DDRC = 0x00; DDRD = 0xFF; int count = 0; while(1) { if(0b00000001 & PINC == 0b00000001) { count++; } else if(0b00000010 & PINC == 0b00000010) { count--; } if(count > 15) display(14); else if(count < 0) display(14); else display(count); } } void display(int d) { PORTD = data[d]; }