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.
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?
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?
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.