realsdx

8segmnetprint891

Sep 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<at89c51xd2.h>
  3. unsigned char xdata control _at_ 0xe003;
  4. unsigned char xdata porta _at_ 0xe000;
  5. unsigned char xdata portb _at_ 0xe001;
  6. unsigned char xdata portc _at_ 0xe002;
  7.  
  8. void function(unsigned char ch)
  9. {
  10.         int i;
  11.         for(i=0;i<8;i++)
  12.         {      
  13.                 unsigned char tmp;
  14.                 tmp=0x80&ch;
  15.                 if (tmp)
  16.                         control=0x03;
  17.                 else
  18.                         control=0x02;
  19.                 control=0x01;
  20.                 control=0x00;
  21.                 ch=ch<<1;
  22.         }
  23. }
  24. void main()
  25. {
  26.     control = 0x80;
  27.     //prints 891
  28.     function(0xf9);//8
  29.     function(0x90);//9
  30.     function(0x80);//1
  31.     function(0xff);
  32.     function(0xff);
  33.     function(0xff);
  34. }
Add Comment
Please, Sign In to add comment