C51 COMPILER V6.00 XBUS 05/18/2000 08:49:51 PAGE 1 C51 COMPILER 6.00, COMPILATION OF MODULE XBUS NO OBJECT MODULE REQUESTED COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE .\Xbus.c OBJECTEXTEND DEBUG stmt level source *** WARNING 500 IN LINE 1 OF .\XBUS.C: MISSING DEVICE (SECURITY KEY NOT FOUND) 1 2 #include 3 4 // #define RESETBUS 5 6 /* 0xc0 = NOP 0xd0 = Addr 0xe0 = Write 0xf0 = Read */ 7 /* outputs */ 8 sbit STROBE = P3^7; /* clock pin is P3.7 */ 9 sbit COM1 = P1^5; /* command1 pin is P1.5 */ 10 sbit COM0 = P1^4; /* command0 pin is P1.4 */ 11 sbit DATA3 = P1^3; /* data3 pin is P1.3 */ 12 sbit DATA2 = P1^2; /* data2 pin is P1.2 */ 13 sbit DATA1 = P1^1; /* data1 pin is P1.1 */ 14 sbit DATA0 = P1^0; /* data0 pin is P1.0 */ 15 16 #define NOPCOM 0x00 17 #define ADDRCOM 0x10 18 #define READCOM 0x30 19 #define WRITECOM 0x20 20 21 /* macro definitions */ 22 #define AddrNibl0(addr)\ 23 P1 = (0xC0 | ADDRCOM | (addr & 0xf)); \ 24 STROBE = 1; STROBE = 0; /* clock it */ 25 26 #define AddrNibl1(addr)\ 27 P1 = (0xC0 | ADDRCOM | ((addr>>4) & 0xf));\ 28 STROBE = 1; STROBE = 0; /* clock it */ 29 30 #define AddrNibl2(addr)\ 31 P1 = (0xC0 | ADDRCOM | ((addr>>8) & 0xf));\ 32 STROBE = 1; STROBE = 0; /* clock it */ 33 34 #define AddrNibl3(addr)\ 35 P1 = (0xC0 | ADDRCOM | ((addr>>12) & 0xf));\ 36 STROBE = 1; STROBE = 0; /* clock it */ 37 38 #define WriteNibl0(value)\ 39 P1 = (0xC0 | WRITECOM | (value & 0xf));\ 40 STROBE = 1; STROBE = 0; /* clock it */ 41 42 // The FPGA pulls down on STROBE to cause us to wait 43 #define WriteNibl1(value) \ 44 P1 =(0xC0 | WRITECOM | ((value>>4) & 0xf)); \ 45 STROBE = 1; \ 46 while (STROBE==0) {}; /* Wait for FPGA to release STROBE */ \ 47 STROBE = 0; 48 49 // We have to tristate the data lines with the 0xf 50 // The FPGA pulls down on STROBE until the read data is ready 51 #define ReadNibl0(value) \ 52 P1 = (0xC0 | READCOM | 0xf); /* Remember to tristate data lines! */ \ 53 STROBE = 1; /* clock it */ \ 54 while ( STROBE==0 ) {} /* Wait until FPGA is ready */ \ C51 COMPILER V6.00 XBUS 05/18/2000 08:49:51 PAGE 2 55 value = (P1 & 0x0f); \ 56 STROBE = 0; 57 58 #define ReadNibl1(value)\ 59 P1 = (0xC0 | READCOM | 0xf); /* Remember to tristate data lines */ \ 60 STROBE = 1; /* clock it */\ 61 value = ((P1 << 4) | value); \ 62 STROBE = 0; 63 64 unsigned char XRead(unsigned int address) 65 { 66 1 unsigned char value; 67 1 68 1 /* 16 bits of address */ 69 1 AddrNibl0(address); 70 1 AddrNibl1(address); 71 1 AddrNibl2(address); 72 1 AddrNibl3(address); 73 1 /* read the data bits back */ 74 1 ReadNibl0(value); 75 1 ReadNibl1(value); 76 1 return value; 77 1 } 78 79 void XWrite(unsigned int address, unsigned char value) 80 { 81 1 /* 16 bits of address */ 82 1 AddrNibl0(address); 83 1 AddrNibl1(address); 84 1 AddrNibl2(address); 85 1 AddrNibl3(address); 86 1 /* Send the data */ 87 1 WriteNibl0(value); 88 1 WriteNibl1(value); 89 1 } 90 91 // Initialize the Xbus by issuing a bunch of NOPs to get 92 // the FPGA state machine into the idle mode 93 void XInit() 94 { 95 1 P1 = 0xff; // Tristate port 1 96 1 STROBE = 0; // Start with strobe low 97 1 P1 = (0xC0 | NOPCOM ); 98 1 STROBE = 1; STROBE = 0; /* clock it */ 99 1 P1 = (0xC0 | NOPCOM ); 100 1 STROBE = 1; STROBE = 0; /* clock it */ 101 1 P1 = (0xC0 | NOPCOM ); 102 1 STROBE = 1; STROBE = 0; /* clock it */ 103 1 P1 = (0xC0 | NOPCOM ); 104 1 STROBE = 1; STROBE = 0; /* clock it */ 105 1 P1 = (0xC0 | NOPCOM ); 106 1 STROBE = 1; STROBE = 0; /* clock it */ 107 1 P1 = (0xC0 | NOPCOM ); 108 1 STROBE = 1; STROBE = 0; /* clock it */ 109 1 P1 = (0xC0 | NOPCOM ); 110 1 STROBE = 1; STROBE = 0; /* clock it */ 111 1 P1 = (0xC0 | NOPCOM ); 112 1 STROBE = 1; STROBE = 0; /* clock it */ 113 1 } 114 115 unsigned char XReadCont() 116 { C51 COMPILER V6.00 XBUS 05/18/2000 08:49:51 PAGE 3 117 1 unsigned char value; 118 1 ReadNibl0(value); 119 1 ReadNibl1(value); 120 1 return value; 121 1 } 122 123 MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 275 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = ---- ---- IDATA SIZE = ---- ---- BIT SIZE = ---- ---- END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)