shubham kumar
Member level 3
- Joined
- Sep 11, 2014
- Messages
- 59
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Location
- bangalore
- Activity points
- 511
unsigned char txt[8],txt1[8];
int timer0_cnt=0, timer1_cnt=0,cnt=0,t,lambda;
void interrupt() // high priority interrupt TImer1
{
if(TMR1IF_bit)
{
TMR1IF_bit=0; // clear flag
timer1_cnt++; // increment cnt1
}
TMR1H=0;
TMR1L=0;
}
void interrupt_low() // Low priority interrupt TIMER0
{
if(TMR0IF_bit)
{
TMR0IF_bit=0; // clear flag
TMR1ON_bit=1; // start timer 1
lambda=1;
// just do something
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda=0;
timer0_cnt++; // increment cnt0
TMR1ON_bit=0; // Stop TIMER1
}
}
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
ADCON0=0;
ADCON1=0x0F; // no analog inputs
INTCON = 0xC0;
INTCON.GIEL=1;
INTCON.GIEH=1;
// Timer0 settings
TMR0H = 0; TMR0L = 0; // Timer0 initial value
T08BIT_bit=0; // timer in 16 bit mode
TMR0IF_bit=0; // clear flag
TMR0IE_bit=1; // enable interrupt
TMR0IP_bit=0; // set at low priority
// Timer1 settings
TMR1H=0; TMR1L=0;
TMR1IF_bit = 0; // clear TMR1IF
TMR1IE_bit = 1; // enable Timer1 interrupt
TMR1IP_bit=1; // set priority high
T1CON = 0x00; // Timer1 settings
TMR0ON_bit=1; // Timer0 started
do
{
if(timer1_cnt>10)
{
IntToStr(timer1_cnt,txt);
Lcd_Out(1,1,txt);
Lcd_Out(1,9,"Tmr1_10");
timer0_cnt=0;
// Delay_ms(500); // used just to see the output for some significant time
}
if(timer0_cnt>5)
{
IntToStr(timer0_cnt,txt1);
Lcd_Out(2,1,txt1);
Lcd_Out(2,9,"Tmr0_5");
timer1_cnt=0;
// Delay_ms(500); // used just to see the output for some significant time
}
// just do something
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda=0;
}while(1);
}
Lcd_Out(1,1,txt);
Lcd_Out(1,9,"Tmr1_10");
void interrupt()
{
if(TMR1IF_bit)
{
TMR1IF_bit=0; // clear flag
timer1_cnt++; // increment cnt1
}
TMR1H=0;
TMR1L=0;
}
void interrupt_low()
{
if(TMR0IF_bit==1)
{
TMR1ON_bit=1; // start timer 1
lambda=1;
// just do something
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda=0;
timer0_cnt++; // increment cnt0
TMR0IF_bit=0; TMR0H=0;TMR0L=0;
}
TMR1ON_bit-0;
}
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
ADCON0=0;
ADCON1=0x06; // no analog inputs
RCON =0x80;
INTCON.GIEL=1;
INTCON.GIEH=1;
// Timer1 settings
TMR1H=0; TMR1L=0;
TMR1IF_bit = 0; // clear TMR1IF
TMR1IE_bit = 1; // enable Timer1 interrupt
TMR1IP_bit=1; // set priority high
T1CON = 0x00; // Timer1 settings*/
// Timer0 settings
INTCON = 0xC0;
TMR0H = 0; TMR0L = 0; // Timer0 initial value
TMR0IF_bit=0; // clear flag
TMR0IE_bit=1; // enable interrupt
TMR0IP_bit=0; // set at low priority
T0CON= 0x84;
do
{
if(timer1_cnt>10)
{
IntToStr(timer1_cnt,txt);
Lcd_Out(1,1,txt);
Lcd_Out(1,9,"Tmr1_0");
timer1_cnt=0;
// Delay_ms(500);
}
else if(timer0_cnt>3)
{
IntToStr(timer0_cnt,txt);
Lcd_Out(2,1,txt);
Lcd_Out(2,9,"Tmr0_5");
timer0_cnt=0;
// Delay_ms(500);
}
// just do something
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda= lambda+1; lambda= lambda+1; lambda= lambda+1; lambda= lambda+1;
lambda=0;
}while(1);
}
Exactly this is the thing I was worrying about. It can miss, so I wanted to make it more and more accurate so that it should miss least number of chances.Yeah obviously it can miss running the code for some time if you put some excessive load in while, that can be avoided by slicing the big tasks and state based algorithms.
what I meant was, till (if) I become a moderator, means I would have helped a lot of persons. Which some one can do only when he had attained certain level (in terms of knowledge).You have to prove yourself useful before becoming a moderator.
that wasn't my aim.none of the moderators have ever met each other
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?