You are an excellent person!:-)
Quote:
Originally Posted by Jumper
Hi,
If you dont use a backup battery for the 1307 make sure that the un-used leg for the backup function is tied to ground. You can find this in the datasheet but if this is not done the chip will not work properly (sometimes it doesn't, other times it does but never when you want it to).
We are using the 1307 and it is doing fine.
TRIS? = %00000000 ' all pins to output just replace ? with port name
SDA var Port?.? 'define port for I2C communication replace ?.? with pin
SCL var Port?.?
Hours var Byte
Minutes var Byte
Seconds var Byte
RTC var Byte
I2C_Adr_B var byte
RTC = % 11010000 ' Device adress on I2C bus
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[128,0,0,0,0,0,0,128] 'Reset time to 0 and stopped, 12 hour setting
Start_RTC:
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[0,0,0,0,0,0,0,16] 'Start RTC if you put a resistor and LED between the "SEC" pin and 5V it should start flash 1/s
return
RTC_Read:
I2C_Adr_B=0
I2CREAD SDA,SCL,RTC,I2C_Adr_B,[seconds,minutes, hours] ' in bcd code
return
call each part with a GOSUB
Good luck and enjoy
__________________________________________________ _____________
i wouldl ike to thank you so much! but now i returned home and far from my Lab. I will try it tomorrow. is it suitable for PIC16F876A? and by the way, how to set the date and time to: "10:15:30 01-06-2006 "? can you tell me how and in which part of your program?
thank you again....
you guessed right..i'm so squeezed by time..
Quote:
Originally Posted by BobK
Maybe you should post some of the code you have so far and give us a schematic to look at. I can feel the panic in your requests. We want to help but can only go so far here!
__________________________________________________ _______________
To tell you the truth, i have right now 15 programs related to real time clock and elapsed time and i'm not able to use any of them...
as i said before, i don't know anything about PicBasic Pro, nor PIC, nor RTC. I just got stuck with this situation and should make it pass.. i'm simply a biomedical engineer..
so for example, i'll tell you what i did yesterdsay night. This is a program from Melanie (thanks Melanie for providint such important program) :
http://www.melabs.com/resources/samp...ted/MN1307.txt
i will not paste it here because it's too long...
but she's using PIC16F628. For me, i didn't find it; i found 16F628A which must be similar.... right?
i did the circuit as she was saying (bought 2 Lines LCD), connetions to PIC and for DS1307, there was a suspicious part in some lines she wrote:
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++
" ' 10K Resistors required from PORTB.1 and PORTB.2 to Vdd
' PORTB.0 relies on weak pull-up's (for future use)
'
SQWpin var PORTB.0
' You don't actually need to wire this pin... but...
' If you're observant, you'll notice I've wired the DS1307's
' SQW to RB0. Rather than 'poll' and display the time/date
' as in this example code, you can have an interrupt
' on RB0 each second to do this. In fact if you look at
' my code for setting the DS1307 you'll see I've already
' programmed it for a 1 second 'Tick' for exactly this
' purpose...
SCLpin var PORTB.1
SDApin var PORTB.2
'
' Setting Buttons
' ---------------
' Buttons are connected between PORTB.4, 5 & 6 down to Vss
' No Resistors required - we're using weak pull-up's
'
DecButton var PORTB.4 ' Press to Decrement Button
SetButton var PORTB.5 ' Press to Set/memorise Button
IncButton var PORTB.6 ' Press to Increment Button
"
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++
so i just "connected": SQWpin of DS to PORTB.0
SCLpin to PORTB.1
SDApin to PORTB.2
and for ports B.4 ,B.5 and B.6, i have put "push buttons" to ground.
and also i have put 10K resistors as she said.
so i got the same unused ports that she mentioned and was happy because i felt that it will work!
now the programming section came....
i just copied and pasted the whole program on PicBasic Pro, compiled it, things were fine.
Then, using the programmer (i'm using ICPROG), i put the PIC, chose 16F862A and programmed but it gave:
"verify error at location 0000xH"
so i retuend to the program and paid attention to some sentences Melanie wrote in the beginning:
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
i tried to add "A" near each "8" but didn't work... so i noticed that i am already doing these setting from ICPROG (by checking what i need) so i removed all this section and programmed without it. It worked.
it was time to test..
LCD is just giving black rectangles.. nothing else :-( :-( !!!!
i don't know what to do... i downloaded all this program to PIC... we do not program DS1307 also? no program should be inserted inside it?
i also used a crystal for it... 32.768 as i remember...
so here it is, i explained one case...and i previously fell in many previous similar cases... no one here around me is ready to help so i just thought that maybe i can find help on the internet. This is why i am sending many posts.... i should finish this whole work by next friday... i'm working on the biomedical part and do not have too much time to sit, read manual, try exercises, build more circuits and test.... i can't lay my legs Bob! i'm working on this project 20 hours a day since 3 months! can you beleive it? so i "really" cannot sit and just be in the mood to learn PicBasic Pro and I2c and RTC.....
in case someone would be able to help i'll be grateful..
You were wrong this time Melanie..
He apologised today... he meant by "programming" the real meaning and not as many expected.. Simply, he meant that i should put all the program inside DS1307.... i think he didn't have any idea about this DS...
anyway, life continues.... i'm about to present my project on friday.Still delaying this matter of timer because it makes me nervous! have i ever said that i designed a new instrument that analyzes blood, saliva and bones at the same time?
It's so useful and i am working now on reducing it's size... i'm using MEMS technlogy in case anyone is interested.
This is why i'm so squeezed by time and do not have time to read any discover new and silly datasheets.... time is treasure and i cannot lose it.
So if this timer does not work it doesn't matter but i just hope it will work so that i can display time and date on the screen or maybe put a timer to be used by patients.
One more thing about "Project MN1307"
It is located at:
http://www.melabs.com/resources/samp...ted/MN1307.txt
for those who are interested.
No more fabrication of PIC 16F628 or 16F876, and this is worldwide done. It's same case for other PICs. They are being replaced by 16F628A and 16F876A.
so, can this program be used directly on a pic 16F628A without facing any problem or changing any code?
I will try it on a 4-line LCD but i just want to know about the PIC... yesterday, Melanie gave me a way to stop the comparators on 16F876A. So should something be done for this 16F628A?
thank you.