pwm pin

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

pwm pin

Postby bear » Sat Feb 12, 2011 5:08 am

how to use pwm pin of pic.. please give sample coding..
bear
Apprentice
 
Posts: 46
Joined: Tue Oct 05, 2010 2:11 am

Re: pwm pin

Postby ober » Sat Feb 12, 2011 8:43 am

hi, there are many sample coding available from Cytron DIY project, PR10-controlling DC motor, PR23-multifunction mobile robot, PR19-Flexibot. Also the sample source code for MC40A.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: pwm pin

Postby bear » Sat Feb 12, 2011 11:13 am

thanks..
bear
Apprentice
 
Posts: 46
Joined: Tue Oct 05, 2010 2:11 am

Re: pwm pin

Postby shahrul » Fri Feb 18, 2011 8:49 pm

bear WROTE:how to use pwm pin of pic.. please give sample coding..

See this example PWM code and video. I have PWM function.
CODE: SELECT_ALL_CODE
void pwm_set(int freq, int duty)
{int a;
T2CON=0b00000111;
PR2=(_XTAL_FREQ/(4*16))/(freq)-1;
a=(PR2+1)*duty/25;
CCPR2L=a/4;
CCP2CON=(CCP2CON&0b11001111)|((a%4)<<4);
}
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 2 guests

cron