Prince Vegeta
Member level 5
- Joined
- May 29, 2012
- Messages
- 84
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 2,011
Hi guys ^_^
I have a problem in PIC18F6520 CCP4 compare module.
I work in a project that includes controlling a DC-to-AC inverter using PIC18, all I need is a 50Hz signal with 50% duty cycle.
so 50Hz = 20ms, 1st 10ms will be + and last 10ms will be - in order to control the inverter circuit.
I saw Tahmid's code, modified it so it can suit the PIC18F6520 I want to use... then I ran the simulation in Proteus but the interval of the + half cycle is too fast (in us) which isn't proper (it should be 10ms)...
After many trials I finally decided to post the issue and the code here so everyone can help, here's the code:
I PM Tahmid yesterday for this issue but it seems like he is busy or so...
It may have wrong Timer3 configurations due to many trials made...
Thank you in advance ^______________^
I have a problem in PIC18F6520 CCP4 compare module.
I work in a project that includes controlling a DC-to-AC inverter using PIC18, all I need is a 50Hz signal with 50% duty cycle.
so 50Hz = 20ms, 1st 10ms will be + and last 10ms will be - in order to control the inverter circuit.
I saw Tahmid's code, modified it so it can suit the PIC18F6520 I want to use... then I ran the simulation in Proteus but the interval of the + half cycle is too fast (in us) which isn't proper (it should be 10ms)...
After many trials I finally decided to post the issue and the code here so everyone can help, here's the code:
Code:
void interrupt(){
if (CCP4IF_bit == 1){
RE4_bit = ~ RE4_bit; //Toggle RC0
CCP4IF_bit = 0;
RE3_bit = RE4_bit;
TMR3L = 0;
TMR3H = 0;
}
}
void main() {
PORTE = 0;
TRISE = 0;
CCP4CON = 10;
CCP4IE_bit = 1;
GIE_bit = 1;
PEIE_bit = 1;
CCPR4H = 0x9C;
CCPR4L = 0x40;
T3CON = 0x41; //Prescaler 1:1, start Timer 1
while(1){
//Do whatever else is required
}
It may have wrong Timer3 configurations due to many trials made...
Thank you in advance ^______________^