Regarding pwm in atmega8

Status
Not open for further replies.

Embedded_Geek

Full Member level 6
Joined
Jul 5, 2010
Messages
342
Helped
58
Reputation
116
Reaction score
56
Trophy points
1,318
Location
Germany
Visit site
Activity points
2,974
I have an odd problem the value of OCR1A is automatically taken as 0x3FF, below is my code

Code:
int main(void)
{

    // PB1(OC1A) is now an output
    DDRB |= (1 << DDB1);
    
    // set PWM for 50% duty cycle ((65536/2) - 1 )
    OCR1A = 0x7fff;
    
    // set none-inverting mode
    TCCR1A = (1 << COM1A1);
    
    // Fast PWM
    TCCR1A |= ((1 << WGM11) | (1 << WGM10));
    TCCR1B = ((1 << WGM13) | (1 << WGM12));

    // Set prescaler
    TCCR1B |= (1 << CS10);

    while(1);


But i see that when it reaches while(1) value of OCR1A = 0x3FF.


Thanks in advance
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…