How to program an external crystal osicalator for atmega 1281, simulate on proteus

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Creating a stopwatch and want to measure the time more accurately, no matter what frequency is used(8MHz. 4MHz,2MHz,1MHz) there are always errors with the real-time, already connected the 8MHz crystal, 2, 20pF cap to XTAL1, and XTAL2, but have no idea about how to configured the fuses thing for 8MHz.

..

PS: can't use 8MHz, it says excessive cps load error on Proteus

 

Imanka Priyasad Amarakoon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you would more likely get an answer here:

 

https://support.labcenter.com/fo...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As mentioned, if you want to know what a "cps load" is, you have to ask Proteus support.  [I'd wager an 8MHz setup is achievable.]

 

But to answer your primary question(s) you need to give more information.  What accuracy and resolution are you trying to achieve?  How are you "tripping" the start/stop?   What are these "errors", and how large are they?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks

Imanka Priyasad Amarakoon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to use the 8MHz clock with more accuracy, can make it more accurate by changing the OCR1A value but instead, I want to use an external clock source with the real value

 

currently, I'm using 8MHZ, 8-bit prescaler ,  and OCR1A=1000, 

Imanka Priyasad Amarakoon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You did not answer any of the questions:

theusch wrote:
you need to give more information. What accuracy and resolution are you trying to achieve? How are you "tripping" the start/stop? What are these "errors", and how large are they?

 

I don't see how OCR1A might be involved in a timing app.  ICR1 (input capture) can get you down to a single AVR clock resolution, properly done.  Trapping TCNT1 on an edge event will get you to a few dozen AVR clock cycles.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to count passing of 1 millisecond and to fire an interrupt at passing of every millisecond,

 

used F_CPU 4 MHz. clock_Pre_scaler(2),     its 37 second delay for 1 min

Imanka Priyasad Amarakoon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IMA wrote:
I want to count passing of 1 millisecond and to fire an interrupt at passing of every millisecond,

I don't understand.  What does that have to do with a stopwatch function?

 

I realize that there is a language barrier, but you must describe your situation and needs in much more detail.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Thank you very much for replying.

 

Basically i want to configure a timer and enable  to fire an interrupt( timer1_Compare_Vector) at every millisecond so i can use it to calculate passing of seconds, minutes and hours,

 

have managed to do that but the accuracy is really low, with my stopwatch and a real one there is 10-20 seconds delay, one i created is running slower than a real one,

 

the higher the frequencies i use the error rate of the stopwatch is also high, with F_CPU 1 MHz i manged to get the most accurate one that also have 10 seconds delay

 

Thanks again

Imanka Priyasad Amarakoon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is running in the simulator and not on real hardware correct?

If so, you need to seek help with the simulator from labcenter!

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes it is simulated,

so there is a time difference between real one and simulated one? this is my 1st project so have no idea about these things

Thanks for replying

Imanka Priyasad Amarakoon