patanong... to be exact sir, ano yung delay.h? nagstruggle ako gumawa ng sariling ds1307 driver. guided na din naman gawa nung driver sa CCSinfo.parang mas gusto ko to kasi software i2c to di ba?
/* * Delay functions * See delay.h for details * * Make sure this code is compiled with full optimization!!! */#include "delay.h"voidDelayMs(unsigned char cnt){#if XTAL_FREQ <= 2MHZ do { DelayUs(996); } while(--cnt);#endif#if XTAL_FREQ > 2MHZ unsigned char i; do { i = 4; do { DelayUs(250); } while(--i); } while(--cnt);#endif}
/* * Delay functions for HI-TECH C on the PIC * * Functions available: * DelayUs(x) Delay specified number of microseconds * DelayMs(x) Delay specified number of milliseconds * * Note that there are range limits: x must not exceed 255 - for xtal * frequencies > 12MHz the range for DelayUs is even smaller. * To use DelayUs it is only necessary to include this file; to use * DelayMs you must include delay.c in your project. * *//* Set the crystal frequency in the CPP predefined symbols list in HPDPIC, or on the PICC commmand line, e.g. picc -DXTAL_FREQ=4MHZ or picc -DXTAL_FREQ=100KHZ Note that this is the crystal frequency, the CPU clock is divided by 4. * MAKE SURE this code is compiled with full optimization!!! */#ifndef XTAL_FREQ#define XTAL_FREQ 4MHZ /* Crystal frequency in MHz */#endif#define MHZ *1000L /* number of kHz in a MHz */#define KHZ *1 /* number of kHz in a kHz */#if XTAL_FREQ >= 12MHZ#define DelayUs(x) { unsigned char _dcnt; \ _dcnt = (x)*((XTAL_FREQ)/(12MHZ)); \ while(--_dcnt != 0) \ continue; }#else#define DelayUs(x) { unsigned char _dcnt; \ _dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \ while(--_dcnt != 0) \ continue; }#endifextern void DelayMs(unsigned char);
ano naman yung io.h? dami kong tanong... heheh
//define the following externally on io.h file/* //port pin assignment #define SCL RA5 #define SCL_TRIS TRISA5 #define SDA RA4 #define SDA_TRIS TRISA4*/
Ok lang.Sir, ito yung definition ng IO na ginagamit sa I2C.On the top part sa source code naka-comment ito:Code: [Select]//define the following externally on io.h file/* //port pin assignment #define SCL RA5 #define SCL_TRIS TRISA5 #define SDA RA4 #define SDA_TRIS TRISA4*/Ito yung laman ng io.h or any ther io definitions sa overall program.This is a modular concept sa programming para hindi ako malito.Pwede ring tangalin ang io.h and copy/paste the code inside the .c file.
mga sir, cno po may alam kung magcrack ng PIc mcu...