Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Timer1 oscillator mode

Status
Not open for further replies.
Hi,

I would not do it that way, too much like hard work.

In your ISR every time your timer1 interupts you update your seconds counter, e.g. secondsUnit and secondsTens, and if needed you carry over to your minutes and hours and days etc.
You have plenty of time in your ISR to do that.

Then in your main led routine its just a case of loading the appropriate register and convtering it to 7 seg format, much quicker that testing as you are doing now.
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi,

I would not do it that way, too much like hard work.

In your ISR every time your timer1 interupts you update your seconds counter, e.g. secondsUnit and secondsTens, and if needed you carry over to your minutes and hours and days etc.
You have plenty of time in your ISR to do that.

Then in your main led routine its just a case of loading the appropriate register and convtering it to 7 seg format, much quicker that testing as you are doing now.


Hi

Thanks for the reply

can I have simple code example please

Thanks in advance
 

Hi,

Perhaps I was too hasty, I was thinking of doing it the way I have in the past, but as you have already started updating the seconds it would probably be easier for you to keep using that method.

You have updated Seg1 and Seg2 perfectly so what is the difficulty of updating Seg3 onwards, you just use the same method for seg3 and 4 as you did for the seconds, so when seg2 overflows and is cleared, you increment seg3 etc and for the hours you just change the value to 12 or 24 for seg 6.

Job done - yes ?
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi

Dear wp100
Thanks for the reply and advice

Actually I can manege up to second and minutes

in the hours, seg5 increment up to 9 in first round and in the second round only up to 2 in the 12 hours mode

Should you please help on this regard?
Thanks
 

Hi,

For seg 1/2 and 3/4 you do simple 1 digit compares first for 0 the for 6.

For seg 5/6 you need to do a double compare , something like

seg 5 = 3 ( just updated to 3) yes , then does seg6 = 1, yes , reset hours to 01

same with 24hrs
seg5 = 4, yes, seg 6 = 2, yes , reset hours to 00
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top