I'm trying to use an ATmega32 to communicate to a MAX7219 chip for multiplexing with an led matrix. However, I do have multiple different devices that I want to communicate with.

I am trying to communicate with the device without actually using the SPI pins provided on the microcontroller. I have made a test project, but nothing is working. At first it seemed there was something wrong with my code. I've been on other forums and people have shown me better code for doing the job, but still I can't seem to get this working. I've checked all my wiring and even connected it to an Arduino and it ran perfectly. So now I'm thinking it has something to do the the ATmega. Do any pins need pull-up or pull-down resistors on them? Or is there maybe something else that is the issue? 

![enter image description here][1]


One of my codes:


    #include <avr/io.h>
    #include <util/delay.h>


    int main(void)
    {
		
	
	
	DDRB = 0b00000111; // pin 1(data), 2(clock) and 3(latch) are outputs
	
	PORTB = 0b00000000;
	
	
	_delay_ms(1);
	uint16_t data;
	data = 0b0000110000000000; // data to shift out to the register
	//read bit
	uint16_t mask;
	for (mask = 0b1000000000000000; mask>0; mask >>= 1)
	{
		
		//iterate through bit mask
		if (data & mask)
		{ // if bitwise AND resolves to true
			// send one
			PORTB |= 1 << PINB0;
			_delay_ms(1);
			// tick
			PORTB |= 1 << PINB1;
			_delay_ms(1);
			// tock
			PORTB &= ~(1 << PINB1);
			_delay_ms(1);
		}
		else{ //if bitwise and resolves to false
			// send 0
			PORTB &= ~(1 << PINB0);
			_delay_ms(1);
			// tick
			PORTB |= 1 << PINB1;
			_delay_ms(1);
			// tock
			PORTB &= ~(1 << PINB1);
			_delay_ms(1);
		}
		
		
		
	}
	
	PORTB |= 1 << PINB2; // latch all the data
	_delay_ms(1);
	PORTB &= ~(1 << PINB2); // latch pin 3 is low
	_delay_ms(1000);
	

    }


  [1]: https://i.sstatic.net/a1QzT.png