April 23, 2010
Hello guys. I'm trying to make an spi connection between the arduino and an IC. Actually it's not an arduino, it's an atmega328 on a breadboard, but i'm programming it with the arduino IDE through ICSP. I've got a problem, this sketch doesn't work:
byte clr; SPCR=B01010011;
digitalWrite(10, LOW); //10 is basically the SLAVE SELECT pin
spi_transfer(B00000100); //powerup delay(10);
spi_transfer(B00001010); //STOPPWRDN com
void spi_transfer(volatile char data)
while(!(SPSR & (1<<SPIF)))
Never mind about the commands, i just wanted to focus your attention on the spi_transfer function.
Curious thing is that the same program on picaxe works (of course the commands are different: hspiout instead of spi_transfer). I've also tried the SPI library and the shiftOut command and they don't work, so i'm starting to think it is a problem related to something else, something like the fact that my chip doesn't have the bootloader (i don't know why that would matter though, but i have no more ideas!) or the fact that i have to set fuse bits in some strange way to make SPI work. Any ideas?