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.

pause and resume a key using microcontrollers

Status
Not open for further replies.

2222

Newbie level 4
Joined
May 8, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
Actually we r working on a micro-controller(timer/clock function), where we have a problem ,
the working is similar to tat of a audio video player ,
so now how do we start and stop the timer and resume at the time were the user has stopped.
kindly give me an idea to go ahead with this.

MOD: USING SMS LANGUAGE IS NOT ALLOWED HERE..
READ RULES BEFORE POSTING.
NEXT TIME YOU WILL GET A WARNING..

NANDHU015
 

Start a timer. Hold the seconds in a variable. Save it to eeprom if needed. When stop sec variable will hold some value like say 20 (20 sec). If stop button pressed, disable timer and when start button is pressed time starts counting from 20 sec.
 

sir could you please explain this in detail with a example of a c code for this,as i could not catch your point and am fresher to this field.
 

Post you circuit and mention how do you start and stop timer?
we are not using any reset in the hardware part .only we have to alter in the code.For example - the user set the timer for some 8 hours and later stops at 2 hours 15 minutes ,now to resume ,the user should start again from 2 hours 15 minutes only .am posting some part of the code where changes can be made..
Code:
#include	<stdio.h>	  
#include	<string.h>

idata int hours_selected = 8; 		
idata int minutes_selected = 0;

idata int temp_hours_selected = 8;	
idata int temp_minutes_selected = 0;

idata unsigned char idata therapy_is_over;
unsigned int timer1_overflow_count = 0;
unsigned int timer0_overflow_count = 0;
idata unsigned char spill_over_count_loaded;
idata unsigned char spill_over_count1_loaded;

void timer1_ISR(void) interrupt 3
{
if(therapy_is_over == 0)
{
if(spill_over_count1_loaded == 1)
		{
			spill_over_count1_loaded = 0;
			timer1_overflow_count = 0;
//			minutes_remaining--;
			if((minutes_remaining == 0) && (hours_remaining == 0))
			{

	//				hours_remaining = hours_selected;
	//				minutes_remaining = minutes_selected;
					hours_remaining = 0;
					minutes_remaining = 0;
			}
			else
			{
				minutes_remaining--;
				if(minutes_remaining == -1)
				{
					minutes_remaining = 59;
					--hours_remaining;
				}
			}
			show_time_flag = 1;
		}
		else
		{
			if((timer1_overflow_count % 10) == 0)
				show_seconds_flag = 1;
			timer1_overflow_count++;
			if(timer1_overflow_count == 1220)
			{
				spill_over_count1_loaded = 1;
				TL1 = 0;
				TH1 = 0x4c;
			}
		}
	}
}
 

hours and minutes has to be saved to eeprom and read back after a power reset. In timer interrupt time is checked if it is equal to set time (x sec) . What Compiler are you using?
 
  • Like
Reactions: 2222

    2222

    Points: 2
    Helpful Answer Positive Rating
hours and minutes has to be saved to eeprom and read back after a power reset. In timer interrupt time is checked if it is equal to set time (x sec) . What Compiler are you using?

keil u mission 4 IDE(compiler)..
 

mikroC Code for PIC using Timer0. Can you use mikroC PRO 8051?
 

Attachments

  • timerss.rar
    78.7 KB · Views: 95
  • tmr0sim.rar
    152.5 KB · Views: 103
  • Like
Reactions: 2222

    2222

    Points: 2
    Helpful Answer Positive Rating
mikroC Code for PIC using Timer0. Can you use mikroC PRO 8051?
But mikroC code supports ATMEL & SILICON LABS 8051 MICROCONTROLLER FAMILY, but not NXP family..
Can we use above attachement for our P89V51RD2 chip..
 

The above file is for PIC microcontroller. The timers in in 8051 is different and also EEPROM library. You have to look at my code and write similar code for your Controller using Keil + C51 Compiler. If you can post code for eeprom read and write for your uC then I can help.
 
  • Like
Reactions: 2222

    2222

    Points: 2
    Helpful Answer Positive Rating
The above file is for PIC microcontroller.
Yes Sir.. your guidence really helping me..and the thing is we are not using EEPROM instead using EPROM ,can we use EPROM instead of EEPROM??..Also i have attached the data sheet of P89v51rd2 chip...
 

Attachments

  • p89v51rd2.pdf
    369.6 KB · Views: 85

I don't need datasheet. What I need is eeprom or eprom code that you use in your code. Are you using internal eeprom or external eprom?
sir actually we need eprom code..our chip does not support eeprom code ...and we have not yet used eprom code in our program..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top