Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need CCP module basic in microC

Status
Not open for further replies.

Mithun_K_Das

Advanced Member level 3
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
Visit site
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:


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: sdfsfadf.png
Can you tell me what the wrong I'm doing here?
 

I need to generate 50Hz PWM push-pull signal for inverter. And also need to control a TRIAC to control the charging section.... So 3 pulses need to be generated.

Simple PWM will not work.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top