⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p16web.lst

📁 一个由PIC单片机组成的Web服务器源码
💻 LST
📖 第 1 页 / 共 5 页
字号:
CCS PCM C Compiler, Version 2.693, 3951

               Filename: C:\CHIPWEB\PCM\P16WEB.LST

               ROM used: 6840 (83%)
                         Largest free fragment is 761
               RAM used: 177 (48%) at main() level
                         214 (58%) worst case
               Stack:    7 locations

0000:  MOVLW  10
0001:  MOVWF  0A
0002:  GOTO   4AB
0003:  NOP
....................  /* PIC Ethernet Web server; runs on the Microchip PICDEM.net board 
.................... ** Copyright (c) Iosoft Ltd 2001 
.................... ** This software is only licensed for distribution in the Iosoft ChipWeb package 
.................... ** and may only be used for personal experimentation by the purchaser  
.................... ** of that package, on condition that this copyright notice is retained.  
.................... ** For commercial licensing, contact license@iosoft.co.uk 
.................... ** 
.................... ** This is experimental software; use it entirely at your own risk */ 
.................... /* 
.................... ** v0.01 JPB 1/12/00 First version 
.................... ** v0.02 JPB 7/12/00 Simple LCD driver added 
.................... ** v0.04 JPB 10/12/00 Added simple Ethernet transmit 
.................... **                    Added simple EEROM check 
.................... ** v0.05 JPB 17/12/00 Renamed from PICT77 to ETHERPIC 
.................... ** v0.06 JPB 23/12/00 Got ARP working 
.................... ** v0.07 JPB 26/12/00 Got Ping working 
.................... ** v0.08 JPB 26/12/00 Improved Tx throughput 
.................... ** v0.09 JPB 27/12/00 Added support for 64-byte ping 
.................... ** v0.10 JPB 27/12/00 Added support for new (v3) PICDEM-NET board 
.................... ** v0.11 JPB 28/12/00 Added preliminary TCP code 
.................... ** v0.12 JPB 29/12/00 Added dummy daytime service 
.................... ** v0.13 JPB 29/12/00 Started boot configuration 
.................... **                    Increased NIC RAM size from 20h to 40h pages 
.................... **                    Fixed ICMP checksum problem 
.................... ** v0.14 JPB 30/12/00 Added RX_BUFFERED option (to eliminate Rx buffer!) 
.................... ** v0.15 JPB 30/12/00 Added first Web page 
.................... ** v0.16 JPB 30/12/00 Split internal & external Tx length words 
.................... ** v0.17 JPB 1/1/01   Fixed bugs in TCP transmission and length calculation 
.................... **                    Improved debug output 
.................... ** v0.18 JPB 3/1/01   Added UDP echo capability 
.................... **                    Added skeletal FTP for test 
.................... ** v0.19 JPB 4/1/01   Added TFTP 
.................... ** v0.20 JPB 5/1/01   Added TFTP receive 
.................... ** v0.21 JPB 6/1/01   Added EEROM programming to TFTP receive 
.................... ** v0.22 JPB 6/1/01   Stripped out unnecessary functions 
.................... **                    Added user configuration interface 
.................... ** v0.23 JPB 7/1/01   Added non-volatile config 
.................... ** v0.24 JPB 7/1/01   Added EGI variable substitution 
.................... **                    Reduced Ether RAM size to 8K 
.................... ** v0.25 JPB 21/1/01  Switched from TFTP to Xmodem for EEROM programming 
.................... ** v0.26 JPB 25/1/01  Added Fuji display initialisation 
.................... ** v0.27 JPB 28/1/01  Adapted for new design of Web pages 
.................... **                    Sign on as ChipWeb 
.................... ** v1.02 JPB 11/2/01  Added digital I/P 
.................... **                    Up-issued for release 
.................... ** v1.03 JPB 5/3/01   Fixed problem with blank Web page ROM error msg 
.................... */            
....................  
.................... #define SIGNON  "ChipWeb v1.03\n" 
....................  
.................... #define DEBUG        0          // Set non-zero to enable diagnostic printout 
.................... #define OLD_BOARD    0          // Set non-zero if using old PICDEM.NET board 
.................... #define RX_BUFFERED  0          // Set non-zero if using Rx buffers  
.................... #define CLOCK16      0          // Set non-zero if using 16 MHz clock */ 
....................  
.................... #include <16F877.H> 
....................  //////// Standard Header file for the PIC16F877 device //////// 
.................... #device PIC16F877 
.................... #list 
.................... 
.................... #device *=16 
....................  
.................... #FUSES HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP // PIC fuse settings 
.................... #ID CHECKSUM                                 // ID bytes are checksum 
.................... #ZERO_RAM                                    // Wipe RAM for safety 
.................... #use fast_io(A)                              // I'll set the direction bits 
.................... #use fast_io(B) 
.................... #use fast_io(C) 
.................... #use fast_io(D) 
.................... #use fast_io(E) 
....................  
.................... #use I2C(MASTER, SDA=PIN_C4, SCL=PIN_C3, RESTART_WDT, FAST) 
*
03B0:  MOVLW  08
03B1:  MOVWF  78
03B2:  NOP
03B3:  CLRWDT
03B4:  BCF    07,3
03B5:  BSF    03,5
03B6:  BCF    07,3
03B7:  CLRWDT
03B8:  BCF    03,5
03B9:  BSF    03,6
03BA:  RLF    45,F
03BB:  BCF    03,6
03BC:  BCF    07,4
03BD:  BTFSS  03,0
03BE:  GOTO   3C2
03BF:  BSF    03,5
03C0:  BSF    07,4
03C1:  BCF    03,5
03C2:  BTFSC  03,0
03C3:  GOTO   3C7
03C4:  BSF    03,5
03C5:  BCF    07,4
03C6:  BCF    03,5
03C7:  BSF    03,5
03C8:  BSF    07,3
03C9:  BCF    03,5
03CA:  BTFSS  07,3
03CB:  GOTO   3CA
03CC:  DECFSZ 78,F
03CD:  GOTO   3B2
03CE:  CLRWDT
03CF:  BCF    07,3
03D0:  BSF    03,5
03D1:  BCF    07,3
03D2:  NOP
03D3:  BSF    07,4
03D4:  CLRWDT
03D5:  CLRWDT
03D6:  CLRWDT
03D7:  CLRWDT
03D8:  BSF    07,3
03D9:  BCF    03,5
03DA:  BTFSS  07,3
03DB:  GOTO   3DA
03DC:  CLRF   78
03DD:  CLRWDT
03DE:  BTFSC  07,4
03DF:  BSF    78,0
03E0:  CLRWDT
03E1:  BCF    07,3
03E2:  BSF    03,5
03E3:  BCF    07,3
03E4:  BCF    03,5
03E5:  BCF    07,4
03E6:  BSF    03,5
03E7:  BCF    07,4
03E8:  BCF    03,5
03E9:  RETLW  00
*
0DE8:  MOVLW  08
0DE9:  BSF    03,6
0DEA:  MOVWF  49
0DEB:  BCF    03,6
0DEC:  MOVF   77,W
0DED:  BSF    03,6
0DEE:  MOVWF  4A
0DEF:  BCF    03,6
0DF0:  BSF    03,5
0DF1:  BSF    07,4
0DF2:  CLRWDT
0DF3:  BSF    07,3
0DF4:  BCF    03,5
0DF5:  BTFSS  07,3
0DF6:  GOTO   5F5
0DF7:  BTFSC  07,4
0DF8:  BSF    03,0
0DF9:  BTFSS  07,4
0DFA:  BCF    03,0
0DFB:  RLF    78,F
0DFC:  CLRWDT
0DFD:  BSF    03,5
0DFE:  BCF    07,3
0DFF:  BCF    03,5
0E00:  BCF    07,3
0E01:  BSF    03,6
0E02:  DECFSZ 49,F
0E03:  GOTO   605
0E04:  GOTO   607
0E05:  BCF    03,6
0E06:  GOTO   5F0
0E07:  BSF    03,5
0E08:  BCF    03,6
0E09:  BSF    07,4
0E0A:  CLRWDT
0E0B:  BCF    03,5
0E0C:  BCF    07,4
0E0D:  BSF    03,6
0E0E:  MOVF   4A,W
0E0F:  BTFSC  03,2
0E10:  GOTO   616
0E11:  BSF    03,5
0E12:  BCF    03,6
0E13:  BCF    07,4
0E14:  BCF    03,5
0E15:  BSF    03,6
0E16:  BCF    03,6
0E17:  NOP
0E18:  BSF    03,5
0E19:  BSF    07,3
0E1A:  BCF    03,5
0E1B:  BTFSS  07,3
0E1C:  GOTO   61B
0E1D:  CLRWDT
0E1E:  BCF    07,3
0E1F:  BSF    03,5
0E20:  BCF    07,3
0E21:  CLRWDT
0E22:  BCF    03,5
0E23:  BCF    07,4
0E24:  BSF    03,5
0E25:  BCF    07,4
0E26:  BCF    03,5
0E27:  RETLW  00
....................  
.................... #define EEROM_ADDR   0xa0   // i2c addr for eerom 
....................  
.................... // Timer 1 trigger value; tick time = (1024 x DIV) / CPU_CLK 
.................... // 50 ms ticks with 7.3728 MHz clock requires divisor 45 prescale 8 
.................... #if CLOCK16 
.................... #define TIMER1_DIV  98 
.................... #use DELAY(CLOCK=16000000) 
.................... #else 
.................... #define TIMER1_DIV  120 
.................... #use DELAY(CLOCK=19660800) 
*
00ED:  MOVLW  33
00EE:  MOVWF  04
00EF:  BSF    03,7
00F0:  MOVF   00,W
00F1:  BTFSC  03,2
00F2:  GOTO   102
00F3:  MOVLW  06
00F4:  MOVWF  78
00F5:  CLRF   77
00F6:  DECFSZ 77,F
00F7:  GOTO   0F6
00F8:  DECFSZ 78,F
00F9:  GOTO   0F5
00FA:  MOVLW  5A
00FB:  MOVWF  77
00FC:  DECFSZ 77,F
00FD:  GOTO   0FC
00FE:  NOP
00FF:  NOP
0100:  DECFSZ 00,F
0101:  GOTO   0F3
0102:  RETLW  00
.................... #endif 
.................... #define TIMER1_SET  (T1_INTERNAL | T1_DIV_BY_8) 
....................  
.................... #use RS232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, ERRORS) 
*
02BF:  BTFSS  0C,5
02C0:  GOTO   2BF
02C1:  MOVF   18,W
02C2:  MOVWF  20
02C3:  MOVF   1A,W
02C4:  MOVWF  78
02C5:  BTFSS  20,1
02C6:  GOTO   2C9
02C7:  BCF    18,4
02C8:  BSF    18,4
02C9:  NOP
02CA:  RETLW  00
....................  
.................... #define WORD unsigned long  // Data type definitions 
.................... #define BOOL short          // 'short' is very short (1 bit) in this compiler 
.................... typedef union               // Longword definition (not a native type) 
.................... { 
....................     BYTE b[4]; 
....................     WORD w[2]; 
....................     BYTE l; 
.................... } LWORD; 
....................  
.................... #byte   PORTA = 5               // Main I/O ports 
.................... #byte   PORTB = 6 
.................... #byte   PORTC = 7 
.................... #define ALL_OUT 0 
.................... #define ALL_IN  0xff 
....................  
.................... #if OLD_BOARD 
.................... #BIT DIAG_LED = PORTA.5 
.................... #else 
.................... #bit USER_BUTTON=PORTB.5        // User pushbutton 
.................... #bit USERLED1 = PORTA.2         // User LEDs 
.................... #bit USERLED2 = PORTA.3 
.................... #bit SYSLED   = PORTA.4         // System LED 
.................... #endif 
....................  
.................... #define LEDTIME 10              // Interval for toggling system LED 
....................  
.................... WORD adc1, adc2;                // Copy of current ADC values 
.................... int tickcount;                  // Timer tick count 
.................... BOOL ledon;                     // LED state 
.................... unsigned ledticks;              // LED tick count 
.................... WORD tpxdlen;                   // Length of external data in Tx frame 
....................  
.................... /* General prototypes */ 
.................... void displays(BYTE b); 
....................  
.................... /* Local prototypes */ 
.................... BOOL geticks(void); 
.................... BOOL timeout(int &var, int tout); 
.................... void scan_io(void); 
.................... BOOL read_nonvol(void); 
.................... BYTE csum_nonvol(void); 
.................... void user_config(void); 
....................  
.................... /* Character O/P for debugging */ 
.................... #if DEBUG 
.................... #define DEBUG_PUTC(c) putchar(c) 
.................... #else 
.................... #define DEBUG_PUTC(c) 
.................... #endif 
....................  
.................... /* For PCM compiler, library code must be included (can't be linked) */ 
.................... #include "\chipweb\pcm\p16_eth.h" 
....................  /* RTL8019AS network driver for ChipWeb on PICDEM.net board 
.................... ** Copyright (c) Iosoft Ltd 2001 
.................... ** This software is only licensed for distribution in the Iosoft ChipWeb package 
.................... ** and may only be used for personal experimentation by the purchaser  
.................... ** of that package, on condition that this copyright notice is retained.  
.................... ** For commercial licensing, contact license@iosoft.co.uk 
.................... ** 
.................... ** This is experimental software; use it entirely at your own risk */ 
.................... /* 
.................... ** v0.01 JPB 25/11/00  Adapted from ETHERNE.C v0.25 
.................... */ 
....................  
.................... #byte   PORTD       = 8 
.................... #byte   PORTE       = 9 
....................  
.................... #BIT    NIC_RESET   = PORTE.2 
.................... #BIT    NIC_IOW_    = PORTE.1 
.................... #BIT    NIC_IOR_    = PORTE.0 
.................... #BYTE   NIC_ADDR    = PORTB 
.................... #BYTE   NIC_DATA    = PORTD 
.................... #define DATA_TO_NIC   set_tris_d(ALL_OUT); 
.................... #define DATA_FROM_NIC set_tris_d(ALL_IN); 
....................  
.................... #define PROMISC  0              /* Set non-zero to accept all packets */ 
....................  
.................... /* Ethernet definitions.. */ 
.................... #define MINFRAME  60 
.................... #define MINFRAMEC 64 
.................... #define CRCLEN    4 
.................... #define MAXFRAME  1514 
.................... #define MAXFRAMEC 1518 
....................  
.................... /* NE2000 definitions */ 
.................... #define DATAPORT 0x10 
.................... #define NE_RESET 0x1f 
....................  
.................... /* 8390 Network Interface Controller (NIC) page0 register offsets */ 
.................... #define CMDR    0x00            /* command register for read & write */ 
.................... #define PSTART  0x01            /* page start register for write */ 
.................... #define PSTOP   0x02            /* page stop register for write */ 
.................... #define BNRY    0x03            /* boundary reg for rd and wr */ 
.................... #define TPSR    0x04            /* tx start page start reg for wr */ 
.................... #define TBCR0   0x05            /* tx byte count 0 reg for wr */ 
.................... #define TBCR1   0x06            /* tx byte count 1 reg for wr */ 
.................... #define ISR     0x07            /* interrupt status reg for rd and wr */ 
.................... #define RSAR0   0x08            /* low byte of remote start addr */ 
.................... #define RSAR1   0x09            /* hi byte of remote start addr */ 
.................... #define RBCR0   0x0A            /* remote byte count reg 0 for wr */ 
.................... #define RBCR1   0x0B            /* remote byte count reg 1 for wr */ 
.................... #define RCR     0x0C            /* rx configuration reg for wr */ 
.................... #define TCR     0x0D            /* tx configuration reg for wr */ 
.................... #define DCR     0x0E            /* data configuration reg for wr */ 
.................... #define IMR     0x0F            /* interrupt mask reg for wr */ 
....................  
.................... /* NIC page 1 register offsets */ 
.................... #define PAR0    0x01            /* physical addr reg 0 for rd and wr */ 
.................... #define CURRP   0x07            /* current page reg for rd and wr */ 
.................... #define MAR0    0x08            /* multicast addr reg 0 for rd and WR */ 
....................  
.................... /* NIC page 3 register offsets */ 
.................... #define RTL9346CR 0x01          /* RTL 9346 command reg */  
.................... #define RTL3    0x06            /* RTL config reg 3 */ 
....................  
.................... /* NIC RAM definitions */ 
.................... #define RAMPAGES 0x20           /* Total number of 256-byte RAM pages */ 
.................... #define TXSTART  0x40           /* Tx buffer start page */ 
.................... #define TXPAGES  6              /* Pages for Tx buffer */ 
.................... #define RXSTART  (TXSTART+TXPAGES)      /* Rx buffer start page */ 
.................... #define RXSTOP   (TXSTART+RAMPAGES-1)   /* Last Rx buffer page */ 
.................... #define DCRVAL   0x48           /* Value for data config reg */ 
....................  
.................... #define MACLEN   6 
.................... BYTE myeth[MACLEN] = {0x00, 0x04, 0xa3, 0, 0, 0}; 
.................... int next_page; 
.................... BYTE curr_rx_page; 
....................  
.................... typedef struct {                // NIC hardware packet header 
....................     BYTE stat;                  //     Error status 
....................     BYTE next;                  //     Pointer to next block 
....................     WORD len;                   //     Length of this frame incl. CRC 
.................... } NICHEADER; 
....................  
.................... typedef struct {                // Ethernet frame header  
....................     BYTE dest[MACLEN];          //     Dest & srce MAC addresses  
....................     BYTE srce[MACLEN]; 
....................     WORD pcol;                  //     Protocol  
.................... } ETHERHEADER; 
....................  
.................... typedef struct {                // NIC and Ethernet headers combined 
....................     NICHEADER nic; 
....................     ETHERHEADER eth; 
.................... } NICETHERHEADER; 
....................  
.................... NICETHERHEADER nicin;           // Buffer for incoming NIC & Ether hdrs  
....................  
.................... WORD rxin, rxout;               // Rx buffer counts (NIC RAM is buffer) 
.................... BOOL atend; 
....................  
.................... #define TXBUFFLEN 64             
.................... BYTE txbuff[TXBUFFLEN];         // Tx buffer 
.................... int txin, txout; 
....................  
.................... /* Prototypes */ 
.................... void setnic_addr(WORD addr); 
.................... WORD getnic_addr(void); 
.................... BYTE getnic_byte(void); 
.................... int getnic_data(BYTE *data, int len); 
.................... int getnic_rx(WORD addr, WORD len); 
.................... void putnic_byte(BYTE b); 
.................... void putnic_data(BYTE *data, int len); 
.................... BYTE nicwrap(int page); 
.................... BYTE innic(int reg); 
.................... void outnic(int reg, int b); 
....................  
.................... /* Prototypes for network driver */ 
.................... BYTE getch_net(void); 
.................... void putch_net(BYTE b); 
.................... void check_byte(BYTE b); 
.................... void swapw(WORD &val); 
....................  
.................... /* Return non-zero if MAC address is a broadcast */ 
.................... BOOL is_mac_bcast(BYTE *addr) 
.................... { 
....................     return((addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff); 
.................... } 
....................  
.................... /* Get a byte from network buffer; if end, set flag */ 
.................... BYTE getch_net(void) 
.................... { 
*
0A69:  BSF    03,6
0A6A:  CLRF   37
....................     BYTE b=0; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -