می خواستم از PWM در WINAVR استفاده کنم اگه سورس ساده ای توانست گیر بیاره یا کسی PWM در WINAVR آشنا بود بی دریغ سپاس گذارمکمکی بکند. :smile:
اضافه شده در تاریخ :
این هم سورس
حالا یکی که می تونه توضیح بده.
اضافه شده در تاریخ :
این هم سورس
#include <avr\io.h>
#include <avr\iom8.h>
#define outp(a, b) b = a
int main(void) {
/* set OC2 for PWM output*/
outp((1<<PINB3), DDRB);
/*set timer counter initial value*/
TCNT2=0x00;
/*Set timer output compare register*/
OCR2=0x80;
/*start timer:
without presscaler
Non inverted mode in OC2 pin;
phase corect PWM*/
outp((1<<FOC2)|(1<<COM21)|(1<<CO M20)|(1<<WGM20)|(1<<CS00), TCCR2);
for (;
{
/* loop forever timer does the job*/
}
}
[url=http://[url=http://winavr.scienceprog.com/avr-gcc-tutorial/control-avr-8-bit-timer-counter2-using-winavr.html]http://winavr.scienceprog.com/avr-gc...inavr.html</a>#include <avr\iom8.h>
#define outp(a, b) b = a
int main(void) {
/* set OC2 for PWM output*/
outp((1<<PINB3), DDRB);
/*set timer counter initial value*/
TCNT2=0x00;
/*Set timer output compare register*/
OCR2=0x80;
/*start timer:
without presscaler
Non inverted mode in OC2 pin;
phase corect PWM*/
outp((1<<FOC2)|(1<<COM21)|(1<<CO M20)|(1<<WGM20)|(1<<CS00), TCCR2);
for (;

/* loop forever timer does the job*/
}
}
حالا یکی که می تونه توضیح بده.
دیدگاه