Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
can anyone provide any good and easy to understandable document and examples?
Nice explanation. But I need to try first.
- - - Updated - - -
If you can provide an example code it will be easy to understand. Thanks in advance.
void interrupt()
{
RB2_bit = ~RB2_bit;
//Delay_ms(10);
TMR0 = 0; //reset TIMER0 value;
INTCON = 0x20; //clear T0IF, Bit T0IF=0, T0IE=1;
}
void main()
{
TRISB = 0x00; // Set PORTB direction to be output
PORTB = 0x00; // Turn OFF LEDs on PORTB
TRISA = 0b11110000; // RA5 is input only
// Timer settings
OPTION_REG = 0b00000100; // Set timer TMR0;
TMR0 = 0;
INTCON = 0xA0; // Disable interrupt PEIE,INTE,RBIE,T0IE
while(1)
{
RB5_bit = ~RB5_bit;
Delay_ms(6000);
} //Endless loop;
} //End.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #include "msp430x54xA.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watch dog TA1CCTL0 = CCIE; // Enable timer interrupt TA1CCR0 = 50000; // Load the timer with some value TA1CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, upmode, clear TAR __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts } // Timer A0 interrupt service routine #pragma vector=TIMER1_A0_VECTOR __interrupt void TIMER1_A0_ISR(void) { // Do your interrupt processing here }
void interrupt(void){
if (TMR0IF_bit == 1){
//Do whatever
//.....
//.....
TMR0IF_bit = 0;
}
if (TMR1IF_bit == 1){
//Do whatever
//.....
//.....
TMR1IF_bit = 0;
}
}
Good job! Its really amazing. but I was full before, didn't used as I didn't tried. Thanks everyone. can you give me any example that having 2 timer interrupts? and also what is the effect of using 2 different timer interrupt? will they harm each other? or will they work in parallel?
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?