Ok, so I am fairly new to AVR microcontrollers and I am having trouble applying what I thought was a simple solution to a senior engineering design project for my undergrad. The project is using a total of 14 double pole double throw relays (TQ2-L2-3V) which allow an analog interface board to change between impedances for analog signal testing. I selected the ATmega32A because it can has the 32 general purpose input outputs.
5 of the pins on the atmega32 are used as an input that receive a 3.3 V. (currently using ports pd3-7) From these 5 inputs a simple truth table can be constructed giving a total of 32 distinct possible outputs (I only actually need 26 but need 5 'bits' to get enough to output up to 26).
d03 = 1 , d04 =2, d05= 4, d06=8, and d07 = 16. Inside the source code I set a variable to store the corresponding value for each port and then add the together to get the total output. This total output then designates which port to output that flips the relay either on or off.
Currently, the only port I can get to work correctly as an output correctly is porta. ie.. I provide an input to port pd3 and it causes an output of 5v on port a0. When I provide an input to pd3 & pd6 (value of 9 from the truth table) I get a jump in voltage that my meter isn't quick enough to read and then it settles at roughly .3volts. This happens for all of ports b,c,and d.
Any help is appreciated. Attached is my source code. Be gentle... I'm new to this!