kamilosxd678

SWIM6

Apr 3rd, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None | 0 0
  1. /*
  2.  * lab6.c
  3.  *
  4.  * Created: 2012-03-26 20:20:24
  5.  *  Author: student
  6.  */
  7. #define F_CPU 6000000UL
  8. #include <lcd.h>
  9. #include <avr/io.h>
  10. #include <util/delay_basic.h>
  11. #include <util/delay.h>
  12. #ifndef __PGMSPACE_H_
  13. #include <avr/pgmspace.h>
  14. #endif
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17.  
  18. void init_lcd(void){
  19.     _delay_ms(15);
  20.     COMM_LCD = 0x30;
  21.     _delay_ms(5);
  22.     COMM_LCD = 0x30;
  23.     _delay_ms(0.2);
  24.     COMM_LCD = 0x30;
  25.     _delay_ms(30);
  26.     COMM_LCD = 0x38;
  27.     test_bf();
  28.     pisz_com(0x0C);
  29.     lcd_clear();
  30.     pisz_com(0x06);
  31.     lcd_home();
  32.     pisz_com(0x48);
  33.     pisz_ws(0x00);
  34.     pisz_ws(0x00);
  35.     pisz_ws(0x11);
  36.     pisz_ws(0x00);
  37.     pisz_ws(0x00);
  38.     pisz_ws(0x11);
  39.     pisz_ws(0xFE);
  40.     pisz_ws(0x00);
  41.    
  42. }
  43. void disp_txt_P(const char* _adres){
  44.     volatile uint8_t al;
  45.     for(int i=0;i<16;i++){
  46.         al=pgm_read_byte(&_adres[i]);
  47.         if(al == 0xFF) break;
  48.         pisz_ws(al);
  49.     }
  50. }
  51. void disp_txt_D(const char* _adres){
  52.     volatile uint8_t al;
  53.     for(int i=0;i<16;i++){
  54.         al=_adres[i];
  55.         if(al == 0x00) break;
  56.         pisz_ws(al);
  57.     }
  58. }
  59.  
  60. int main(void)
  61. {
  62.     MCUCR = _BV(SRE) |_BV(SRW10);
  63.     XMCRA = _BV(SRW00) |_BV(SRW01) |_BV(SRW11);
  64.     ADMUX = _BV(MUX0);
  65.     char tab[16] = {'L','a','b',' ','S','W','i','M','\0'};
  66.     char tab2[16] = {0x01,'\0'};
  67.     init_lcd();
  68.     ADCSRA ^= _BV(ADEN);
  69.     int jakas_zmienna = 0;
  70.     int kierunek = 1;
  71.     while(1)
  72.     {
  73.         lcd_clear();
  74.         pisz_com(0x80);
  75.         disp_txt_D(tab);
  76.         pisz_com(0xC0+jakas_zmienna);
  77.         disp_txt_D(tab2);
  78.         if(kierunek)
  79.             jakas_zmienna++;
  80.         else
  81.             jakas_zmienna--;
  82.         if(jakas_zmienna == 0)
  83.             kierunek = 1;
  84.         if(jakas_zmienna == 15)
  85.             kierunek = 0;
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment