Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more flexibility in rtc library for other frequencies #100

Open
GoogleCodeExporter opened this issue Mar 3, 2016 · 2 comments
Open

more flexibility in rtc library for other frequencies #100

GoogleCodeExporter opened this issue Mar 3, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

The rtc_isr_tmr0 library contains some hard coded constants (hi,mid,lo) for
a specific oscillator frequency (20MHz).
This means that the user would have to change the library when using a
different oscillator frequency.
Request: the library should adapt itself automatically to the oscillator
speed. 

Original issue reported on code.google.com by robhamerling on 24 Oct 2009 at 8:06

@GoogleCodeExporter
Copy link
Author

A quick fix could be to replace the hard coded values of hi,mid and lo by:

const  byte  hi  = (target_clock / 4) / 65536
const  byte  mid = (target_clock / 4) % 65536 / 256
const  byte  lo  = (target_clock / 4) % 256

This makes the library independent of the oscillator frequency.
However the working of the Interrupt service routine depends also on the proper
setting of OPTION_REG, in particular the PS and PSA bits. This is currently not
handled by this library and not mentioned in the comments/docs too.


Original comment by robhamerling on 24 Oct 2009 at 12:33

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

This code-change has proven to be working correctly, but some more improvents 
may be
desired, like:

1. Support for oscillator frequencies higher than 64 MHz, either by using a 
larger
counter (4 bytes in stead of 3) or by using a prescaler value for the timer (to 
bu
user specified.  

2. Convert the code to native JAL. The site of Roman Black shows some examples 
in
C-language which can be converted to Jal easily. A first attempt shows a slight
increase of code space. The amount depends on the size of the counter field.   


Original comment by robhamerling on 25 Oct 2009 at 10:44

  • Added labels: Component-Jal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant