CCS PCH C Compiler, Version 5.048, 26145               28-Mar-23 11:59

               Filename:   C:\Users\soac-gj2\Desktop\i2c multi master\ccs\main.lst

               ROM used:   132 bytes (0%)
                           Largest free fragment is 49020
               RAM used:   6 (0%) at main() level
                           7 (0%) worst case
               Stack used: 0 locations
               Stack size: 31

*
0000:  GOTO   0032
.................... #include <main.h> 
.................... #include <18F2525.h> 
.................... //////////// Standard Header file for the PIC18F2525 device //////////////// 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... ////        (C) Copyright 1996, 2014 Custom Computer Services          //// 
.................... //// This source code may only be used by licensed users of the CCS C  //// 
.................... //// compiler.  This source code may only be distributed to other      //// 
.................... //// licensed users of the CCS C compiler.  No other use, reproduction //// 
.................... //// or distribution is permitted without written permission.          //// 
.................... //// Derivative programs created using this software in object code    //// 
.................... //// form are not restricted in any way.                               //// 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... #device PIC18F2525 
....................  
.................... #list 
....................  
.................... #device ADC=10 
....................  
.................... #FUSES FCMEN                 	//Fail-safe clock monitor enabled 
.................... #FUSES IESO                  	//Internal External Switch Over mode enabled 
.................... #FUSES NOPUT                 	//No Power Up Timer 
.................... #FUSES BROWNOUT              	//Reset when brownout detected 
.................... #FUSES BORV27                	//Brownout reset at 2.7V 
.................... #FUSES NOPBADEN              	//PORTB pins are configured as digital I/O on RESET 
.................... #FUSES LPT1OSC               	//Timer1 configured for low-power operation 
.................... #FUSES NOMCLR                	//Master Clear pin used for I/O 
.................... #FUSES STVREN                	//Stack full/underflow will cause reset 
.................... #FUSES NOLVP                 	//No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O 
.................... #FUSES NOXINST               	//Extended set extension and Indexed Addressing mode disabled (Legacy mode) 
.................... #FUSES NOPROTECT             	//Code not protected from reading 
.................... #FUSES NOCPB                 	//No Boot Block code protection 
.................... #FUSES NOCPD                 	//No EE protection 
.................... #FUSES NOWRT                 	//Program memory not write protected 
.................... #FUSES NOWRTC                	//Configuration registers not write protected 
.................... #FUSES NOWRTB                	//Boot block not write protected 
.................... #FUSES NOWRTD                	//Data EEPROM not write protected 
.................... #FUSES NOEBTR                	//Memory not protected from table reads 
.................... #FUSES NOEBTRB               	//Boot block not protected from table reads 
....................  
.................... #use delay(internal=8MHz) 
*
000C:  CLRF   FEA
000E:  MOVLW  06
0010:  MOVWF  FE9
0012:  MOVF   FEF,W
0014:  BZ    0030
0016:  MOVLW  02
0018:  MOVWF  01
001A:  CLRF   00
001C:  DECFSZ 00,F
001E:  BRA    001C
0020:  DECFSZ 01,F
0022:  BRA    001A
0024:  MOVLW  97
0026:  MOVWF  00
0028:  DECFSZ 00,F
002A:  BRA    0028
002C:  DECFSZ FEF,F
002E:  BRA    0016
0030:  RETURN 0
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1,errors) 
.................... #use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3) 
....................  
.................... #define LED PIN_A7 
.................... #define DELAY 500 
....................  
....................  
....................  
....................  
.................... #include <2402.C> 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... ////   Library for a MicroChip 24LC02B configured for a x8 org         //// 
.................... ////                                                                   //// 
.................... ////   init_ext_eeprom();    Call before the other functions are used  //// 
.................... ////                                                                   //// 
.................... ////   write_ext_eeprom(a, d);  Write the byte d to the address a      //// 
.................... ////                                                                   //// 
.................... ////   d = read_ext_eeprom(a);  Read the byte d from the address a     //// 
.................... ////                                                                   //// 
.................... ////   b = ext_eeprom_ready();  Returns TRUE if the eeprom is ready    //// 
.................... ////                            to receive opcodes                     //// 
.................... ////                                                                   //// 
.................... ////   The main program may define EEPROM_SDA                          //// 
.................... ////   and EEPROM_SCL to override the defaults below.                  //// 
.................... ////                                                                   //// 
.................... ////                            Pin Layout                             //// 
.................... ////   -----------------------------------------------------------     //// 
.................... ////   |                                                         |     //// 
.................... ////   | 1: NC   Not Connected | 8: VCC   +5V                    |     //// 
.................... ////   |                       |                                 |     //// 
.................... ////   | 2: NC   Not Connected | 7: WP    GND                    |     //// 
.................... ////   |                       |                                 |     //// 
.................... ////   | 3: NC   Not Connected | 6: SCL   EEPROM_SCL and Pull-Up |     //// 
.................... ////   |                       |                                 |     //// 
.................... ////   | 4: VSS  GND           | 5: SDA   EEPROM_SDA and Pull-Up |     //// 
.................... ////   -----------------------------------------------------------     //// 
.................... ////                                                                   //// 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... ////        (C) Copyright 1996, 2003 Custom Computer Services          //// 
.................... //// This source code may only be used by licensed users of the CCS C  //// 
.................... //// compiler.  This source code may only be distributed to other      //// 
.................... //// licensed users of the CCS C compiler.  No other use, reproduction //// 
.................... //// or distribution is permitted without written permission.          //// 
.................... //// Derivative programs created using this software in object code    //// 
.................... //// form are not restricted in any way.                               //// 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... #ifndef EEPROM_SDA 
....................  
.................... #define EEPROM_SDA  PIN_C4 
.................... #define EEPROM_SCL  PIN_C3 
....................  
.................... #endif 
....................  
....................  
.................... #use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL) 
....................  
.................... #define EEPROM_ADDRESS BYTE 
.................... #define EEPROM_SIZE    256 
....................  
.................... void init_ext_eeprom() { 
....................    output_float(EEPROM_SCL); 
*
0004:  BSF    F94.3
....................    output_float(EEPROM_SDA); 
0006:  BSF    F94.4
0008:  GOTO   005C (RETURN)
.................... } 
....................  
.................... BOOLEAN ext_eeprom_ready() { 
....................    int1 ack; 
....................    i2c_start();            // If the write command is acknowledged, 
....................    ack = i2c_write(0xa0);  // then the device is ready. 
....................    i2c_stop(); 
....................    return !ack; 
.................... } 
....................  
.................... void write_ext_eeprom(BYTE address, BYTE data) { 
....................    while(!ext_eeprom_ready()); 
....................    i2c_start(); 
....................    i2c_write(0xa0); 
....................    i2c_write(address); 
....................    i2c_write(data); 
....................    i2c_stop(); 
.................... } 
....................  
....................  
.................... BYTE read_ext_eeprom(BYTE address) { 
....................    BYTE data; 
....................  
....................    while(!ext_eeprom_ready()); 
....................    i2c_start(); 
....................    i2c_write(0xa0); 
....................    i2c_write(address); 
....................    i2c_start(); 
....................    i2c_write(0xa1); 
....................    data=i2c_read(0); 
....................    i2c_stop(); 
....................    return(data); 
.................... } 
....................  
....................  
.................... void main() 
*
0032:  CLRF   FF8
0034:  BCF    FD0.7
0036:  MOVLW  70
0038:  MOVWF  FD3
003A:  CLRF   F9B
003C:  MOVF   FD3,W
003E:  CLRF   04
0040:  BCF    FB8.3
0042:  MOVLW  0C
0044:  MOVWF  FAF
0046:  MOVLW  A2
0048:  MOVWF  FAC
004A:  MOVLW  90
004C:  MOVWF  FAB
004E:  MOVF   FC1,W
0050:  ANDLW  C0
0052:  IORLW  0F
0054:  MOVWF  FC1
0056:  MOVLW  07
0058:  MOVWF  FB4
.................... { 
.................... 	init_ext_eeprom(); 
005A:  BRA    0004
....................  
.................... 	while(TRUE) 
.................... 	{ 
....................  
.................... 		//Example blinking LED program 
.................... 		output_low(LED); 
005C:  BCF    F92.7
005E:  BCF    F89.7
.................... 		delay_ms(DELAY); 
0060:  MOVLW  02
0062:  MOVWF  05
0064:  MOVLW  FA
0066:  MOVWF  06
0068:  RCALL  000C
006A:  DECFSZ 05,F
006C:  BRA    0064
.................... 		output_high(LED); 
006E:  BCF    F92.7
0070:  BSF    F89.7
.................... 		delay_ms(DELAY); 
0072:  MOVLW  02
0074:  MOVWF  05
0076:  MOVLW  FA
0078:  MOVWF  06
007A:  RCALL  000C
007C:  DECFSZ 05,F
007E:  BRA    0076
0080:  BRA    005C
....................  
.................... 		//TODO: User Code 
.................... 	} 
....................  
.................... } 
0082:  SLEEP 

Configuration Fuses:
   Word  1: C800   INTRC_IO FCMEN IESO
   Word  2: 1E17   NOPUT BROWNOUT BORV27 NOWDT WDT32768
   Word  3: 0500   CCP2C1 NOPBADEN LPT1OSC NOMCLR
   Word  4: 0081   STVREN NOLVP NOXINST NODEBUG
   Word  5: C00F   NOPROTECT NOCPB NOCPD
   Word  6: E00F   NOWRT NOWRTC NOWRTB NOWRTD
   Word  7: 400F   NOEBTR NOEBTRB
