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
Hi,
I am using PIC18F452. I am trying to generate to square waves of different frequencies depending on switch level. I am using timer but the not the timer flag (TMR1IF_bit) as interrupt.
Is this possible to generate a pulse without using interrupt.
I am trying to implement the above way but not getting through. Tell me if there is any error in that
OR Tell me if any other method exists.
I am using PIC18F452. I am trying to generate to square waves of different frequencies depending on switch level. I am using timer but the not the timer flag (TMR1IF_bit) as interrupt.
Is this possible to generate a pulse without using interrupt.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 void wave_0() { TMR1L=0x0F; TMR1H=0x0F ; TMR1IF_bit=0; T1CON= 0x01; while(TMR1IF_bit==0); TMR1IF_bit=0; } void wave_1() { TMR1L=0; TMR1H=0 ; TMR1IF_bit=0; T1CON= 0x01; whileTMR1IF_bit==0); TMR1IF_bit=0; } void main() { AN0_bit=0; AN1_bit=0; AN2_bit=0; AN3_bit=0; // Configure AN pins as Digital I/O and turn off comparators TRISD.B7=1; TRISD.B6=0; do{ PORTD.B6 = ~ PORTD.B6; if( TRISD.B7==1) { wave_0(); } // Delay_ms(500); if( TRISD.B7==0) { wave_1(); } // Delay_ms(500); } while(1); }
I am trying to implement the above way but not getting through. Tell me if there is any error in that
OR Tell me if any other method exists.
Last edited by a moderator: