Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <REGX52.H>
  2.  
  3. #define TT 8000
  4.  
  5. sbit STRm = 0x84;
  6. sbit ACKm = 0x85;
  7.  
  8. sbit STRs = 0x86;
  9. sbit ACKs = 0x87;
  10.  
  11. bit b1 = 1;
  12. bit b2 = 1;
  13.  
  14. int dt = TT/1000;
  15. int tt = TT/100;
  16. unsigned char LiczB2 = 0x00;
  17.  
  18.  
  19. void LiczInt0(void) interrupt 0 {
  20. EX0 = 0;
  21. LiczB2++;
  22. if(LiczB2 == 255){
  23. LiczB2 = 0;
  24. }
  25. EX0 = 1;
  26. b2 = 0;
  27. ACKm = 0;
  28. }
  29.  
  30. void wait(int i){
  31. unsigned int k,l,m;
  32.  
  33. for(l=0;l<i;l++){
  34. k=500;
  35. m=1000;
  36. k=m*k;
  37. }
  38. }
  39.  
  40.  
  41. void init(){
  42. LiczB2 = 0;
  43. if(P0_0 == 0){
  44. STRm = 1;
  45. ACKm = 0;
  46. }
  47. if(P0_0 == 1){
  48. STRs = 1;
  49. ACKs = 0;
  50. }
  51. IT0 = 1;
  52. EX0 = 1;
  53. EA = 1;
  54. }
  55.  
  56. void main(){
  57. init();
  58. wait(tt);
  59. while(P0_0 == 0){
  60. while(b2){
  61. wait(dt);
  62. }
  63. P1 = LiczB2;
  64. b2 = 1;
  65. while(ACKm == 0){
  66. STRm = 0;
  67. P2 = P1;
  68. }
  69.  
  70. }
  71. while(P0_0 == 1){
  72. while(STRs == 1){
  73. wait(dt);
  74. }
  75. P1 = P2;
  76. ACKs = 1;
  77. wait(50);
  78.  
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement