Estoy tratando de usar un ATmega32 para comunicarme con un chip MAX7219 para multiplexar con una matriz de led. Sin embargo, tengo varios dispositivos diferentes con los que quiero comunicarme.
Estoy intentando comunicarme con el dispositivo sin utilizar realmente los pines SPI provistos en el microcontrolador. He hecho un proyecto de prueba, pero nada está funcionando. Al principio parecía que había algo mal con mi código. He estado en otros foros y la gente me ha mostrado un mejor código para hacer el trabajo, pero todavía no puedo hacer que esto funcione. Revisé todo mi cableado e incluso lo conecté a un Arduino y funcionó perfectamente. Así que ahora estoy pensando que tiene algo que ver el ATmega. ¿Hay algún pasador que necesite resistencias de pull-up o pull-down? O tal vez hay algo más que es el problema?
aquí es sólo una prueba perezosa. Ni siquiera esto funciona, prueba ni parada. código de prueba simple:
//test
#include <avr/io.h>
int main(void)
{
DDRB = 0b00000111; // pin 1, 2 and 3 are outputs
/*
//display test
PORTB = 1 << PINB0; // data pin 1 is high
PORTB = 0 << PINB1; // clock pin 2 is low
PORTB = 0 << PINB2; // latch pin 3 is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
// next 8 bits
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB2; // latch pin 3 is high
*/
// shutdown
PORTB = 1 << PINB0; // data pin 1 is high
PORTB = 0 << PINB1; // clock pin 2 is low
PORTB = 0 << PINB2; // latch pin 3 is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB0; // data pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
// next 8 bits
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB1; // clock pin is high
PORTB = 0 << PINB1; // clock pin is low
PORTB = 1 << PINB2; // latch pin 3 is high
}