This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to change modes.

I wrote two applications, and both will never know what application starts first. So I design a handshake that works something like this.

receiver

Set to receiver, look for transmitter to send a NOP.

transmitter

must first set to receiver as the hex code is the same for both, based on some criteria it will know to enter transmitter mode,

set to transmitter and look for a NOP.

However the issue is that once I set my transmitter  to receiver mode its stuck in that mode. To close that mode I do this.

void Close(void)
{
    SPCR |= (1<<SPE);//turn off spi.
    enable();
    sendCommand(0x20);sendCommand(0x00);//power off.
    disable();
    pulse();
    
    DDRB &= ~0x1f;
    PORTB |= 0x02;
    SPCR &= ~(1<<SPE);//power down SPI
}

then initialize my nr24p again with transmitter 0x20,0x0a....

but seems not to work. If I wire up my application to skip receiver mode like so

transmitter

// must first set to receiver as the hex code is the same for both, based on some criteria it will know to enter transmitter mode,

set to transmitter and look for a NOP.

All works fine. So what I'm wondering is how can I switch from receiver to transmitter white its powered on. My above code is not working.

Parents Reply Children
No Data
Related