Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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. }
  28.  
  29. void wait(int i){
  30. unsigned int k,l,m;
  31.  
  32. for(l=0;l<i;l++){
  33. k=500;
  34. m=1000;
  35. k=m*k;
  36. }
  37. }
  38.  
  39.  
  40. void init(){
  41. LiczB2 = 0;
  42. STRm = 1;
  43. ACKm = 0;
  44. STRs = 1;
  45. ACKs = 0;
  46.  
  47. IT0 = 1;
  48. EX0 = 1;
  49. EA = 1;
  50. }
  51.  
  52. void main(){
  53. init();
  54. wait(tt);
  55. while(P0_0 == 0){
  56. while(b2){
  57. wait(dt);
  58. }
  59. P1 = LiczB2;
  60. b2 = 1;
  61. while(ACKm == 0){
  62. STRm = 0;
  63. P2 = P1;
  64. }
  65. ACKm = 0;
  66. }
  67. while(P0_0 == 1){
  68. while(STRs == 1){
  69. wait(dt);
  70. }
  71. P1 = P2;
  72. ACKs = 1;
  73. wait(50);
  74.  
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement