Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Regarding pwm in atmega8

Status
Not open for further replies.

Embedded_Geek

Full Member level 6
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top