Microcontroller › 8051 › Understanding timers/interrupts
- This topic has 1 reply, 2 voices, and was last updated 10 years, 9 months ago by
AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
May 23, 2014 at 2:56 pm #3096
John Jameson
ParticipantHey guys,I’m looking over some code here for a pulse sensor and are just looking for some clarification on some points,from I can see the interrupt of the mirco is being used to detect the pulse when a finger is placed on a sensor,I’m just gonna post the interrupts rather than post the whole code.Variables used are all intsvoid extrint (void) interrupt 0 // external Interrupt to detect the pulse{bt=tick; // number of ticks are pickedtick=0; // reset for next counting}[/CODE]so is bt or tick equal to the number of pulses the sensor reads when a finger is placed over it?And resets back when the finger is removed?[CODE]void timer0 (void) interrupt 1 using 1 // Timer 0 for one second time{TH0 = 0xdc; //The value is taken for Ssc/100 at crystal 11.0592MHzsec100++; // It is incremented every Ssc/100 at crystal 11.0592MHztick++; // This variable counts the time period of incoming pulse in Sec/100if(tick>=3500){tick=0;} // tick are limited to less than 255 for valid calculationif(sec100 >=100) // 1 sec = sec100 * 100{sec++;sec100=0;}}[/CODE]Not sure on this one,is this a timing reference for the pulses? or something to work out a 1 second timer as it says in comment,I’m a bit lost here[CODE]void extrint (void) interrupt 0 // external Interrupt to detect the pulse
{bt=tick; // number of ticks are pickedtick=0; // reset for next counting}[/CODE]so is bt or tick equal to the number of pulses the sensor reads when a finger is placed over it?And resets back when the finger is removed?void timer0 (void) interrupt 1 using 1 // Timer 0 for one second time{TH0 = 0xdc; //The value is taken for Ssc/100 at crystal 11.0592MHzsec100++; // It is incremented every Ssc/100 at crystal 11.0592MHztick++; // This variable counts the time period of incoming pulse in Sec/100if(tick>=3500){tick=0;} // tick are limited to less than 255 for valid calculationif(sec100 >=100) // 1 sec = sec100 * 100{sec++;sec100=0;}}[/CODE]Not sure on this one,is this a timing reference for the pulses? or something to work out a 1 second timer as it says in comment,I’m a bit lost here[CODE]void timer0 (void) interrupt 1 using 1 // Timer 0 for one second time
{TH0 = 0xdc; //The value is taken for Ssc/100 at crystal 11.0592MHzsec100++; // It is incremented every Ssc/100 at crystal 11.0592MHztick++; // This variable counts the time period of incoming pulse in Sec/100if(tick>=3500){tick=0;} // tick are limited to less than 255 for valid calculationif(sec100 >=100) // 1 sec = sec100 * 100{sec++;sec100=0;}}[/CODE]Not sure on this one,is this a timing reference for the pulses? or something to work out a 1 second timer as it says in comment,I’m a bit lost hereMay 27, 2014 at 6:59 am #11775AJISH ALFRED
ParticipantHi John,
Suggest you to post the entire code, so that things will become more clear for others to post their comments on your query.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.