Hello everybody
pleeease help me..
I'm using this function to control the speed of a small DC motor using pwm, and the problem is that the output of OC1A is still VCC whether I give OCR1A any value including 0xFFFF and 0x0000 and any value between them.. this is the function...
/********************************************* Chip type : ATmega8535 Program type : Application Clock frequency : 4.000000 MHz Memory model : Small External SRAM size : 0 Data Stack size : 128 *********************************************/ #include//MOTOR: //********************************************************** //Motor Pins: //-------------- //PIND.5=OC1A:PWM source for the motor . // //The following function is used to set Timer1 in fast pwm mode void settings(void) { DDRD |=0b00100000;//PORTD.5=OC1A is output// /* // Bit7:6=COM1A1:0(Compare Output Mode for Channel A)=10>>(Clear OC1A/OC1B on Compare Match, // set OC1A/OC1B at TOP (Non-Inverting)) with WGM13:0=1111 // Bit5:4=COM1B1:0(Compare Output Mode for Channel B)=00>>Normal port operation, OC1B disconnected. // Bit3=FOC1A(Force Output Compare for Channel A)=0>>No Forcing for Output Compare of Channel A // Bit2=FOC1B(Force Output Compare for Channel B)=0>>No Forcing for Output Compare of Channel B // Bit1:0=WGM11:0(Waveform Generation Mode)=11+WGM13:2=11>>Mode: Fast PWM top=OCR1A */ TCCR1A=0b10000011; TCNT1=0xFFFE;// MAX count value; /* // Bit7=ICNC1(Input Capture Noise Canceler)=1>>Input Capture Noise Canceler On // Bit6=ICES1(Input Capture Edge Select)=0>>Falling Edge // Bit5=Reserved Bit=0; // Bit4:3=WGM13:2(Waveform Generation Mode)=11+WGM11:0=11>>Mode: Fast PWM top=OCR1A // Bit2:0=CS12:0(Clock Select)=001>>>clock source clkI/O/1 (No prescaling). */ TCCR1B=0b10011001; OCR1A=0x9999;//PWM Duty }
:( :(
thanks in advance