Advertisement
Latkoski

Lab03Mps

Dec 10th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. sbit LCD_RS at RA4_bit;
  2. sbit LCD_EN at RA5_bit;
  3. sbit LCD_D4 at RA0_bit;
  4. sbit LCD_D5 at RA1_bit;
  5. sbit LCD_D6 at RA2_bit;
  6. sbit LCD_D7 at RA3_bit;
  7. sbit LCD_RS_Direction at TRISA4_bit;
  8. sbit LCD_EN_Direction at TRISA5_bit;
  9. sbit LCD_D4_Direction at TRISA0_bit;
  10. sbit LCD_D5_Direction at TRISA1_bit;
  11. sbit LCD_D6_Direction at TRISA2_bit;
  12. sbit LCD_D7_Direction at TRISA3_bit;//promeneti poradi data line sto e A
  13.  
  14. void interrupt() {
  15. if (TMR0IF_bit) {
  16. cnt++;
  17. TMR0IF_bit = 0;
  18. TMR0 = 96;
  19. }
  20. } //prekin za tmr0, so nego rabotime
  21.  
  22. char *ime;
  23. void main(){
  24. ANSEL = 0;
  25. ANSLH = 0;
  26. TRISA = 0;
  27. TRISB.B0 = 0xFF;
  28. OPTIONREG = 0x85; //binarno vo hex za preskaler, prviot bit e 1, poslednite 3 od tabela
  29. INTCON = 0xA0; // binarno vo hex za interuput, global interupt i tmr0 da se aktivni od tabela
  30. TMR0 = 96; //formulata?
  31. cnt = 0;
  32. while(1){
  33. if(PORTB.B0 == 1){
  34. if(cnt >= 196){
  35. cnt = 0;
  36. Lcd_Init();
  37. Lcd_Cmd(_LCD_CURSOR_OFF);
  38. Lcd_Cmd(_LCD_CLEAR);
  39. }
  40. Lcd_Init();
  41. Lcd_Cmd(_LCD_CURSOR_OFF);
  42. strcpy(ime, "Angel");
  43. Lcd_Out(1,1,ime);
  44. }
  45. else if(PORTB.B0 == 0){
  46. if(cnt >= 196){
  47. cnt = 0;
  48. Lcd_Init();
  49. Lcd_Cmd(_LCD_CURSOR_OFF);
  50. Lcd_Cmd(_LCD_CLEAR);
  51. }
  52. Lcd_Init();
  53. LCD_Cmd(_LCD_CURSOR_OFF);
  54. LCD_Cmd(_LCD_CLEAR);
  55. strcpy(ime,"Latkoski");
  56. Lcd_Out(2,1,ime);
  57. i = 0 ;
  58. while(i < 9){
  59. LCD_Cmd(_LCD_SHIFT_LEFT);
  60. Delay_ms(10);
  61. i++;
  62. }
  63. }
  64. }
  65.  
  66.  
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement