Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Writing for the ATMega8

Name: Anonymous 2010-11-17 17:57

Jesus Christ this shit shouldn't be so hard.

IF ANYbody else ever needs fast PWM on PB3, here's the enable stuff:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "setupPWM.h"


void setupPWM() // Sets up Fast non-inverting PWM with no pre-scaler.
{
    //    Set PB3 as output
    DDRB |= 0b0001000;
    PORTB |= 0b00001000;
   
    // Set Fast non-inverting PWM without pre-scaler
    TCCR2 = 0b01101001;
   
    // Set initial value. 0xFF = 100%, 0xFF = 0%
    OCR2 = 0b10000000;
   
}

Name: Anonymous 2010-11-17 17:58

Oh, that had a bunch of unnecessary includes, sorry. You can make do with just <avr/io.h> and of course the include file to wherever you put setupPWM()

Name: Anonymous 2010-11-17 18:57

Ugh, and "Initial value" in the comments is off, too.

0xFF is 0%, 0x00 is 100%, the Duty Cycle is 1/OCR2

Name: Anonymous 2010-11-18 15:05

Port it to an ARM9 and run it on Windows CE.

Name: Anonymous 2010-11-18 20:04

haha fuck no

Name: Anonymous 2010-11-19 0:46

Port it to x86 and run it on Windows 7.

Name: Anonymous 2010-11-19 3:50

Port it to The Java Virtual Machine and run it everywhere.

Name: Anonymous 2010-11-19 5:24

Port it to penis and run it in my anus

Name: Anonymous 2010-11-19 7:53

Really, the trouble with the ATMega series isn't that they're weak - there's plenty of stuff you can do with 8 bits and a MHz of clock. It's not that they're undocumented.

No, the problem is that they're documented in a fashion that assumes you already know what you're doing (in which case, why are you reading the documentation?) That's no longer a problem for me because I *do* generally know what I'm doing but I still remember back when I first started working with Atmel products. Christ.

Name: Anonymous 2010-12-24 23:09

Name: Anonymous 2011-02-02 22:35

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List