Home | Store | Showcase | Forums | Examples | Guides | Reviews | Support | Download | About Us

 

 

 

Using the Real-time Counter with the M32
The ATMega32 chip in the M32 has a real-time counter that operates asynchronously when a 32khz watch crystal is connected to it, providing a real-time clock.  Bascom has built-in support for the RTC, making it very easy to use time functions.  You can purchase the parts needed as a kit by clicking here.

First let's install the watch crystal.  The watch crystal needs to connect to pins TOSC1(28) and TOSC2(29).  To do this, we need to solder the watch crystal to a couple of female crimp connectors. Use something to hold the crimp connectors while you are soldering, small parts can be difficult to solder. Be sure to crimp the pins before soldering so they will fit into a plastic housing.

You could also solder the crystal directly to the male posts, but I would recommend using the crimp connectors.

 

Next, slide the female crimp connectors into a 2-pin plastic housing. Now you can install and remove the watch crystal as needed.

 

 

 

 

Slide the connector onto pins 28 & 29 as shown in the picture. 

 

 

 

 

Now fold the crystal down against the plastic housing as shown. This will keep the crystal safe. You could use a drop of hot glue to secure the crystal in place and protect it. Click the picture to see a close up.

 

 

 

Sample Code

'Real-Time Clock Example
'Wright Hobbies, LLC
'eddy@wrighthobbies.com

Enable Interrupts
Config Clock = Soft 'This command inits the clock


Input "Enter the time(hh:mm:ss):" , Time$

Do
  
Print Time$
  
Wait 1
Loop

You should see this in the terminal window:

Read through the Bascom Help for more information on the available clock functions.

Enjoy!