Warning: N00b question!

No flames please :slight_smile:

I’m really starting out from scratch, trying to use Atmel chips in various open-hardware / open-firmware projects. I have a basic understanding of general purpose assembler, so Atmel’s assembler is not a black box or anything, but I don’t really understand how it ends up controlling the chip’s behavior.

As an example, using an AtMega8, let’s say I want to put out a signal on PB1/OC1A. I guess I need to set a register value somewhere, but where?

I’m not asking for all the answers (after all, I need to do a LITTLE work if I want to enjoy the rewards :-)), but maybe a hint on where to look for this information? As far as I can tell, it’s not part of the language reference (since this is a chip-specific problem), and I can’t find it in the summary data sheet for the AtMega8, nor the more detailed. Where can I get this information? I thought I finished RTFM, but maybe I’m blind?

Thanks for any help…

peripherals on AVRs (like lots of other microcontrollers) are controlled through special-function registers, SFRs, which are usually assigned to some memory address. (On a single-chip system, the difference between a register and a memory location is kind of blurry anyway.)

since there are so many different functions assigned to a small number of pins, you need to set up the port by telling the uC that you’re using that pin as a general-purpose I/O pin, and configure it as an output. After you’ve done that, you change the value on the pin by writing to the register (memory address) which is assigned to the port’s output latch.

you probably want to look at [the mega8 data sheet near page 49 (“I/O Ports, introduction”) and page 50 (“Ports as general digital I/O … configuring the pin”).](http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf)

It never fails. I read the spec sheet 50 times, pore over the source code, wrack my brains for weeks trying to figure it out, then, 30 seconds after I post my idiotic newbie question to some public place, I find the answer on page 1 of the data sheet (or some other obvious place).

Thanks, wiml for helping me out, but, as usual, I figured this out about ten minutes after posting. sigh