Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <REGX52.H>
- #define TT 8000
- sbit STRm = 0x84;
- sbit ACKm = 0x85;
- sbit STRs = 0x86;
- sbit ACKs = 0x87;
- bit b1 = 1;
- bit b2 = 1;
- int dt = TT/1000;
- int tt = TT/100;
- unsigned char LiczB2 = 0x00;
- void LiczInt0(void) interrupt 0 {
- EX0 = 0;
- LiczB2++;
- if(LiczB2 == 255){
- LiczB2 = 0;
- }
- EX0 = 1;
- b2 = 0;
- ACKm = 0;
- }
- void wait(int i){
- unsigned int k,l,m;
- for(l=0;l<i;l++){
- k=500;
- m=1000;
- k=m*k;
- }
- }
- void init(){
- LiczB2 = 0;
- if(P0_0 == 0){
- STRm = 1;
- ACKm = 0;
- }
- if(P0_0 == 1){
- STRs = 1;
- ACKs = 0;
- }
- IT0 = 1;
- EX0 = 1;
- EA = 1;
- }
- void main(){
- init();
- wait(tt);
- while(P0_0 == 0){
- while(b2){
- wait(dt);
- }
- P1 = LiczB2;
- b2 = 1;
- while(ACKm == 0){
- STRm = 0;
- P2 = P1;
- }
- }
- while(P0_0 == 1){
- while(STRs == 1){
- wait(dt);
- }
- P1 = P2;
- ACKs = 1;
- wait(50);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement