How can read the assembly code of analogWrite() and PinMode()?

Hello, I'm doing a project (for university) in which I write directly the registers DDRD, PORTD, PIND, for configure digital I/O. Later I need use one of the pins of the same port (DDRD) like an analog output and input (I do this with analogWrite and PinMode)... and after this back the pin to the previous state (digital I/O again) writing directly the registers. The issue is that the last step fails. When newly write the registers for use the pin like digital output, it don't set to high or low, the PWM continues active in the pin.

I would like to know how work the functions from above to fix it.

Please, would someone so polite to help me?

Thanks in advance.

Just compile a sketch containing the code you need and then use avr-objdump on the output.

Or look at the source code. You have it.

Excuse me for my ignorance... but i use the arduino Java gui + avr-gcc compiler on linux. My problem is that I don't know in which folder the code is compiled and builded. I don't know where i can find the avr-objdump too. Is an executable on my system? Is another GUI program?. EDIT.. ok I found the avr-objdump on konsole. bash exec.

On the other hand. In which part of the source code can I find that? Must I download the source code for linux for example, open the tarball and look over there?

greetings to both and thank you.

ozcy:
excuse me for my ignorance... but i use the arduino Java gui + avr-gcc compiler on linux. My problem is that I don't know in which folder the code is compiled and builder. I don't know where i can find the avr-objdump too. Is an executable on my system? Is another program?.

If you go to preferences and enable verbose compilation, the IDE will tell you everything it does. That will contain the name of the temporary directory in which it compiles stuff. avr-objdump is part of avr-binutils

On the other hand. In which part of the source code can I find that? Must I download the source code for linux for example, open the tarball and look over there?

All the source code for the arduino library functions is in the arduino directory, under hardware/arduino/cores/arduino
Or here: https://github.com/arduino/Arduino/tree/master/hardware/arduino/cores/arduino

Thank you very much WizenedEE. I will take a look

When newly write the registers for use the pin like digital output, it don't set to high or low, the PWM continues active in the pin.

Yes this is because the PWM is controlled by the timers, this is a hardware thing and the pin's function is switched to be controlled by the timers as an alternative function. Therefore it no longer is switched through to the normal port registers.
You need to look at section 13.3 in the ATmega328 data sheet to see what is going on.

Very greatful! Grumpy_Mike