Hi So I am narrowing down a problem I am having with an spi conection.
When a button is pressed the mega1284 tries to transmit some data using SPI communication. It never seems to finish. Within the code I can see that it an leave the do while based on two conditions:
do { //stop if max_retries reached if((mirf_read_register(OBSERVE_TX) & 0b1111) == mirf_RETR) { breaked = 1; break; } _delay_us(10); } while( !(mirf_get_status() & _BV(TX_DS)) );
I dont completely understand the if conditon that breaks the loop but the while condition I do.
If SPDR returns 1 here it will leave the loop:
uint8_t spi_writeread(uint8_t data) { SPDR = data; while((SPSR & (1<<SPIF)) == 0); return SPDR; }
I have checked it and it never is not 0.
My question is does this suggest a connection problem i.e hardware? I have checked my connections and everything is good as far as I can tell.
I am currently trying to understand the output of my scope...