#include // demo of Mike's optimised IIC code for eeprom access under hitech C // (C) Mike Harrison 2001 email mike -at- whitewing.co.uk // Note that this doesn't seem to work when local optimisation is enabled, as it // appears to 'optimise' the asm code by simply ignoring it! Global optimisation seems to be OK. // this is intended for inclusion within C source, not as a seperate 'extern' module // It could be converted to the latter form easily, and this would avoid the above optimisation // problem. (If anyone does this please let me have a copy!) // see notes on original assembler version for more details. // this version works under hitech C V7.86, and was tested on a PIC16C74 // if anyone who knows C better can suggest any improvements to the C side of this please let me know! //asm macros #define c 0 #define z 2 #define skpnc btfsc _STATUS,c #define skpc btfss _STATUS,c #define sec bsf _STATUS,c #define clc bcf _STATUS,c #define skpz btfss _STATUS,z #define skpnz btfsc _STATUS,z #define tris dw 0x60+ #define rp0 5 // define indf - missing from hitech static volatile unsigned char INDF @ 0x00; // eeprom port bits (PORT A) #define sclbit 2 #define sdabit 3 #define ee_scl _PORTA,sclbit #define ee_sda _PORTA,sdabit #define hitris 0x1a // PORT A TRIS for SDA high #define lotris hitris-(1<