GP2X Possibility For A Realtime Clock?


BenScar

What does this do again?
Joined
Jan 4, 2006
Messages
435
Age
47
Location
UK, Near London, somewhere...
Website
Visit site
Hello all,

I've touched on a good few things in my travels and wondered if I could bring together a few of them to make a real time clock add on.

Thinking something along the lines of a Linux driver (learning C++ at the moment, so that's only a year or so off :) ) that when "asked" for the time asked, it would send a message over the serial port (OK, not the fastest but I'm just thinking out loud here). The hardware would consist of a little PICT (or similiar programmable chip) that sits and waits for a command to come down the serial port. If it sees "TIME:CURRENT" (or something uniquie) it just dumps its date/time store back to the serial for the driver to pick up and relay to the requesting app.

The rest of the hardware would consist of a low current timer (ticking at, oh I don't know, 100th of a second) feeding into the PICT chip where is would count up the seconds/minutes/hours.

It would of course need to set first, IE given a date/time over the serial, so that would also have to be part of the driver. Something like "TIME:SET:ddd mmm yyyy HH:MM:SS". The PICT chip would then translate this into how ever it was stored (probably in a set of registers, guessing now).

The part of the PICT that's doing the counting would need the rules for counting up but the rules themselves aren't to hard and it would always be GMT. Adjustments for Daylight Saving/British Summer Time would have to be thought about some where else or perhaps there are nice simple rules for that as well.

Now, here's the part I'm posting for... Is there anyone out there with PICT or similiar experience who can tell me I'm talking tosh or perhaps, just perhaps, I might have listened in a lecture or two and picked something up?

Is this something people would want?! For things like using the 2x as a PDA (which I wouldn't but I like to make things!) or even an alarm clock..

Another question, showing my lack of Linux experience here, is there a "/dev/input/mice" type thing for the system clock? Something like "/dev/input/clock" which when read gives you the date/time ?

I thank you for your attention!
Ben
 
You wouldn't need to make a driver - just a userspace program that accesses the serial port and sets the time with the "date" command. It could be run from the startup script, etc.

http://unixhelp.ed.ac.uk/CGI/man-cgi?date

At most you would need a kernel recompile to add clock support (not sure if this can even be disabled?), but linux can definitely track the current time while it's running - there's no need to constantly query the clock module whenever an app needs the time, and there appears to be a "date" utility in the firmware (probably part of busybox).
 
BradN posted on Apr 13 2006 at 10:41 PM said:
You wouldn't need to make a driver - just a userspace program that accesses the serial port and sets the time with the "date" command. It could be run from the startup script, etc.
That makes sense, I don't know all that much about Linux as yet, so I'm probably making things overly complicated but that sounds like it might be more along the right lines than a special driver.

BradN posted on Apr 13 2006 at 10:41 PM said:
At most you would need a kernel recompile to add clock support (not sure if this can even be disabled?), but linux can definitely track the current time while it's running - there's no need to constantly query the clock module whenever an app needs the time, and there appears to be a "date" utility in the firmware (probably part of busybox).
Cool, so it would just be a case of getting the date/time from the external hardware and feeding it to the system on start up...
So my idea stands (sorta), just have to see if the the hardware side of things would run the way I think they can...

Thanks for you input, more cogs turning in my noggin now :)
 
Last edited by a moderator:
With regards to the PIC, don't forget they have a built in timer, so if you intend running the PIC all the time, you could run this internal timer at say 1ms and easily function as a clock with the only other electronics being a voltage regulator (if it has it's own battery - may not be required depending on battery voltage), and a crystal. You could probably get away with a RC circuit, but for a clock a crystal would be more accurate over time.

If you don't want the PIC running all the time, then you could use an external realtime clock chip that'll run off a watch battery for years, and maybe power the PIC from the 2X as it'll only be needed when the 2X is on.
 
Squidge posted on Apr 14 2006 at 12:03 AM said:
With regards to the PIC, don't forget they have a built in timer
Now that I didn't know, so it would be possible to have it all housed in one chip (with a few external parts). That would make things less difficult, at least less complicated component wise.

Squidge posted on Apr 14 2006 at 12:03 AM said:
If you don't want the PIC running all the time, then you could use an external realtime clock chip that'll run off a watch battery for years, and maybe power the PIC from the 2X as it'll only be needed when the 2X is on.
That what I had in mind, so when you turned the 2x on it was able to get the date straight away, rather than having to set it each time.
Saying that I've not looked into the power side of the EXT port, is that powered all the time, even when the 2x itself is off?

<time passes as I think about that!>

Thinking about it I wouldn't really want to run it off the 2x, not that much of a drain but why do that when a simple watch battery would last long enough (with a seperate realtime clock)

So, to add to the C++, Linux and SDL pile, I'll throw in PIC programming :) That'll keep me busy for a while!

Thanks Squidge, lots to think about there.
 
Last edited by a moderator:
Don't forget the GP2X has an I2C (TWI) eeprom inside hence it is running an I2C bus and I presume has kernel support for it too.

Theoretically you could open it up, piggyback a Dallas DS1307, watch crystal and a coin battery backup onto the pins that connect to the eeprom and then just write code that looks for the DS1307's address on the I2C bus instead of the eeprom etc. You can even ask Maxim for a free sample in DIP form factor to play with.

They are accurate for years, last 10 years on one coin battery, and know the leap years until 2100AD. Also include 56bytes of ram you can store stuff in.

http://pdfserv.maxim-ic.com/en/ds/DS1307.pdf

Note, I saw in a recent Maxim/Dallas publication they have RTCs without the need for external watch crystal, might be worth looking at too.
 
This idea has been bugging me for a while, but I want to know if its at all valid. I realise that for the GP2X this isnt at all what we want but still, worth voicing right?

If I remember correctly batteries loose their charge over time regardless if they are on or off, slowly when they are off. So couldnt one poll the battery when the unit is turned off and get the voltage to a certain amount of figures, and then when the unit is turned back on, get the voltage right away(before too much power is drawn) and calculate the time change based on that?

Or laugh at me :p.
 
Nice idea! However, the way the 2x checks the battery status, it wouldn't work, as the accuracy just isn't there.
 
If you get a microcontroller or clock module that's capable of running from 2-3V, you could make it internal and just connect it up to the battery pins, maybe with a capacitor to let you swap batteries without losing the time. Hooking into the I2C bus sounds like a good interface idea, and if linux is set up with an actual driver for I2C access, it would be trivial to add a module to support the clock if linux has one, and then it wouldn't require much real programming at all.

I see the following I2C real time clocks supported in the 2.6.16 kernel (but the gp2x version may have less or none, you'd have to check):

Dallas Semiconductor DS1337 and DS1339 Real Time Clock
Maxim/Dallas Semiconductor DS1374 Real Time Clock
Epson 8564 RTC chip
Xicor X1205 RTC chip
 
BradN posted on Apr 25 2006 at 07:35 PM said:
If you get a microcontroller or clock module that's capable of running from 2-3V,

I have such microcontroller what will work directly from 2xAA NiMH (PIC 16F627A) however imho it's not good idea to use it for clock. Its bulitin oscillator isn't too precise (calibrated withing 1%). Adding external quartz is perhaps good idea but then why no stick to the dedicated clock/calendar chip like the PCF8593 from Philips for an example? It eats only 1µA of power and will work at 2V. Then add some small battery to make it work all the time no matter if 2xAA are inserted or not.

Then how it should connect to the Ext port pins?
(are there some traces/vias what would make it doable?)

Then what with compatibility with Ext breakup boxes?

Adding support software wise shouldn't be too hard. Personally as I find it interesting I'm not too excited about adding realtime clock for GP2x.

Perhaps for additional functionality for some kind of ubermod but just for it... overkill. :unsure:
 
Last edited by a moderator:
Radek, I was thinking of making it a pass-though EXT connector, just adding the info to the RS232 lines (when asked).
So all the rest of the EXT things can be used.
Would be (I think) compatible with any BOB you wanted to connect up to it.

It's still a bit of a pipe dream at the moment, as you say "ubermod" just for the hell of it :)
 
Why not connect it to i2c pins that the e2 uses? Saves messing around with the ext port and can be all internal then
 
yeah, a DS3231 costs like 2$.
But it would be cheaper to just hook up the mmsp2's rtc, maybe we could get gph to do that in the next pcb revision?
 
The 2X has a e2 (e-squared, or otherwise known as eeprom) chip for non-volatile storage of data. The bus used to talk to this chip is i2c (eye-squared-see, or Inter-Integrated Circuit).

You can get a clock chip that also talks on the I2C bus, and thus you could wire it to the same pins that the e2 uses for I2C, as the I2C bus support multiple slaves (IC's) on the same bus.
 
Ah, that makes a lot more sense now :)
I see, so if I were able to design and make it small enough to fit inside it could be made as a mod without having to worry the Ext connector at all.

Like the sound of that, thanks for the explanation Squidge.
 
BenScar posted on Apr 26 2006 at 05:33 PM said:
Ah, that makes a lot more sense now :)
I see, so if I were able to design and make it small enough to fit inside it could be made as a mod without having to worry the Ext connector at all.

Like the sound of that, thanks for the explanation Squidge.

I2C bus had that advantage it's just need only two bidirectional lines to communicate. So unfortunate that I have only one left in my mod using the 16F627A. But not everything at once....
 
Last edited by a moderator:
slaanesh posted on May 28 2009 at 03:04 AM said:
Old thread, I know.
However I was wondering if anyone has successfully added an RTC to their GP2x?
This isnt a RTC method, but whenever I hook my GP2x up to the USB network (I do this alot), I have an auto script that whenever the TCP/USB comes up it runs an "rcmd gp2x netdate mrlinux". Which required me to port over netdate and the "r" commands (rcp, rsh, rlogin), and I use these commands alot to log into my GP2x and transfer software, etc. So all I have to do is have my GP2x on, plug it in and a sec or 2 later the time is set.

rcmd runs on my Linux PC when the USB detects the network interface coming up, runs rcmd to "gp2x" (in my local /etc/hosts file) to tell gp2x to run netdate and sync off my local machine "mrlinux" (in my gp2x's /etc/hosts file).

An RTC would be better though.

I heard in the F200 some idiot designed out the USB network chip which is why I never "upgraded" from my F100. Anyone know if that idiot was fired before the Wiz was designed?
 
Last edited by a moderator:
I heard in the F200 some idiot designed out the USB network chip which is why I never "upgraded" from my F100. Anyone know if that idiot was fired before the Wiz was designed?
Yeah, I'm totally gutted that the network chip was not included within the F200. :angry:
 
Last edited by a moderator:
Back
Top