MUKESH.K.S
Full Member level 1
- Joined
- Jan 31, 2014
- Messages
- 98
- Helped
- 14
- Reputation
- 28
- Reaction score
- 13
- Trophy points
- 1,288
- Location
- KERALA
- Activity points
- 1,891
I completed a project based on ds1307 and pic16f877a. It works very well in proteus but its not working in hardware. I have tried many times with changing pull up res value ,connecting vbat to gnd etc but it still not working ....here is my pgm
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 #include <htc.h> #ifndef _XTAL_FREQ #define _XTAL_FREQ 11059000 #endif __CONFIG(FOSC_HS & WDTE_OFF& PWRTE_OFF & BOREN_OFF & LVP_OFF & WRT_OFF & DEBUG_OFF & CPD_OFF & CP_OFF); void I2CMASTER(void); void I2CSTART(void); void I2CSTOP(void); void I2CREPSTART(void); int I2CTRANSMIT(unsigned char temp5); unsigned char I2CRECEIVE( int); void main() { TRISD7=1; OPTION_REG=0X38; //TIMER CONFIG PSA=1; TRISB=0XFF; TRISD=0X00; PORTB=0XFF; TMR0=0X00; TRISB=0X00; I2CMASTER(); __delay_ms(1000); while(1) { if(RB7==0) { while(RB7==0); I2CSTART(); I2CTRANSMIT(0XD0); I2CTRANSMIT(0X00); I2CTRANSMIT(0X00); I2CSTOP(); I2CSTART(); I2CTRANSMIT(0XD0); I2CTRANSMIT(0X07); I2CTRANSMIT(0X10); I2CSTOP(); } } } void I2CMASTER(void) { SSPADD=0Xff; WCOL=0; CKP=1; SSPM3=1; SSPM2=0; SSPM1=1; SSPM0=1; SSPEN=1; TRISC=0X00; TRISC4=1; TRISC3=1; } void I2CSTART(void) { SEN=1; while(SEN==1); } void I2CSTOP(void) { PEN=1; while(PEN==1); } void I2CREPSTART(void) { RSEN=1; while(RSEN==1); } int I2CTRANSMIT(unsigned char temp5) { ACKSTAT=0; SSPBUF=temp5; while(R_W==1); return(ACKSTAT); }
Last edited by a moderator: