Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: C | Size: 0.52 KB | Hits: 149 | Expires: Never
Copy text to clipboard
  1. #include <avr/interrupt.h>
  2. #include <avr/io.h>
  3. #include <stdio.h>
  4.  
  5. int main(void)
  6. {
  7.  
  8.  
  9.         DIDR0 = 0x00;          
  10.  
  11.         DDRC  = 0x00;
  12.         DDRB  = 0xFF;
  13.  
  14.         PORTB = 0x00;
  15.  
  16.  
  17.         ADCSRA = (1 << ADEN) | (1 << ADATE) | (1 << ADIE) | (0b111 << ADPS0);
  18.         ADCSRB = 0x00;
  19.  
  20.         ADMUX = (0b00 << REFS0) | (1 << ADLAR) | (0x0 << MUX0);
  21.  
  22.         sei(); // Interrupt Enable
  23.  
  24.         ADCSRA |= (1 << ADSC); // Start first conversion
  25.        
  26.         while (1) {     }
  27.  
  28.         return 0;
  29. }
  30.  
  31. // PS2 Interrupt - Bit receive
  32. ISR(ADC_vect)
  33. {
  34.         PORTB = ~(1 << ((ADCH * 8) / 255));
  35. }