Real time clock ICs


Closed Thread
Results 1 to 40 of 67

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi ENG4444,

    What Jumper is referring to with the GOSUB is that the routines "Start_RTC" and "RTC_Read" are called from your main program. Read the PBP manual referring to the word "GOSUB" for a further explanation.

    The clock setting portion is, as I stated in an earlier reply, is handled in the setup of the clock. You put these values in the variables for the clock, meaning "seconds", "minutes", "hours", etc then write them into the RTC.

    It really sounds to me that you are in such a panic to get this project done by 9am Monday morning that you can't slow down and pay attention to what we are trying to say to you. You have posted on several sections of this forum with different requests. One request is for an RTC for a clock. Another post says you need elapsed time. Several of us have provided you with the information you requested. So now what do you want? We are here to help you but from your ongoing statements you aren't learning anything or really don't understand what is being given to you.

    Sit back and put your feet up in the air and relax for a few minutes. Re-look at the information we have provided. Try a few of the example programs that have been provided to you and see what they may or may not do for you.

    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!

    BobK

    The example programs are documented as to what each portion of the program is doing. Look at them and they will show you where to enter the values for setting the clock.

  2. #2
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Default 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..

  3. #3
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Exclamation By the way BobK,

    you said:

    "
    "What Jumper is referring to with the GOSUB is that the routines "Start_RTC" and "RTC_Read" are called from your main program. Read the PBP manual referring to the word "GOSUB" for a further explanation.

    The clock setting portion is, as I stated in an earlier reply, is handled in the setup of the clock. You put these values in the variables for the clock, meaning "seconds", "minutes", "hours", etc then write them into the RTC. "
    __________________________________________________ ______________

    So do you mean that i should write all the program:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    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

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    in the PIC16F876A directly and it works?

    let's say i want to chose port B and pin 22 which is RB1
    23 which is RB2
    so i write:
    TRISB = %00000000
    SDA var PortB.1
    SCL var PortB.2
    true?
    and i wire b.1 to sda of DS, B.2 to SCL DS.... right?



    Now tell me, if i just connect PIC16F876A to this DS1307 and a 4 lines LCD (or 2 lines). and let's say i just want to use this whole PIC just for the DS (it's stupidity i know but let's say i will keep all ports not used) would this program, as he gave it to me, be enough to begin displaying time and date on LCD? or i should write more things that he didn't write thinking that i should know them..... ?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Since my original program was configured for a 4-Line LCD (which extensively used the LCDOut command), and you're using a 2-Line LCD which does not, unless you make significant changes to the program to compensate for the difference it's not exactly going to work, is it?

    You might need to be aware, that a 2-Line LCD communicates by SERIAL asynchronous. For reliability your PIC will ideally need to be driven by an Xtal or Resonator and not rely on the Internal Oscillator. See Thread...

    http://www.picbasic.co.uk/forum/show...nal+Oscillator

    A 4 or 8-wire connected LCD does not have this limitation.

    You obviously haven't a clue as to what you're doing. With your level of expertise, unless you EXACTLY replicate programs and hardware examples that are posted - without changes, your chances of success are slim to none.

    Let me put this into perspective... I catch a Cold. I therefore go into a BioMed Lab to devise a cure. I only need to cure my Cold, and then I will never set foot in a BioMed Lab ever again. I give myself a week to accomplish this... I am not a Doctor or a Scientist or even a BioMed Technician. All I know is that the Plasma they drip into your arm is the same stuff that drives the Starship Enterprise...

  5. #5
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Exclamation Dear Melanie,

    I already said that i have no clue...

    i have LCD 4 lines so i will try it....

  6. #6
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Exclamation By the way...

    This DS1307... we do not program it? just access it from PIC?

    A Professor here said that i am obliged to program it... one of us is stupid so who is it?


    for me, i have read so many examples but i never noticed that i should program a DS1307.... i just have to connect it to PIC and then access it by the program..

    Am i mistaken?

  7. #7
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Program it

    I think that the professor is using "program" loosely. You will write the time and date therby "programming it".

    Travin

  8. #8
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Eng4444
    LCD is just giving black rectangles.. nothing else :-( :-( !!!!
    Have you adjusted the contrast correctly.

    At one extreme it will display nothing, at the other extreme it will display black rectangles. Somewhere inbetween it will display the characters correctly.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  9. #9
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > Still again asking: should i change something related to PIC16F628A?

    If I don't know the answer to questions like will my program work on a 16F628 as well as a 16F628A... I would...

    1. Download both Datasheets and compare them...

    2. Create a simple program to display "I must learn to study Datasheets" on my LCD and compile it for a standard 16F628. I would then burn an 'A' version with that code and checked if it would still work.

    But that's me... you on the other hand would rather ask the same questions over and again on the forum... hint... if you tried option 2, you'd discover the answer in less than 15 minutes...

    Even Drugs and Chemicals have Datasheets - and you would use one of those without checking the Datasheet first?

    Code:
    	'
    	'	Device Programming Options
    	'	--------------------------
    	@ 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
    
    	'
    	'	Hardware Defines
    	'	----------------
    		'
    		' 	LCD Display
    		'	-----------
    	Define LCD_DREG PORTB				' Port for LCD Data
    	Define LCD_DBIT 4				' Use upper 4 bits of Port
    	Define LCD_RSREG PORTB				' Port for RegisterSelect (RS) bit
    	Define LCD_RSBIT 3				' Port Pin for RS bit
    	Define LCD_EREG PORTB				' Port for Enable (E) bit
    	Define LCD_EBIT 2				' Port Pin for E bit
    	Define LCB_BITS 4				' Using 4-bit bus
    	Define LCD_LINES 2				' Using 2 line Display
    	Define LCD_COMMANDUS 2000			' Command Delay (uS)
    	Define LCD_DATAUS 50				' Data Delay (uS)
    
    	'
    	'	Software Defines
    	'	----------------
    	CounterA var BYTE
    	CounterB var BYTE
    	CounterC var BYTE
    	DataA var BYTE
    
    	'
    	'	EEPROM Contents
    	'	---------------
    	Data @0,"I must learn not to be lazy and to read Datasheets!"
    
    	'
    	'	Initialise PIC
    	'	--------------
    	TRISA=%00000000			' PortA all OUTPUT
    	TRISB=%00000000			' PortB all OUTPUT
    	CMCON=%00000111			' Comparators OFF
    
    	'
    	'	Main Program
    	'	------------
    	Pause 2000			' Timeout for LCD Hardware to wake-up...
    	LCDOut $FE,1			' Clear Display
    Loop:
    	For CounterA=0 to 35
    		Gosub DisplayMessage
    		Next CounterA
    	Pause 1000
    	For CounterA=35 to 0 step -1
    		Gosub DisplayMessage
    		Next CounterA
    	Pause 1000
    	Goto Loop
    
    	'
    	'	Subroutine Displays Scrolling Message
    	'	-------------------------------------
    DisplayMessage:
    	LCDOut $FE,$80
    	For CounterB=0 to 16
    		CounterC=CounterA+CounterB
    		Read CounterC,DataA
    		LCDOut DataA
    		Next CounterB
    	Pause 500		
    	Return
    
    	End
    If the above doesn’t work for you, then there are still career openings in Landscape Gardening…
    Attached Images Attached Images  

  10. #10
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Exclamation Landscape gardening..

    Well that's simple!

    Without landscape gardening, nobody would have remained alive!!

    and that's a "TRUTH".

    Perhaps you people eat PIC16F876, PIC16F876A, PIC16F628, PIC16F628A, PIC16F88...... several delicious different vegetables and fruits! yeah?

    Maybe if just one of you read well what i was writing withouth playing the intelligent, would have understood what i was saying each time...


    Thank you for your cooperation.
    Sam.

  11. #11
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hello again Eng4444,

    It's nice to see that you are still here. Just to give a further example of what we are all trying to say to you, I just put the program that Melanie had just posted into an older project board of mine. Her program puts the LCD on PortB. Well my LCD is on PortA. So I made some minor changes to the program and tried it. It didn't work! Her program is for a 16F628 and I had a 16F872. I commented out the DEVICE setup and chose to set the configuration fuses through my programmer. Still didn't work. I only got blocks on line 1 of the LCD. So I opened the datasheet on the 16F872 and went to the section on the A/D module and found in the register explanation how to disable the A/D module and how to make the Analog pins all digital. Programmed the chip again and now the message scrolls across the screen!

    Now before you go and say what a smart ass you are let me explain that I do not have any degree in ANYTHING' I am a self employed alarm installer. I play with electronics for fun and once in a while I might make a few bucks making something to get the job done.

    I read this forum faithfully and pay attention to what the real pros like Melanie, Mister E, David Taylor, and the many other fine folks have to say when they offer their advise and expertise to someone. I really haven't gotten involved with anyone here to the extent that I have with you because I don't want to say or do something stupid. I don't think that you gave anyone here that has responded to you a fare shake. You say I dropped out. Well I didn't. I was reading everything. I read this forum at least twice a day and if I'm at a place that has internet access then I use my Dell handheld and go on to see what's up. If it wasn't for this forum and the fine people here I wouldn't have the knowledge I have today.

    By the way, I started at 7:15 this morning working on that little display program and was up and running including the troubleshooting in less than 1/2 hour. I keep the datasheets for the parts I use on my computer so that they are handy. The most frequently posted comment is read the datasheet. You don't have to read it like a novel, just refer to it once in a while. I know you are pressed for time so I won't hold you up. Good luck on you project! I have to goto work.

    Have a nice day!

    BobK
    Last edited by BobK; - 7th June 2006 at 14:02.

  12. #12
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Lightbulb Once again..

    i would say and repeat to you people:

    I DO NOT WORK WITH THIS TYPE OF TECHNOLOGY!!

    why no one understands??? i work with MEMS!!!!!!!! i already said it.....

    stop talking to me as if i'm a stupid intruder... you have your world and i have mine.. you are EXPERTS in PICs (this is why i came to you).

    and i am EXPERT in MEMS! ( in case someone needs anything related to MEMS i'll be ready!)

    Bobk, i checked your profile. I respect you very much but you made me nervous when you kept asking me to give details and schematics! So, i'm sorry to talk in a bad way to you.

    So here it is... a chematic! i did it with paint because with circuit builder it exceeds the attachement size. Those are the exact connections i did on Breadboard and then on PCB.

    And also, here is the program i used ( the same of Melanie):

    @ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT
    ' System Clock Options
    @ DEVICE pic16F628A, WDT_ON
    ' Watchdog Timer
    @ DEVICE pic16F628A, PWRT_ON
    ' Power-On Timer
    @ DEVICE pic16F628A, BOD_ON
    ' Brown-Out Detect
    @ DEVICE pic16F628A, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic16F628A, LVP_OFF
    ' Low-Voltage Programming
    @ DEVICE pic16F628A, CPD_OFF
    ' Data Memory Code Protect
    @ DEVICE pic16F628A, PROTECT_OFF


    Define LCD_DREG PORTA ' Port for LCD Data
    Define LCD_DBIT 0 ' Use lower 4 bits of Port
    Define LCD_RSREG PORTA ' Port for RegisterSelect (RS) bit
    Define LCD_RSBIT 6 ' Port Pin for RS bit
    Define LCD_EREG PORTA ' Port for Enable (E) bit
    Define LCD_EBIT 7 ' Port Pin for E bit
    Define LCB_BITS 4 ' Using 4-bit bus
    Define LCD_LINES 2 ' Using 2 line Display
    Define LCD_COMMANDUS 2000 ' Command Delay (uS)
    Define LCD_DATAUS 50 ' Data Delay (uS)


    SQWpin var PORTB.0
    SCLpin var PORTB.1
    SDApin var PORTB.2

    DecButton var PORTB.4
    SetButton var PORTB.5
    IncButton var PORTB.6

    Data @0,74,97,110,70,101,98,77,97,114,65,112,114
    ' Jan Feb Mar Apr
    Data 77,97,121,74,117,110,74,117,108,65,117,103
    ' May Jun Jul Aug
    Data 83,101,112,79,99,116,78,111,118,68,101,99
    ' Sep Oct Nov Dec
    Data 84,117,101,87,101,100,84,104,117,70,114,105
    ' Tue Wed Thu Fri
    Data 83,97,116,83,117,110,77,111,110
    ' Sat Sun Mon

    CounterA var byte
    CounterB var byte
    CounterC var byte
    CounterD var byte
    RTCSec var byte
    RTCMin var byte
    RTCHour var byte
    RTCWDay var byte
    RTCDay var byte
    RTCMonth var byte
    RTCYear var byte
    RTCCtrl var byte
    SetTime var byte
    SetSec var byte
    SetMin var byte
    SetHour var byte
    SetDay var byte
    SetMonth var byte
    SetYear var byte
    TimeOut var word

    ButtonRepeat con 200
    goto JumpStart

    ConvertBCD:
    CounterB=CounterA DIG 1
    CounterB=CounterB<<4
    CounterB=CounterB+CounterA DIG 0
    Return

    DisplayMonth:
    CounterB=CounterB*3-3
    DisplaySequence:
    For CounterA=CounterB to CounterB+2

    Read CounterA,CounterD
    LCDOut CounterD
    Next CounterA
    Return

    FindDays:
    LookUp SetMonth-1,[31,28,31,30,31,30,31,31,30,31,30,31],CounterA
    ' Above line gives the 'usual' days of the Month
    ' Section below adjusts for Leap-Year
    If SetMonth=2 then
    If (SetYear&$03)=0 then CounterA=29
    endif
    Return

    SetButtonRelease:
    LCDOut $FE,1
    While SetButton=0:Wend
    Pause 250 ' Small pause to kill any Key-Bounce
    Return

    JumpStart:
    CMCON=%00000111
    TRISA=%00000000
    TRISB=%11111111
    OPTION_REG.7=0
    Pause 200

    ReDisplay:
    LCDOut $FE,1
    ReDisplayLoop:

    I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl]

    If RTCSec.7=1 then goto SetUpPreset

    If SetButton=0 then
    Gosub SetButtonRelease
    goto Setup
    endif

    LCDOut $FE,$80
    If RTCHour.6=1 then

    CounterA=(RTCHour>>4)&$01
    else
    CounterA=(RTCHour>>4)&$03
    endif
    CounterA=CounterA*10+(RTCHour&$0F)
    If RTCHour.6=1 then

    LCDOut #CounterA
    else
    LCDOut #CounterA Dig 1,#CounterA Dig 0
    endif
    LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F,":"
    LCDOut #(RTCSec>>4)&$0F,#RTCSec&$0F," "
    IF RTCHour.6=1 then
    If RTCHour.5=1 then
    LCDOut "PM"
    else
    LCDOut "AM"
    endif
    endif

    LCDOut " ",$FE,$C0
    CounterB=RTCWDay*3+33
    Gosub DisplaySequence

    LCDOut " ",#(RTCDay>>4)&$0F,#RTCDay&$0F," "
    CounterB=((RTCMonth>>4)&$0F)*10+(RTCMonth&$0F)
    Gosub DisplayMonth
    LCDOut " 20",#(RTCYear>>4)&$0F,#RTCYear&$0F,$FE,$80
    '
    Pause 250
    Goto ReDisplayLoop

    SetupPreset:
    RTCSec=$00
    RTCMin=$15
    RTCHour=$13
    RTCWDay=$01
    RTCDay=$12
    RTCMonth=$06
    RTCYear=$02
    RTCCtrl=$10

    Setup:
    SetTime=RTCHour.6
    If SetTime=1 then

    SetHour=(RTCHour>>4)&$01

    else
    SetHour=(RTCHour>>4)&$03

    endif
    SetHour=SetHour*10+(RTCHour&$0F)
    If SetTime=1 then
    If RTCHour.5=1 then
    If SetHour<12 then SetHour=SetHour+12

    else
    If SetHour=12 then SetHour=0
    endif
    endif
    SetMin=((RTCMin>>4)&$0F)*10+(RTCMin&$0F)
    SetSec=((RTCSec>>4)&$0F)*10+(RTCSec&$0F)
    SetYear=((RTCYear>>4)&$0F)*10+(RTCYear&$0F)
    SetMonth=((RTCMonth>>4)&$0F)*10+(RTCMonth&$0F)
    SetDay=((RTCDay>>4)&$0F)*10+(RTCDay&$0F)

    CounterC=0
    TimeOut=0
    SetupLoop:
    LCDOut $FE,1,"Set "

    If CounterC=0 then
    LCDOut "Mode"
    endif
    If CounterC=1 then
    LCDOut "Hours"
    endif
    If CounterC=2 then
    LCDOut "Minutes"
    endif
    If CounterC=3 then
    LCDOut "Seconds"
    endif
    If CounterC=4 then
    LCDOut "Year : 20"
    endif
    If CounterC=5 then
    LCDOut "Month"
    endif
    If CounterC=6 then
    LCDOut "Day"
    endif
    If CounterC<>4 then LCDOut " :"

    SetupDisplayLoop:
    If CounterC=0 then
    LCDOut $FE,$8B
    If SetTime=0 then
    LCDOut "24HR"
    else
    LCDOut "12HR"
    endif
    LCDOut $FE,$8B
    endif
    If CounterC=1 then
    CounterA=SetHour
    If SetTime=1 then
    LCDOut $FE,$8E
    ' Display AM/PM bit
    If CounterA<12 then
    LCDOut "AM"
    else
    LCDOut "PM"
    endif
    If CounterA=0 then CounterA=12
    If CounterA>12 then CounterA=CounterA-12
    endif
    LCDOut $FE,$8C,#CounterA
    If CounterA<10 then LCDOut " "
    LCDOut $FE,$8C
    endif

    If CounterC=2 then
    LCDOut $FE,$8E,#SetMin
    If SetMin<10 then LCDOut " "
    LCDOut $FE,$8E
    endif

    If CounterC=3 then
    LCDOut $FE,$8E,#SetSec
    If SetSec<10 then LCDOut " "
    LCDOut $FE,$8E
    endif

    If CounterC=4 then
    LCDOut $FE,$8D,#SetYear DIG 1,#SetYear Dig 0
    LCDOut $FE,$8D
    endif

    If CounterC=5 then
    LCDOut $FE,$8C
    CounterB=SetMonth
    Gosub DisplayMonth
    LCDOut $FE,$8C
    endif
    '
    ' Day
    ' ---
    If CounterC=6 then
    LCDOut $FE,$8A,#SetDay
    If SetDay<10 then LCDOut " "
    LCDOut $FE,$8A
    endif

    SetupEntryLoop:

    If DecButton=0 then

    If CounterC=0 then
    If SetTime=0 then
    SetTime=1
    else
    SetTime=0
    endif
    endif
    '
    ' Decrement Hours
    ' ---------------
    If CounterC=1 then
    If SetHour=0 then
    SetHour=23
    else
    SetHour=SetHour-1
    endif
    endif
    '
    ' Decrement Minutes
    ' -----------------
    If CounterC=2 then
    If SetMin=0 then
    SetMin=59
    else
    SetMin=SetMin-1
    endif
    endif
    '
    ' Decrement Seconds
    ' -----------------
    If CounterC=3 then
    If SetSec=0 then
    SetSec=59
    else
    SetSec=SetSec-1
    endif
    endif
    '
    ' Decrement Years
    ' ---------------
    If CounterC=4 then
    If SetYear=0 then
    SetYear=99
    else
    SetYear=SetYear-1
    endif
    endif
    '
    ' Decrement Month
    ' ---------------
    If CounterC=5 then
    If SetMonth=1 then
    SetMonth=12
    else
    SetMonth=SetMonth-1
    endif
    Gosub FindDays
    If SetDay>CounterA then SetDay=CounterA
    endif
    '
    ' Decrement Days
    ' --------------
    If CounterC=6 then
    Gosub FindDays
    If SetDay=1 then
    SetDay=CounterA
    else
    SetDay=SetDay-1
    endif
    endif
    Pause ButtonRepeat
    TimeOut=0
    Goto SetUpDisplayLoop
    endif

    If IncButton=0 then

    If CounterC=0 then
    If SetTime=1 then
    SetTime=0
    else
    SetTime=1
    endif
    endif
    '
    ' Increment Hours
    ' ---------------
    If CounterC=1 then
    If SetHour=23 then
    SetHour=0
    else
    SetHour=SetHour+1
    endif
    endif
    '
    ' Increment Minutes
    ' -----------------
    If CounterC=2 then
    If SetMin=59 then
    SetMin=0
    else
    SetMin=SetMin+1
    endif
    endif

    If CounterC=3 then
    If SetSec=59 then
    SetSec=0
    else
    SetSec=SetSec+1
    endif
    endif
    '
    ' Increment Years
    ' ---------------
    If CounterC=4 then
    If SetYear=99 then
    SetYear=0
    else
    SetYear=SetYear+1
    endif
    endif
    '
    ' Increment Month
    ' ---------------
    If CounterC=5 then
    If SetMonth=12 then
    SetMonth=1
    else
    SetMonth=SetMonth+1
    endif
    '
    Gosub FindDays
    If SetDay>CounterA then SetDay=CounterA
    endif
    If CounterC=6 then
    Gosub FindDays
    If SetDay=>CounterA then
    SetDay=1
    else
    SetDay=SetDay+1
    endif
    endif
    Pause ButtonRepeat
    TimeOut=0
    Goto SetupDisplayLoop
    endif
    '
    ' Set Button Pressed
    ' ------------------
    If SetButton=0 then
    CounterC=CounterC+1
    ' Increment Menu Item
    TimeOut=0
    If CounterC>6 then
    ' Save Data if all edit items exhaused
    LCDOut $FE,1,"Memorised"
    Attached Images Attached Images  

Similar Threads

  1. real time clock
    By maria in forum Code Examples
    Replies: 44
    Last Post: - 1st March 2022, 13:13
  2. Real Time Clock
    By in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd June 2012, 05:52
  3. real time clock - PCF8583
    By maria in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th April 2010, 16:41
  4. Real Time Clock
    By savnik in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th December 2006, 03:02
  5. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 22:56

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts