Advertisement
avr_programmieren_rh

Bitmanipulation

Feb 25th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. /*
  2.  * BitmanipulationVT018.c
  3.  *
  4.  * Created: 04.12.17 11:24:32
  5.  * Author : Hiestermann
  6.  */
  7. #ifndef F_CPU                                                   // Hier wird abgefragt ob F_CPU schon definiert ist
  8. #define F_CPU 18432000                                          // wenn F_CPU noch nicht definiert war, wird es hier mit 18,432MHz nachgeholt
  9. #warning "F_CPU war nicht definiert, wurde jetzt nachgeholt"    // und zusätzlich eine Warnung ausgegeben
  10. #endif
  11.  
  12. #include <avr/io.h>
  13. #include <util/delay.h>
  14.  
  15. int main(void)
  16. {   MCUCR |=0x10;           //Disable pull up
  17.     DDRD=0xFF;              //Setzte Port D auf Ausgang
  18.     PORTD=0b11111111;       //Setze alle bits auf High
  19.     while (1)
  20.     {      
  21.         PORTD&=0b10101010;  // 11111111 Wird mit 10101010 UND Verknüpft
  22.         _delay_ms(1000);    // 1s Warten
  23.         PORTD|=0b01010101;  // ERGEBNIS 101010101 wird mit 0101010101 ODER Verknüpft ERGEBNIS ?
  24.         _delay_ms(1000);    // 1s Warten
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement