Sign in

username:

password:



Not a member?

Search Comp.Arch.Embedded



Search tips

embedded by Keywords

68HC11 | 68HC12 | 8051 | 8052 | ARM | ARM7 | Asic | AT91 | AT91RM9200 | Atmel | AVR | AVRStudio | Bootloader | CFP | CompactFlash | Cygnal | Cypress | Dataflash | DSP | eCos | EEPROM | Embedded Linux | Emulator | Endian | Ethernet | Firewire | FPGA | Freescale | GCC | GNUARM | GSM | H8 | HDLC | I2C | Infineon | Interrupts | Java | JTAG | LCD | LED | LPC2000 | MCU | Microchip | MMC | MPLAB | MSP430 | PC104 | PCB | PCI | PCMCIA | PowerPC | Rabbit | RS232 | RS485 | RTOS | SBC | SDRAM | Sensor | SPI | STK500 | UART | UML | USART | USB | Verilog | VHDL | VxWorks | Xilinx

Ads

Discussion Groups

Discussion Groups | Comp.Arch.Embedded | Software Real-Time Clock on HC12

There are 6 messages in this thread.

You are currently looking at messages 0 to 6.

Software Real-Time Clock on HC12 - Christian Winter - 08:48 02-03-06

Hi!

I am trying to implement a software real-time clock on the HC12 using
the timer module. I am pretty much unable to do it at this point and
was hoping that someone could point me in the right direction --
perhaps even coded examples that could serve as a way to better
understand it. I need to keep track of a 24 hour day, no need for any
actual dates. I can code using either assembler or C++. The clock
should run independently so other code can be inserted without effort.

Thanks for all and any help!

Christian




Re: Software Real-Time Clock on HC12 - Steve at fivetrees - 09:48 02-03-06

"Christian Winter" <c...@gmail.com> wrote in message 
news:1...@p10g2000cwp.googlegroups.com...
> Hi!
>
> I am trying to implement a software real-time clock on the HC12 using
> the timer module. I am pretty much unable to do it at this point and
> was hoping that someone could point me in the right direction --
> perhaps even coded examples that could serve as a way to better
> understand it. I need to keep track of a 24 hour day, no need for any
> actual dates. I can code using either assembler or C++. The clock
> should run independently so other code can be inserted without effort.

I suggest you setup a heartbeat interrupt - say 5ms or 1ms, depending on the 
granularity you need - and do the time maintenance therein.

Steve
http://www.fivetrees.com



Re: Software Real-Time Clock on HC12 - Eric - 12:26 02-03-06

if (RTC_tick>= XX ){
   	  	seconds++;
		RTC_tick = 0;

  	    if (seconds>=60){
   	  		minutes++;
			seconds = 0;
   	  	}
	  	if (minutes>=60){
   	  		hours++;
			minutes = 0;
   	  	}
	  	if (hours>=24){
   	  		days++;
			hours = 0;
		}
}

You have to define XX based on the heatbeat time you setup.
Eric


Re: Software Real-Time Clock on HC12 - Christian Winter - 21:09 02-03-06

With "heartbeat" do you mean using the real-time interrupts? If so, it
would be best if I could set it up such that it is called every second
to increment the clock.

I also found someone suggesting to use the pulse-width modulator, but I
am unsure as to how to do that.

Getting out the HC12 data sheet again...


Re: Software Real-Time Clock on HC12 - Steve at fivetrees - 07:37 03-03-06

"Christian Winter" <c...@gmail.com> wrote in message 
news:1...@e56g2000cwe.googlegroups.com...

> With "heartbeat" do you mean using the real-time interrupts?

I mean use one of the timers to generate a regular interrupt.

> If so, it
> would be best if I could set it up such that it is called every second
> to increment the clock.

If your only realtime requirement is updating the clock, then sure. But one 
often needs to have finer time control than 1s.

> I also found someone suggesting to use the pulse-width modulator, but I
> am unsure as to how to do that.

Errrr.... PWM is not directly appropriate. However the timer may well be a 
potential interrupt source.

> Getting out the HC12 data sheet again...

Good plan ;).

Steve
http://www.fivetrees.com



Re: Software Real-Time Clock on HC12 - Everett M. Greene - 11:48 03-03-06

"Steve at fivetrees" <s...@NOSPAMTAfivetrees.com> writes:
> "Christian Winter" <c...@gmail.com> wrote
> 
> > With "heartbeat" do you mean using the real-time interrupts?
> 
> I mean use one of the timers to generate a regular interrupt.
> 
> > If so, it
> > would be best if I could set it up such that it is called every second
> > to increment the clock.
> 
> If your only realtime requirement is updating the clock, then sure. But one 
> often needs to have finer time control than 1s.
> 
> > I also found someone suggesting to use the pulse-width modulator, but I
> > am unsure as to how to do that.
> 
> Errrr.... PWM is not directly appropriate. However the timer may well be a 
> potential interrupt source.
> 
> > Getting out the HC12 data sheet again...
> 
> Good plan ;).

Looking at the data manual finds the Clock Generation Module,
Realtime Interrupt.  Interrupts occur at one of eight
program-selectable rates in binary fractions of oscillator
frequency.  Use a power-of-two oscillator and you can get
exact time-of-day;  otherwise, throw in a fudge factor
from time to time.