Electronics > Microcontrollers

AVR not getting any output from PWM

(1/1)

blewisjr:
Hey guys I am messing around with a PWM on a ATtiny2313A.  I am trying to get a signal out of it any signal at all and I am getting nada.
Not really sure what is going on.  I have it set for a 50% duty cycle ish I think and only thing on the pin is my scope probe.

Wish I can give more info but here is some code. The uC is clock at 1 MHZ


--- Code: ---int main(void)
{   
   
    TCCR0A = 0b00100011;  // Setup fast PWM on PD5
    TCCR0B = 0b00000001;  // no prescaler
    OCR0B = 126;  // about 50% duty cycle
    TCNT0 = 0;  // Reset TCNT0 register
    DDRD |= (1<<5);  // Set PD5 (OC0B) as an output
   
   
    while(1);
   
    return 0;
}
--- End code ---

EDIT:  Fixed the code above I missed a bit in TCCR0B doh.

Psi:
Do you mean you fixed the problem and now its working?
Or you made a mistake posting your non-working code and now it's correct non-working code?  ;D

blewisjr:
Fixed the mistake and now it is working code sorry lol.  Noticed it while I was looking at the code waiting for a reply.

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod