anjalimidhuna
Member level 3
- Joined
- Jan 4, 2014
- Messages
- 62
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 8
- Location
- india
- Activity points
- 358
Hi,
My project is a simple light dimmer.I connected a port to AN1. adc values are given to pwm1.I am getting only half of the expected frequcy. pic12f1501 is my controller.following is the code that i used.
My project is a simple light dimmer.I connected a port to AN1. adc values are given to pwm1.I am getting only half of the expected frequcy. pic12f1501 is my controller.following is the code that i used.
Code:
void main() {
TRISA2=0;
TRISA3=1;
OSCCON=0xF3;
OSCSTAT=0x10;
adc_init();
T2CON=0x04;
while(TMR2IF==0);
TMR2IF=0;
PR2=0xC7;
PWM1CON=0xE0;
while(1)
{
while(ADGO==1);
ADGO=1;
PWM1DCH=ADRESH;
PWM1DCL=ADRESL;
}
}
Last edited: