GATE - Hightechrobo Bin
  CPP   46

GATE

Guest on 6th June 2022 12:15:05 PM

  1. /*******************************************************
  2. This program was created by the
  3. CodeWizardAVR V3.12 Advanced
  4. Automatic Program Generator
  5. © Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l.
  6. http://www.hpinfotech.com
  7.  
  8. Project :
  9. Version :
  10. Date    : 6/6/2022
  11. Author  :
  12. Company :
  13. Comments:
  14.  
  15.  
  16. Chip type               : ATmega32A
  17. Program type            : Application
  18. AVR Core Clock frequency: 8.000000 MHz
  19. Memory model            : Small
  20. External RAM size       : 0
  21. Data Stack size         : 512
  22. *******************************************************/
  23.  
  24. #include <mega32a.h>
  25.  
  26. // Declare your global variables here
  27.  
  28. void main(void)
  29. {
  30. // Declare your local variables here
  31.  
  32. // Input/Output Ports initialization
  33. // Port A initialization
  34. // Function: Bit7=Out Bit6=In Bit5=Out Bit4=In Bit3=In Bit2=Out Bit1=In Bit0=In
  35. DDRA=(1<<DDA7) | (0<<DDA6) | (1<<DDA5) | (0<<DDA4) | (0<<DDA3) | (1<<DDA2) | (0<<DDA1) | (0<<DDA0);
  36. // State: Bit7=0 Bit6=T Bit5=0 Bit4=T Bit3=T Bit2=0 Bit1=T Bit0=T
  37. PORTA=(0<<PORTA7) | (0<<PORTA6) | (0<<PORTA5) | (0<<PORTA4) | (0<<PORTA3) | (0<<PORTA2) | (0<<PORTA1) | (0<<PORTA0);
  38.  
  39. // Port B initialization
  40. // Function: Bit7=In Bit6=In Bit5=Out Bit4=In Bit3=In Bit2=Out Bit1=In Bit0=In
  41. DDRB=(0<<DDB7) | (0<<DDB6) | (1<<DDB5) | (0<<DDB4) | (0<<DDB3) | (1<<DDB2) | (0<<DDB1) | (0<<DDB0);
  42. // State: Bit7=T Bit6=T Bit5=0 Bit4=T Bit3=T Bit2=0 Bit1=T Bit0=T
  43. PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);
  44.  
  45. // Port C initialization
  46. // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=Out
  47. DDRC=(0<<DDC7) | (0<<DDC6) | (0<<DDC5) | (0<<DDC4) | (0<<DDC3) | (0<<DDC2) | (0<<DDC1) | (1<<DDC0);
  48. // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=0
  49. PORTC=(0<<PORTC7) | (0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0);
  50.  
  51. // Port D initialization
  52. // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In
  53. DDRD=(0<<DDD7) | (0<<DDD6) | (0<<DDD5) | (0<<DDD4) | (0<<DDD3) | (0<<DDD2) | (0<<DDD1) | (0<<DDD0);
  54. // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
  55. PORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) | (0<<PORTD3) | (0<<PORTD2) | (0<<PORTD1) | (0<<PORTD0);
  56.  
  57. // Timer/Counter 0 initialization
  58. // Clock source: System Clock
  59. // Clock value: Timer 0 Stopped
  60. // Mode: Normal top=0xFF
  61. // OC0 output: Disconnected
  62. TCCR0=(0<<WGM00) | (0<<COM01) | (0<<COM00) | (0<<WGM01) | (0<<CS02) | (0<<CS01) | (0<<CS00);
  63. TCNT0=0x00;
  64. OCR0=0x00;
  65.  
  66. // Timer/Counter 1 initialization
  67. // Clock source: System Clock
  68. // Clock value: Timer1 Stopped
  69. // Mode: Normal top=0xFFFF
  70. // OC1A output: Disconnected
  71. // OC1B output: Disconnected
  72. // Noise Canceler: Off
  73. // Input Capture on Falling Edge
  74. // Timer1 Overflow Interrupt: Off
  75. // Input Capture Interrupt: Off
  76. // Compare A Match Interrupt: Off
  77. // Compare B Match Interrupt: Off
  78. TCCR1A=(0<<COM1A1) | (0<<COM1A0) | (0<<COM1B1) | (0<<COM1B0) | (0<<WGM11) | (0<<WGM10);
  79. TCCR1B=(0<<ICNC1) | (0<<ICES1) | (0<<WGM13) | (0<<WGM12) | (0<<CS12) | (0<<CS11) | (0<<CS10);
  80. TCNT1H=0x00;
  81. TCNT1L=0x00;
  82. ICR1H=0x00;
  83. ICR1L=0x00;
  84. OCR1AH=0x00;
  85. OCR1AL=0x00;
  86. OCR1BH=0x00;
  87. OCR1BL=0x00;
  88.  
  89. // Timer/Counter 2 initialization
  90. // Clock source: System Clock
  91. // Clock value: Timer2 Stopped
  92. // Mode: Normal top=0xFF
  93. // OC2 output: Disconnected
  94. ASSR=0<<AS2;
  95. TCCR2=(0<<PWM2) | (0<<COM21) | (0<<COM20) | (0<<CTC2) | (0<<CS22) | (0<<CS21) | (0<<CS20);
  96. TCNT2=0x00;
  97. OCR2=0x00;
  98.  
  99. // Timer(s)/Counter(s) Interrupt(s) initialization
  100. TIMSK=(0<<OCIE2) | (0<<TOIE2) | (0<<TICIE1) | (0<<OCIE1A) | (0<<OCIE1B) | (0<<TOIE1) | (0<<OCIE0) | (0<<TOIE0);
  101.  
  102. // External Interrupt(s) initialization
  103. // INT0: Off
  104. // INT1: Off
  105. // INT2: Off
  106. MCUCR=(0<<ISC11) | (0<<ISC10) | (0<<ISC01) | (0<<ISC00);
  107. MCUCSR=(0<<ISC2);
  108.  
  109. // USART initialization
  110. // USART disabled
  111. UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (0<<RXEN) | (0<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
  112.  
  113. // Analog Comparator initialization
  114. // Analog Comparator: Off
  115. // The Analog Comparator's positive input is
  116. // connected to the AIN0 pin
  117. // The Analog Comparator's negative input is
  118. // connected to the AIN1 pin
  119. ACSR=(1<<ACD) | (0<<ACBG) | (0<<ACO) | (0<<ACI) | (0<<ACIE) | (0<<ACIC) | (0<<ACIS1) | (0<<ACIS0);
  120. SFIOR=(0<<ACME);
  121.  
  122. // ADC initialization
  123. // ADC disabled
  124. ADCSRA=(0<<ADEN) | (0<<ADSC) | (0<<ADATE) | (0<<ADIF) | (0<<ADIE) | (0<<ADPS2) | (0<<ADPS1) | (0<<ADPS0);
  125.  
  126. // SPI initialization
  127. // SPI disabled
  128. SPCR=(0<<SPIE) | (0<<SPE) | (0<<DORD) | (0<<MSTR) | (0<<CPOL) | (0<<CPHA) | (0<<SPR1) | (0<<SPR0);
  129.  
  130. // TWI initialization
  131. // TWI disabled
  132. TWCR=(0<<TWEA) | (0<<TWSTA) | (0<<TWSTO) | (0<<TWEN) | (0<<TWIE);
  133.  
  134. while (1)
  135.       {  
  136.       //AND
  137.       if(PINA.0 && PINA.1)
  138.       PORTA.2=1;
  139.       else
  140.       PORTA.2=0;
  141.      
  142.       //or
  143.       if(PINA.3 || PINA.4)
  144.       PORTA.5=1;
  145.       else
  146.       PORTA.5=0;
  147.      
  148.      
  149.       //AND
  150.       if(PINA.6)
  151.       PORTA.7=0;
  152.       else
  153.       PORTA.7=1;
  154.      
  155.       //nAND
  156.       if(PINB.0 && PINB.1)
  157.       PORTB.2=0;
  158.       else
  159.       PORTB.2=1;
  160.      
  161.      
  162.       //xor
  163.       if(!PINB.3 * PINB.4  || !PINB.4 * PINB.3)
  164.       PORTB.5=1;
  165.       else
  166.       PORTB.5=0;
  167.      
  168.      
  169.       //xnor
  170.       if(!PINB.6 * PINB.7 || !PINB.7 * PINB.6)
  171.       PORTC.0=0;
  172.       else
  173.       PORTC.0=1;
  174.  
  175.       }
  176. }


Add Comment

* Required information
1000
Drag & drop images (max 3)
Enter the fifth word of this sentence.
Captcha Image
Powered by Commentics

Comments

No comments yet. Be the first!

Raw Paste


Login or Register to edit or fork this paste. It's free.