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
CCP, Capture/Compare/PWM module of PIC microcontrollers. I need the basic thing about compare module. How can I get a stable frequency using this module?
I'm trying... but need help. Better if you can give me an example code in microC.
Thanks
- - - Updated - - -
I was trying with this:
Output is:
Can you tell me what the wrong I'm doing here?
I'm trying... but need help. Better if you can give me an example code in microC.
Thanks
- - - Updated - - -
I was trying with this:
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 43 44 45 46 47 48 49 50 51 52 53 #define Clock1 RC5_bit void interrupt() { if(CCP1IF_bit) { CCP1IF_bit = 0;// clear flag Clock1 = 0; } if(TMR2IF_bit) { Clock1 = 1; TMR2IF_bit = 0;//clear flag } } // ISR... void PORT_Init(void) { TRISA = 0xFF; // PORTA input TRISB = 0b00000001; // PORTB output except RB0 & RB1 PORTB = 0x00; // all zero TRISC = 0b00001000; // PORTC output PORTC = 0x00; // all zero } void main() { PORT_Init(void); // Timer2 settings for 7ms interrupt T2CON = 0x36; PR2 = 223; // 10 ms time TMR2IE_bit = 1; INTCON = 0xC0; // compare module settings... CCP1CON = 0b00001011;// trigger special event CCP1IE_bit = 1; CCPR1L = 0x1B; CCPR1H = 0xCF; //timer 1 settings... T1CON = 0x01; TMR1IF_bit = 0; TMR1H = 0xCF;//10ms timer TMR1L = 0x2B; while(1) { } // while }// void main
Output is:
Can you tell me what the wrong I'm doing here?