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.

Which RTC to use?

Status
Not open for further replies.

mikesmixes777

New Member
I am building a data logger using a PIC18LF252 that shall interface with an ethernet controller (EN28J60). Guess I overlooked the Date/Time stamp of the logged data and now need to add a RTC to my circuit.

I am using 3xA/D inputs, 1x D output, the 3-wire SPI for the ENC28J60,
RX-TX for RS232 and ICSP pins for ICD2 programmer.
Crystals: PIC18LF252@20MHz and ENC28J60@25MHz

Any ideas for the RTC chip?

Thanks
Mike
 
Thanks....
The PIC being used only has one i2c / SPI interface and i'm using that for the ethernet controller. Is there another way to add a RTC to my existing circuit?
Do they all use i2c?
 
Have you considered putting a watch crystal on timer1/3 oscillator pins and implementing a 1 second interrupt.

Mike.
 
P.S. if you can't afford another interrupt source then you can poll it as it will only change once per second.

Mike.
 
That seems an interesting and probably the best way of doing it. I could generate some code to keep track of the date and time and save it into memory.

As far as interupts are concerned I have not got that far yet so I'm not sure what interupts are going to be used. I know the Ethernet side of the circuit will use an interupt at the least.

Could I not possible collect the date and time from the network? This will only be wise if the circuit is continuosly on the network and if the PC's date/time is correct.
 
If you have spare port pins, you could write a low level I2C routine for the RTC.:)
 
ericgibbs said:
If you have spare port pins, you could write a low level I2C routine for the RTC.:)

Thinking about it, that is probably the best option. My suggestion of using timer1/3 has the disadvantage that it needs resetting whenever power is cut. Futurelec do a nice little RTC module that may get you up and running and only $7.

Mike.
 
hi,
As quick fix guide, I have compiled a Basic Low Level, I2C routine in Oshonsoft, the attached [18F252] asm file is well commented.

EDIT:
Do you need the Header details for this asm file.?
 
Last edited:
Im sort of a beginner to all this pic programming... would adding a crystal to timer1/3 be able to serve the purpose of a RTC without compramising any other issues, bare in mind i am connecting to a ENC28J60 and implemeting the TCP/IP stack on the pic to handle the network interface....(i guess this is going to use alot of resources?)

edit: sorry didnt see the reply posts.....just busy thinking thru erics routine...
 
Last edited:
Please could you give the header files for asm.

I see that PORTC 3 and 4 are *currently used for the SPI as a default. Can i just change it to two free ports say PORTB?
Does the code need any adjusting for inserting it into C18?

Thansk for your help....I appreciate it.
 
Last edited:
hi,
I dont do 'C'... :eek:

Hi Mike,
I should have said " the modules are commented"...:rolleyes:

Shouldn't you be in bed...:D

I cant help the OP with a 'C' conversion, I am wrinkly using asm!!!
 
mikesmixes777 said:
The PIC being used only has one i2c / SPI interface and i'm using that for the ethernet controller.

What's wrong about connecting both the controller and the RTC to the SPI 'bus'?
 
ericgibbs said:
Hi Mike,
Shouldn't you be in bed...:D
Yes.
I cant help the OP with a 'C' conversion, I am wrinkly using asm!!!

Can you beat 49? I spent most of my working life writing asm. Only recently looked at C.

Mike.
 
Pommie said:
Yes.


Can you beat 49? I spent most of my working life writing asm. Only recently looked at C.

Mike.

Hi Mike,
Yes I can beat 49 with a good lead, I am 75 years old, well past my sell by date.:rolleyes:

PS: spent most of my early years writing in machine code.!!!

PPS: going even further back I used enter each bit of the byte with its own switch and then press the accept key.
Entering the program Byte by byte.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top