0
\$\begingroup\$

For a project I am programming an Atmega 328 AU on a custom made PCB. After a lot of struggles I managed to get a bootloader and a program on the chip. I programmed some IO pins and they seem to work fine. The output pins that I use give: LOW = 0 Volt High = 5 Volt which is desired. However, one pin, pin 9 of the chip, gives: LOW = 0 Volt, HIGH = 1 Volt. The 1 Volt does not trigger my opto-coupler so I would like this pin also to give HIGH = 5 Volt. Is there any way to change this in software?

I use the Arduino IDE for programming.

Thank you guys.

edit: Still not figured out. Ill add some schematics. Note: The supply is not that flat with my own power supply, but I could add a bigger capacitor. However, for the opto-coupler is does not matter and the output will correctly trigger the opto-coupler for the 5V.

Microcontroller schematic Optocoupler circuit Measurement of 5 V output Measurement of 1 V output

\$\endgroup\$
7
  • 1
    \$\begingroup\$ You'll need to show your circuit. How much current does your opto-coupler draw? Have you added current limiting resistors/ \$\endgroup\$ – Tom Carpenter Jan 13 at 14:05
  • 1
    \$\begingroup\$ Pin 9 has alternate functions for crystal. Check your clock fuse bits to make sure you have the correct setting. \$\endgroup\$ – jwh20 Jan 13 at 14:12
  • \$\begingroup\$ All my outputs use the same output circuit. A 330 ohm resistor in series with the opto coupler LED and then to GND. Only one output is a plain 1 Volt steady measured at the microcontroller. The microcontroller outputs have steady 5 Volts. \$\endgroup\$ – WillyBogard Jan 13 at 14:13
  • \$\begingroup\$ @jwh20 I see, but I wonder is it possible to alter its function to get a 5 Volt out? \$\endgroup\$ – WillyBogard Jan 13 at 14:14
  • 1
    \$\begingroup\$ Yes, check your fuse bits. \$\endgroup\$ – jwh20 Jan 13 at 14:24
1
\$\begingroup\$

The package type of ATmega328-AU is Plastic Thin Quad Flat Package (TQFP). The pin configuration is different from the 28 SPDIP package types. On 28 SPDIP package, pins 9 and 10 are crystal input. In this case, you could not be used like Arduino Pin.

atmega328-au_tqfp_spdip

On Atmega328-AU is different, you can use Pin 9 like Arduino Pin 5. 

ATmega328-AU pinout

Your test code can be like this:

void setup() {
    pinMode(5, OUTPUT);
    digitalWrite(5, HIGH);
}

void loop() {
}
\$\endgroup\$
0
\$\begingroup\$

Thank you all for helping me! I do have the TQFP package. However I found the problem which was actually stupid. The outputs where listed:

pinMode(pinNumberA, OUTPUT); pinMode(pinNumberB, OUTPUT); pinMode(pinNumberC, OUTPUT); pinMode(pinNumberD, OUTPUT);

But I seemed to only have listed 4 outputs out of 5. One of the outputs I forgot. So after seeing lmcapacho's post I did check again so thank you! Problem is solved.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.