Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC Digital Clock

Status
Not open for further replies.
No, you shouldn't have to 'HALT' it, must be something else. How are you writing, can you post a short snippet of the code you are using?
 
Hi here is the routine I use
RTC_brst_Wr movlw b'00101000' ; Select I2C master mode
banksel SSPCON
movwf SSPCON
movlw I2CRATE ; Set the bus speed
banksel SSPADD
movwf SSPADD
movlw b'00000000' ; And clear any status flags
banksel SSPSTAT
movwf SSPSTAT
call I2CStop ; Ensure the bus is free

;write to ds 1307 with user values
call I2CStart ; Take control of the I2C bus
movlw DS1307|I2C_WR
call I2CWrite ; Send the RTC write command
movlw h'00'
call I2CWrite ; And the register index
call I2CRestart ; Then restart the I2C bus
movf SECS, W
call I2CWrite
movf MINS, W
call I2CWrite
movf HRS, W
call I2CWrite
movf DOW, W
call I2CWrite
movf DAYS, W
call I2CWrite
movf MON, W
call I2CWrite
movf YRS, W
call I2CWrite
call I2CAck
call I2CStop

return
 
Well, any change?
I've looked over what you posted, and as far as I can see, there aren't problems, but then..
What values are you ORing together (DS1307|I2C_WR) to send as the write command? Is your slave address DS1307 and the write command I2C_WR?

According to Dallas' app note **broken link removed**
they don't do the nak near the end of your loop.
 
Hello I found the problem.I was using 4.7KOhms resistor as pullup for SDA and SCL. When I changed it to 10kOhms it started working finely. But Now I am facing another problem i.e. I have used the tutorial6.6 but I cannot read the keys. I am using the same port for I2C and keys i.e. Port C.Kindly anyone give me the source code for reading the 4 keys.
 
Hello,
As far as reading the key is concernerned i can blink the cursor and increment takes place only once. No other keys i.e. decrement and the next character keys doesn't work. If I remove the increment ket connection then decrement key decrements for one step only. I doubt there is some error in initialisation but I cannot figure out. Please help. I am using 16f877a and I teried the PORTA, PORTB--- result same.I develop using developement board.
 
Hello I am struggling with keypad routine. Key value floats and even if I do not press the key the value is detected and values are written. Please Help.
 
muralibhat said:
Hello I am struggling with keypad routine. Key value floats and even if I do not press the key the value is detected and values are written. Please Help.
Sounds like noise on the lines, which you are reading as keypresses; look up(google) key debounce, or switch debounce and you'll get tons of info. You can do it with hardware, or in software. You are using a micro, so software debounce is probably your best bet.
 
Hello I am back
I have almost finished my project. But I am stuck in editing the time i.e to write user defined values to DS1307. Whenevr I write the values after the input from keys it displays erroneous time. I use indirect addressing mode for updating the time registers and aftre finishing editing I write the values to DS 1307
Please Help
 
Are you converting the values from what you're using on the PIC, to the format required on the DS1307? - assuming the DS1307 uses a different format, as clock chips tend to.
 
The values are not converted. If I write the predefined values, by making a subroutine, the clock gets updated but if only I use the values defined from the keys the clock does't get updated to the new values. I think the problem is in the indirect addressing. Is it nessasary to reset the PSR to the begining of the register array.
Thank You
 
problem in writing to RTC

Nigel Goodwin said:
You shouldn't ever assume anything, if you're not specifically setting the index value, how do you know what it is?, and where it might be pointing?.

Thank You, I have set the pointer to the location before I set the time buf registers but after setting the registers I am unable to write it to the RTC i.e this problem is arising only if I enter the subrouine to set the keys. I wrote a seperate subroutine to set the clock with specific data For example
movlw h'12'
movwf HRS and so on.I modified your toutorials 6.1 with interrupt to read the keys
Kindly Help
 
I Did It. I was making mistake by not selecting the proper memory bank. When I used the banksel my problem got solved and my clock is working. Now I have to work out for swiching on the pumpset when the power is back and switching it off after a set time etc.
Thanks for everyone co-operated
 
guys, how about a digital clock using pic16f84a?? do you guys have any suggested sites??? because just like muralibhat i didnt got a specific result of this project using pic16f84a.... pls help!!! coz starting today i only got 10 more days left to do it..

Why not go to this web site and look under downloads, then JULY 2001, you find there a perfect PIC16F84A digital alarm clock that works very well, also easy to build
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top