![]() ![]() Now we get to the actual duty cycle generation. | _BV(COM01) // PWM polarity: active high 80-81 of the ATmega32(L) data sheet.) This results in the setup line: TCCR0 = _BV(WGM01) | _BV(WGM00) // PWM mode: Fast PWM. This means COM01 needs to be set and COM00 needs to be cleared. larger PWM input values result in larger high-output duty cycles. So I'm going to assume you want a positive-going PWM, i.e. Right now you have them (implicitly) disabled PWM output (OC0 disconnected). ( _BV(N) is an avr-libc macro that's more legible than the (1<<N) stuff you're using, but does the same thing.) Also, you're missing the polarity of your PWM output, set by the COM00 and COM01 bits. You have to set all the bits at once, or you have to use a read-modify-write operation (usually TCCR0 |= _BV(bit_num) to set a bit or TCCR0 &= ~_BV(bit_num) to clear it). Setupįirst off, you're setting up TCCR0 wrong. The assembly-only stuff is available as macros in avr-libc. ![]() Also, you shouldn't need to do anything in assembly on AVR. Well, I guess you're okay with all port B and C pins being outputs. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |