Advertisement
SIKER_98

123

May 8th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <REGX52.H>
  2. #include <intrins.h>
  3. #define TRUE 1
  4.  
  5. unsigned char code cyfry[] = {0x3F, 0x06, 0X5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};
  6.  
  7. unsigned char data jednostki=0, dziesiatki=0;
  8. bit flaga = 0;
  9. ///////////////////////////////////////////
  10.  
  11. void on_of() interrupt 0
  12. {
  13. if(flaga == 0) flaga =1;
  14. else flaga = 0;
  15. }
  16.  
  17. void inkrementacja() interrupt 2
  18. {
  19. jednostki++;
  20. if(jednostki==10){
  21. dziesiatki++;
  22. jednostki=0;
  23. }
  24.  
  25. }
  26.  
  27. ///////////////////////////////////////////
  28.  
  29. void opoznienie(unsigned char ms)
  30. {
  31. unsigned long us = 1000*ms;
  32. while (us--)
  33. _nop_();
  34. }
  35.  
  36.  
  37. void wyswietlanie()
  38. {
  39. if (flaga==1)
  40. {
  41. P3_7=1;
  42. P1 = cyfry[dziesiatki];
  43. P3_7=0;
  44. opoznienie(1);
  45.  
  46. P3_6=1;
  47. P1 = cyfry[jednostki];
  48. P3_6=0;
  49. opoznienie(1);
  50. }
  51. else{
  52. P3_6=1;
  53. P3_7=1;
  54. P1=0;
  55. }
  56. }
  57. //////////////////////////////////////////
  58.  
  59. void przerwania()
  60. {
  61. EA = 1;
  62. EX0 = 1;
  63. EX1 = 1;
  64. IT0 = 1;
  65. IT1 = 1;
  66. }
  67.  
  68. //////////////////////////////////////////
  69.  
  70. int main()
  71. {
  72. przerwania();
  73. while (TRUE)
  74. {
  75. wyswietlanie();
  76. }
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement