No photos tonight, I’m afraid.  The camera battery is flat, and anyway, in this light, they probably wouldn’t have come out.

So you’re going to have to take my word for this…

After long, long hours of head scratching, and moments of seeming madness, I’ve finally cracked this i2c lark.

Saturday’s missive was all about how I’d managed to write data down the i2c bus.

As it turns out, this was the easy part.  Apparently, even my cat could have done it, if he’d been bothered.

Getting i2c to receive coherently and on time is apparently quite a big beef amongst the electronics fraternity, and Microchip -the makers of the PIC’s I’m using, haven’t done themselves many favours. Briefly, the way they’ve implemented it is, well, decidedly pratty.

A very long and boring story shorter, but just suffice to say I’ve now got the little board you saw on Saturday not only flashing the LED’s if I want to, but I’ve whacked on an RTCC (Real Time Clock Counter) onto the i2c bus too.

The input/output chip and the clock are quite happily sat on the same two lines (SCL and SDA if you’re that bothered), because they have different i2c addresses.  Before you talk to a chip, you have to give it the right address, which kind of makes sense.

SO, I’ve now got that same board, and you’ll remember it has those four displays left over on it.  Well, these are now coded up so the display simply reads minutes and seconds from the RTCC.  I haven’t set the clock properly, so the numbers are pretty meaningless, but the fact is that even if I completely unplug the board to switch it off, this little clock keeps on ticking -in much the same way as your PC clocks does when you power it down at night.

So, when I come to switch it on again, not only has the clock advanced, but it’s advanced properly to show the correct minutes and seconds that it was when it was on previously.

I guess I’m not explaining this very well, I guess I’m a little tired, but I’ll get some proper photos tomorrow to explain.

Hells, I may even set the clock properly so it shows the correct time!

The next job will be to work with that little input/output chip to get it to input, rather than simply lighting LED’s.

This shouldn’t be quite as difficult as today’s marathon effort, but I have the added ‘fun factor’ of having to set it up so that a button press will interrupt the processor.  This will then send out a command to find out just which button was pressed.

Why?

Well, this vastly saves on processor time.  Rather than the processor having to ‘poll’ the inputs every few milliseconds, and all the bother that entails, this way, it’ll only do something when it’s interrupted.

There’s even a possibility of being able to ‘wake’ the processor from ‘sleep mode’ with a button press.  This then does away with a whopping great on/off switch -it’ll just be a button press to turn on.  …Maybe, we’ll see…

I guess it all sounds dead simple, but take it from me -it’s not!

This is One Tired Wardo, signing off!

Print Friendly