Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /*
  2. * c_praks.c
  3. *
  4. * Created: 20.04.2018 10:10:02
  5. * Author : Tudeng
  6. */
  7.  
  8. #include <avr/io.h>
  9.  
  10.  
  11. int main(void){
  12. DDRA = 0xFF;
  13.  
  14. MCUCR |= (1<<JTD);
  15. MCUCR |= (1<<JTD);
  16.  
  17. DDRF = (0<<PF3) | (0<<PF5);
  18. PORTF = (1<<PF3) | (1<<PF5);
  19.  
  20. while(1)
  21. {
  22. if ((PINF & (1<<PF5)) == 0){
  23. if (PORTA == 0b10000000){
  24. PORTA = 1;
  25.  
  26. while ((PINF & (1<<PF5)) == 0){
  27. for (uint16_t i=0; i!=500; i++){
  28. asm volatile("nop");
  29. }
  30. }
  31. }
  32. else{
  33. PORTA = PORTA<<1;
  34.  
  35. while ((PINF & (1<<PF5)) == 0){
  36. for (uint16_t i=0; i!=500; i++){
  37. asm volatile("nop");
  38. }
  39. }
  40. }
  41. }
  42. if (!(PINF & (1<<PF3))){
  43. if (PORTA == 1){
  44. PORTA = 0b10000000;
  45.  
  46. while ((PINF & (1<<PF3)) == 0){
  47. for (uint16_t i=0; i!=500; i++){
  48. asm volatile("nop");
  49. }
  50. }
  51. }
  52. else{
  53. PORTA = PORTA>>1;
  54.  
  55. while ((PINF & (1<<PF3)) == 0){
  56. for (uint16_t i=0; i!=500; i++){
  57. asm volatile("nop");
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement