baby_1
Advanced Member level 1
Hello
here is my program
in this program when is reset the SSPCON1bits.SSPEN or set it SSPCON1bits.SSPEN=0; it i see some puls in PORTC.3 but when i changed it into SSPCON1bits.SSPEN=1; it doesn't show me any puls but in the datasheet it shows me that (SSPEN=1;Enables the serial port and configures the SDA and SCL pins as the serial port pins)? !!!!
could you tell me what is my problem to use ds1307 and PIC18f452, because i see only 254 or 255 in bcd mode!!! i pulled up the scl and sda with 10kohm resistor
here is my program
PHP:
#include <p18f452.h>
#include <delays.h>
#include<stdio.h>
#include <usart.h>
#include<sw_i2c.h>
#include "LCD.h"
#pragma config OSC=HS
#pragma config WDT=OFF
#pragma config PWRT=ON
#pragma config LVP=OFF
unsigned char x;
void babys(){
SWStartI2C();
SWPutcI2C(0xd0);
SWPutcI2C(0);
SWPutcI2C(0);
SWStopI2C();
}
void babyx(){
SWStartI2C();
SWPutcI2C(0xd0);
SWPutcI2C(0);
SWRestartI2C();
SWPutcI2C(0xd1);
x=SWReadI2C();
SWStopI2C();
}
unsigned char BCD2UpperCh(unsigned char bcd)
{
return ((bcd >> 4) + '0');
}
unsigned char BCD2LowerCh(unsigned char bcd)
{
return ((bcd & 0x0F) + '0');
}
void main(void){
unsigned char msg[17];
SSPSTATbits.SMP=1;
SSPSTATbits.CKE = 0;
SSPCON1bits.SSPEN=1;
SSPCON1bits.SSPM3=1;
SSPCON1bits.SSPM2=0;
SSPCON1bits.SSPM1=0;
SSPCON1bits.SSPM0=0;
SSPCON2bits.RCEN=1;
SSPCON2bits.SEN=1;
SSPCON2bits.GCEN=1;
TXSTA=0x22;
TRISCbits.RC3=0;
TRISCbits.RC4=0;
RCSTAbits.SPEN=1;
SPBRG=12;
TRISDbits.RD2=0x0;
lcdinit();
cls();
babys();
while(1)
{
babyx();
locate(1,1);
sprintf(msg,"Second(BCD):%d ",x);
lcdprint(msg);
Delay100TCYx(10);
if(x<200)
{
locate(2,1);
sprintf(msg,"Second(BCD):%d ",x);
lcdprint(msg);
Delay100TCYx(10);
}
Delay10KTCYx(10);
}
}
in this program when is reset the SSPCON1bits.SSPEN or set it SSPCON1bits.SSPEN=0; it i see some puls in PORTC.3 but when i changed it into SSPCON1bits.SSPEN=1; it doesn't show me any puls but in the datasheet it shows me that (SSPEN=1;Enables the serial port and configures the SDA and SCL pins as the serial port pins)? !!!!
could you tell me what is my problem to use ds1307 and PIC18f452, because i see only 254 or 255 in bcd mode!!! i pulled up the scl and sda with 10kohm resistor