» Advertenties

Wo 22 Februari 2012, 19:36

Hardware configuratie
PRG LED (programmer-ready) - PC0 (Actief hoog)
Busy LED - PD5 (Actief hoog)
Slow jumper - PC1 (Actief laag, met interne pullup weerstand)

C code -
  1. #define F_CPU 12000000
  2.  
  3.  
  4. #include "s/g.h"
  5. #include <util/delay.h>
  6.  
  7.  
  8.  
  9. int main(void){
  10.   // Init HW
  11.   // Both LEDs on
  12.   // Activate pull-up resistor for PC1 (slow-jumper)
  13.   sbi(PORTC, 0);
  14.   sbi(DDRC, 0);
  15.   sbi(PORTD, 5);
  16.   sbi(DDRD, 5);
  17.   sbi(PORTC, 1);
  18.   cbi(DDRC, 1);
  19.  
  20.   // both LEDs on for 1s
  21.   _delay_ms(1000);
  22.  
  23.   while(1){
  24.     // PRG-ready LED (C0) on for 400ms
  25.     // Busy LED (D5) off
  26.     cbi(PORTD, 5);    
  27.     sbi(PORTC, 0);
  28.     _delay_ms(400);
  29.  
  30.     // Only when the slow-jumper is shorted, the busy-LED will blink
  31.     if(!(PINC&(1<<1))){
  32.       sbi(PORTD, 5);
  33.     }
  34.     // PRG-led always during this part off the cycle
  35.     cbi(PORTC, 0);
  36.     _delay_ms(400);
  37.   }
  38.  
  39.   return 0;
  40. }
Nog geen reacties.
Naam
a-z A-Z 0-9 _

 
E-mail
Wordt niet getoont.
  (niet verplicht)
 
Mail sturen als
(optie)
Smoerijf reageerd
Eender wie reageaard
Nooit
 
Mail sturen
(optie)
Enkel mailen bij eerste reactie
Bij elke reactie mailen
 
Reactie
Laatste wijziging: Vr 12 November 2010, 22:23