Advertisement
apl-mhd

micro

Dec 14th, 2020
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.92 KB | None | 0 0
  1. /*****************************************************
  2.  
  3. This program was produced by the
  4.  
  5. CodeWizardAVR V2.05.0 Evaluation
  6.  
  7. Automatic Program Generator
  8.  
  9. � Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
  10.  
  11. http://www.hpinfotech.com
  12.  
  13.  
  14.  
  15. Project :
  16.  
  17. Version :
  18.  
  19. Date    : 11/20/2020
  20.  
  21. Author  : Freeware, for evaluation and non-commercial use only
  22.  
  23. Company :
  24.  
  25. Comments:
  26.  
  27.  
  28.  
  29.  
  30.  
  31. Chip type               : ATmega32
  32.  
  33. Program type            : Application
  34.  
  35. AVR Core Clock frequency: 8.000000 MHz
  36.  
  37. Memory model            : Small
  38.  
  39. External RAM size       : 0
  40.  
  41. Data Stack size         : 512
  42.  
  43. *****************************************************/
  44.  
  45.  
  46.  
  47. #include <mega32.h>
  48. #include <alcd.h>
  49.  
  50.  
  51. #include <delay.h>
  52.  
  53. // Declare your global variables here
  54.  
  55.  
  56.  
  57. void main(void)
  58.  
  59. {
  60.  
  61. // Declare your local variables here
  62. int i = 0;
  63. int j = 0;
  64. int k = 0;
  65.  
  66. // Input/Output Ports initialization
  67.  
  68. // Port A initialization
  69.  
  70. // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
  71.  
  72. // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
  73.  
  74. PORTA=0b00000000;
  75.  
  76. DDRA=0b00000000;
  77.  
  78.  
  79.  
  80. // Port B initialization
  81.  
  82. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
  83.  
  84. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
  85.  
  86. PORTB=0b00000000;
  87.  
  88. DDRB=0b00000000;
  89.  
  90.  
  91.  
  92. // Port C initialization
  93.  
  94. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
  95.  
  96. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
  97.  
  98. PORTC=0x00;
  99.  
  100. DDRC=0x00;
  101.  
  102.  
  103.  
  104. // Port D initialization
  105.  
  106. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
  107.  
  108. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
  109.  
  110. PORTD=0b00000000;  
  111.  
  112. DDRD=0b00000000;    
  113.  
  114.  
  115.  
  116. // Timer/Counter 0 initialization
  117.  
  118. // Clock source: System Clock
  119.  
  120. // Clock value: Timer 0 Stopped
  121.  
  122. // Mode: Normal top=0xFF
  123.  
  124. // OC0 output: Disconnected
  125.  
  126. TCCR0=0x00;
  127.  
  128. TCNT0=0x00;
  129.  
  130. OCR0=0x00;
  131.  
  132.  
  133.  
  134. // Timer/Counter 1 initialization
  135.  
  136. // Clock source: System Clock
  137.  
  138. // Clock value: Timer1 Stopped
  139.  
  140. // Mode: Normal top=0xFFFF
  141.  
  142. // OC1A output: Discon.
  143.  
  144. // OC1B output: Discon.
  145.  
  146. // Noise Canceler: Off
  147.  
  148. // Input Capture on Falling Edge
  149.  
  150. // Timer1 Overflow Interrupt: Off
  151.  
  152. // Input Capture Interrupt: Off
  153.  
  154. // Compare A Match Interrupt: Off
  155.  
  156. // Compare B Match Interrupt: Off
  157.  
  158. TCCR1A=0x00;
  159.  
  160. TCCR1B=0x00;
  161.  
  162. TCNT1H=0x00;
  163.  
  164. TCNT1L=0x00;
  165.  
  166. ICR1H=0x00;
  167.  
  168. ICR1L=0x00;
  169.  
  170. OCR1AH=0x00;
  171.  
  172. OCR1AL=0x00;
  173.  
  174. OCR1BH=0x00;
  175.  
  176. OCR1BL=0x00;
  177.  
  178.  
  179.  
  180. // Timer/Counter 2 initialization
  181.  
  182. // Clock source: System Clock
  183.  
  184. // Clock value: Timer2 Stopped
  185.  
  186. // Mode: Normal top=0xFF
  187.  
  188. // OC2 output: Disconnected
  189.  
  190. ASSR=0x00;
  191.  
  192. TCCR2=0x00;
  193.  
  194. TCNT2=0x00;
  195.  
  196. OCR2=0x00;
  197.  
  198.  
  199.  
  200. // External Interrupt(s) initialization
  201.  
  202. // INT0: Off
  203.  
  204. // INT1: Off
  205.  
  206. // INT2: Off
  207.  
  208. MCUCR=0x00;
  209.  
  210. MCUCSR=0x00;
  211.  
  212.  
  213.  
  214. // Timer(s)/Counter(s) Interrupt(s) initialization
  215.  
  216. TIMSK=0x00;
  217.  
  218.  
  219.  
  220. // USART initialization
  221.  
  222. // USART disabled
  223.  
  224. UCSRB=0x00;
  225.  
  226.  
  227.  
  228. // Analog Comparator initialization
  229.  
  230. // Analog Comparator: Off
  231.  
  232. // Analog Comparator Input Capture by Timer/Counter 1: Off
  233.  
  234. ACSR=0x80;
  235.  
  236. SFIOR=0x00;
  237.  
  238.  
  239.  
  240. // ADC initialization
  241.  
  242. // ADC disabled
  243.  
  244. ADCSRA=0x00;
  245.  
  246.  
  247.  
  248. // SPI initialization
  249.  
  250. // SPI disabled
  251.  
  252. SPCR=0x00;
  253.  
  254.  
  255.  
  256. // TWI initialization
  257.  
  258. // TWI disabled
  259.  
  260. TWCR=0x00;
  261.  
  262.  
  263. // Alphanumeric LCD initialization
  264. // Connections specified in the
  265. // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
  266. // RS - PORTA Bit 0
  267. // RD - PORTA Bit 1
  268. // EN - PORTA Bit 2
  269.  
  270. // D4 - PORTA Bit 4
  271. // D5 - PORTA Bit 5
  272. // D6 - PORTA Bit 6
  273. // D7 - PORTA Bit 7
  274. // characters/line 16
  275. lcd_init(16);
  276. lcd_gotoxy(0,0); // column 1 , row 0
  277.  
  278. PORTB=0b00000000; // set as input
  279. DDRB=0b00000000;
  280.  
  281. DDRC= 0b11111111;  // set as output, segement section
  282. DDRD= 0b11111111;  // set as output, data(digit)
  283. while (1)
  284.  
  285.       {
  286.                
  287.       if(PINB.0 == 0)    // button is pressed
  288.       {          
  289.            lcd_gotoxy(i,0);    
  290.            lcd_puts("Rifat");
  291.            delay_ms(600);
  292.            lcd_clear();
  293.       }  
  294.       else         // button is not pressed
  295.       {
  296.           PORTC = 0b11111110;
  297.           PORTD=0b01100110;//pin 0,1,2,3,5 is high
  298.           delay_ms(300);
  299.           /*
  300.             if(i==10)
  301.             {
  302.                 i=0;
  303.             }
  304.             if(i==0)
  305.             {
  306.                 PORTD=0b00111111;//pin 0,1,2,3,5 is high
  307.             }
  308.  
  309.             if(i==1){
  310.                 PORTD=0b00000110;//pin 1,2 is high
  311.              }
  312.  
  313.             if(i==2){
  314.  
  315.                 PORTD=0b01011011;//pin 0,1,3,4,6 is high
  316.  
  317.              }
  318.  
  319.             if(i==3){
  320.  
  321.                 PORTD=0b01001111;//pin 0,1,2,3,6 is high
  322.  
  323.              }
  324.  
  325.             if(i==4){
  326.  
  327.                 PORTD=0b01100110;//pin 1,2,5,6 is high
  328.  
  329.              }
  330.  
  331.             if(i==5){
  332.  
  333.                 PORTD=0b01101101;//pin 0,2,3,5,6 is high
  334.  
  335.              }
  336.  
  337.             if(i==6){
  338.  
  339.                 PORTD=0b01111101;//pin 0,2,3,4,5,6 is high
  340.  
  341.              }
  342.  
  343.             if(i==7){
  344.  
  345.                 PORTD=0b00000111;//pin 0,1,2 is high
  346.  
  347.              }
  348.  
  349.             if(i==8){
  350.  
  351.                 PORTD=0b01111111;//pin 0,1,2,3,4,5,6 is high
  352.  
  353.              }
  354.  
  355.             if(i==9){
  356.  
  357.                 PORTD=0b01101111;//pin 0,1,2,3,5,6 is high  
  358.  
  359.                 j++;
  360.  
  361.              }
  362.              
  363.               delay_ms(300);  
  364.  
  365.              PORTC=0b11111101;//port C pin 1 is HIGH
  366.  
  367.              if(j==10)j=0;
  368.  
  369.             if(j==0){
  370.  
  371.                 PORTD=0b00111111;//pin 0,1,2,3,5 is high
  372.  
  373.               }
  374.  
  375.             if(j==1){
  376.  
  377.                 PORTD=0b00000110;//pin 1,2 is high
  378.  
  379.              }
  380.  
  381.             if(j==2){
  382.  
  383.                 PORTD=0b01011011;//pin 0,1,3,4,6 is high
  384.  
  385.              }
  386.  
  387.             if(j==3){
  388.  
  389.                 PORTD=0b01001111;//pin 0,1,2,3,6 is high
  390.  
  391.              }
  392.  
  393.             if(j==4){
  394.  
  395.                 PORTD=0b01100110;//pin 1,2,5,6 is high
  396.  
  397.              }
  398.  
  399.             if(j==5){
  400.  
  401.                 PORTD=0b01101101;//pin 0,2,3,5,6 is high
  402.  
  403.              }
  404.  
  405.             if(j==6){
  406.  
  407.                 PORTD=0b01111101;//pin 0,2,3,4,5,6 is high
  408.  
  409.              }
  410.  
  411.             if(j==7){
  412.  
  413.                 PORTD=0b00000111;//pin 0,1,2 is high
  414.  
  415.              }
  416.  
  417.             if(j==8){
  418.  
  419.                 PORTD=0b01111111;//pin 0,1,2,3,4,5,6 is high
  420.  
  421.              }
  422.  
  423.             if(j==9){
  424.  
  425.                 PORTD=0b01101111;//pin 0,1,2,3,5,6 is high    
  426.  
  427.                   k++;
  428.  
  429.              }  
  430.  
  431.             delay_ms(300);    
  432.             PORTC=0b11111011;//port C pin 1 is HIGH
  433.  
  434.              if(k==10)k=0;
  435.  
  436.             if(k==0){
  437.  
  438.                 PORTD=0b00111111;//pin 0,1,2,3,5 is high
  439.  
  440.               }
  441.  
  442.             if(k==1){
  443.  
  444.                 PORTD=0b00000110;//pin 1,2 is high
  445.  
  446.              }
  447.  
  448.             if(k==2){
  449.  
  450.                 PORTD=0b01011011;//pin 0,1,3,4,6 is high
  451.  
  452.              }
  453.  
  454.             if(k==3){
  455.  
  456.                 PORTD=0b01001111;//pin 0,1,2,3,6 is high
  457.  
  458.              }
  459.  
  460.             if(k==4){
  461.  
  462.                 PORTD=0b01100110;//pin 1,2,5,6 is high
  463.  
  464.              }
  465.  
  466.             if(k==5){
  467.  
  468.                 PORTD=0b01101101;//pin 0,2,3,5,6 is high
  469.  
  470.              }
  471.  
  472.             if(k==6){
  473.  
  474.                 PORTD=0b01111101;//pin 0,2,3,4,5,6 is high
  475.  
  476.              }
  477.  
  478.             if(k==7){
  479.  
  480.                 PORTD=0b00000111;//pin 0,1,2 is high
  481.  
  482.              }
  483.  
  484.             if(k==8){
  485.  
  486.                 PORTD=0b01111111;//pin 0,1,2,3,4,5,6 is high
  487.  
  488.              }
  489.  
  490.             if(k==9){
  491.  
  492.                 PORTD=0b01101111;//pin 0,1,2,3,5,6 is high    
  493.  
  494.                  
  495.  
  496.              }  
  497.  
  498.             delay_ms(300);
  499.             i++;
  500.              */
  501.       }              
  502.        
  503.    
  504.                    
  505.    
  506.                
  507.  
  508.            
  509.  
  510.       }
  511.  
  512.      
  513.  
  514. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement