I2C RTC DS1307
Discussion in "AVR Discussion Forum" started by MATHIVANAN Nov 1, 2007.
Thu Nov 01 2007, 03:37 pm
I had problem in my RT C.. how can i configure with timing specification... i connected my hardware as recommended by the Dallas, but i don't know the all values are coming FF...
i connected pullup resistor also Rp=4.75kohm..i gone through data sheet many times..
i connected pullup resistor also Rp=4.75kohm..i gone through data sheet many times..
Thu Nov 01 2007, 09:00 pm
can i see your circuit and program to know what you are doing?
MATHIVANAN like this.
Fri Nov 02 2007, 02:47 pm
i cann"t give the data sheet to public due to our org policy..
but i told u.. which pin i am using
i am using ATMEGA8515
and RTC DS1307
pins: PINC1-SDA
PINC0-SCL
i am not using Square wave input and output.
i gone through datasheet and my program many times
my oscillator is not enabled
how can i initialize?
but i told u.. which pin i am using
i am using ATMEGA8515
and RTC DS1307
pins: PINC1-SDA
PINC0-SCL
i am not using Square wave input and output.
i gone through datasheet and my program many times
my oscillator is not enabled
how can i initialize?
Fri Nov 02 2007, 04:33 pm
the first register of DS1307 has CH (clock halt bit).. make it 0 and oscillator will start working
MATHIVANAN like this.
Mon Nov 05 2007, 12:56 pm
i check that one also ..but its not working.. please tell me how to configure all those parameters.. or give me asm program for RTC avr family
Mon Nov 05 2007, 01:43 pm
i need to see your program and circuit.. to check what you are doing in it..
[ Edited Mon Nov 05 2007, 01:44 pm ]
MATHIVANAN like this.
Mon Nov 05 2007, 03:50 pm
i am not connected anything on the PORTC except RTC i am using I2Cprotocol. how can i start , either sending the start bit, or SDA and SCL is high after that can i send start bit. we are not going to schematic. so i am unable to release the circuit.. but i clearly tell to u.. i am using PORTC PINC0- SCL AND PINC1 FOR SDA.
Tue Nov 06 2007, 08:43 am
MY RTC IS WORKING PROPERLY .. MY MISTAKE IS CONFIGURATION PORT IN AVR WE CAANT DO SINGLE PIN CONFIGURATION
MY PROGRAM:
MY PROGRAM:
;INITIALIZE INITIALIZE_SYSTEM_CLOCK_PORTS: LDI R16,(1<<DDC0) OUT DDRC,R16 LDI R16,(1<<DDB0) OUT DDRB,R16 LDI R16,(1<<PC0) LDI R17,(1<<PB0) OUT PORTC,R16 OUT PORTB,R17 RCALL TIME_5US RCALL START_RTC RCALL RTC_INITIATE LDI R16,(1<<DD_MOSI)|(1<<DD_SCK)|(1<<DDB0) OUT DDR_SPI,R16 LDI R16,(1<<PB0) OUT PORTB,R16 ;READ TIME STAMP READ_TIME_STAMP: RCALL START_RTC RCALL INITIATE_TIME_STAMP RCALL CHANGE_OPTOIP_PORT RCALL GET_TIME RET CHANGE_OPTOIP_PORT: LDI R16,(0<<DDB0) OUT DDRB,R16 LDI R16,(0<<PB0) OUT PORTB,R16 RET INITIATE_TIME_STAMP: LDI R20,$D0 RCALL WRITE_BYTE RCALL GET_ACK LDI R20,$00 RCALL WRITE_BYTE RCALL GET_ACK RCALL REPEATED_START LDI R20,$D1 RCALL WRITE_BYTE RCALL GET_ACK RET GET_TIME: LDI R25,$07 GET_TIME_LOOP: RCALL LOOP_READ RCALL SEND_ACK DEC R25 BRNE GET_TIME_LOOP RCALL SEND_NOT_ACK RCALL STOP_RW RET START_RTC: LDI R16,(0<<PB0) OUT PORTB,R16 RCALL TIME_5US LDI R16,(0<<PC0) OUT PORTC,R16 RCALL TIME_5US RET RTC_INITIATE: LDI R20,$D0 RCALL WRITE_BYTE RCALL GET_ACK LDI R20,$00 RCALL WRITE_BYTE RCALL GET_ACK LDI R20,$00 RCALL WRITE_BYTE RCALL GET_ACK RCALL STOP_RW RET REPEATED_START: LDI R16,(1<<PB0) OUT PORTB,R16 NOP NOP LDI R16,(1<<PC0) OUT PORTC,R16 RCALL TIME_5US LDI R16,(0<<PB0) OUT PORTB,R16 RCALL TIME_5US LDI R16,(0<<PC0) OUT PORTC,R16 RCALL TIME_5US RET LOOP_READ: LDI R17,$08 CLR R16 ST Z+,R16 LOOP_READ1: LDI R16,(1<<PC0) OUT PORTC,R16 RCALL TIME_5US IN R16,PINB CLC LSR R16 ROL R20 LDI R16,(0<<PC0) OUT PORTC,R16 RCALL TIME_5US DEC R17 BRNE LOOP_READ1 ST Z+,R20 RET SEND_ACK: RCALL CHANGE_IPTOOP_PORT LDI R16,(0<<PB0) OUT PORTB,R16 LDI R16,(1<<PC0) OUT PORTC,R16 RCALL TIME_5US LDI R16,(0<<PC0) OUT PORTC,R16 RCALL CHANGE_OPTOIP_PORT RET WRITE_BYTE: LDI R17,$08 WRITE_LOOP: CLC CLR R21 LSL R20 ROL R21 OUT PORTB,R21 LDI R16,(1<<PC0) OUT PORTC,R16 RCALL TIME_5US LDI R16,(0<<PC0) OUT PORTC,R16 RCALL TIME_5US DEC R17 BRNE WRITE_LOOP RET GET_ACK: LDI R16,(0<<DDB0) OUT DDRB,R16 LDI R16,(0<<PB0) OUT PORTB,R16 NOP LDI R16,(1<<PC0) OUT PORTC,R16 GET_ACK_LOOP: SBIC PINB,PINB0 RJMP GET_ACK_LOOP RCALL TIME_5US LDI R16,(0<<PC0) OUT PORTC,R16 RCALL TIME_5US LDI R16,(1<<DDB0) OUT DDRB,R16 RET STOP_RW: LDI R16,(0<<PB0) OUT PORTB,R16 LDI R16,(1<<PC0) OUT PORTC,R16 RCALL TIME_5US LDI R16,(1<<PB0) OUT PORTB,R16 RCALL TIME_5US RET CHANGE_IPTOOP_PORT: LDI R16,(0<<PB0) OUT PORTB,R16 LDI R16,(1<<DDB0) OUT DDRB,R16 RET SEND_NOT_ACK: RCALL CHANGE_IPTOOP_PORT LDI R16,(1<<PB0) OUT PORTB,R16 LDI R16,(1<<PC0) OUT PORTC,R16 RCALL TIME_5US LDI R16,(0<<PC0) OUT PORTC,R16 RCALL TIME_5US RET TIME_5US: PUSH R18 LDI R18,$05 TIME_5US_LOOP: NOP NOP NOP NOP NOP NOP NOP NOP DEC R18 BRNE TIME_5US_LOOP POP R18 RET
[ Edited Tue Nov 06 2007, 11:48 pm ]
Tue Nov 06 2007, 12:42 pm
i think you are doing wrong in program..
do you know how I2C works?
can you tell me what you are doing in your START_RTC?
better you first make simple I2C routines.. there are basic five routines needed..
I2C_start, I2C_read, I2C write, I2C ack, I2C_stop
so first you simply write them after that try to work on I2C peripherals you can take 8051 i2c routines for reference.
do you know how I2C works?
can you tell me what you are doing in your START_RTC?
better you first make simple I2C routines.. there are basic five routines needed..
I2C_start, I2C_read, I2C write, I2C ack, I2C_stop
so first you simply write them after that try to work on I2C peripherals you can take 8051 i2c routines for reference.
Powered by e107 Forum System