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

Transmit and Receive question with PSoC 3

I am trying to get the nRF24L01+ working with a PSoC 3. I initialize the nRF like this..

spiWrite1(NRF_CONFIG, 0x0F);     // reflect TX_DS, RX_DR and MAX_RT interrupts as IRQ 
                                                  // active low, enable 2-byte CRC, power-up, RX mode
spiWrite1(NRF_SETUP_AW, 0x03);   // 5 byte address
spiWrite1(NRF_RX_PW_P0, 0x03);   // 3 bytes of payload
spiWrite0(FLUSH_TX);     // Flush Tx FIFO
spiWrite0(FLUSH_RX);     // Flush Rx FIFO
nrfClearStatusInt(STAT_MAX_RT | STAT_RX_DR | STAT_TX_DS);  // Clear INT's
CE_Write(0);                            // stand-by

Then, in the main loop, I transmit some test data when a button in pushed..

 spiWrite0(FLUSH_TX);                 // Clear Tx FIFO
 nrfClearStatusInt(STAT_TX_DS);  // Clear TX_DS INT
 txdata[0] = Input_1_Read();        // Fill an array with data to send
 txdata[1] = Input_1_Read();        // The first two bytes are the switch condition (0 or 1)
 txdata[2] = 0x55;                        // Some dummy data
 spiWriteTxData(txdata, RX_PAYLOAD_BYTES);    // Send the array of data

The "spiWriteTxData" function looks like this..

void spiWriteTxData(const uint8 txdata[], uint8 bytes) {
    uint8 array[RX_PAYLOAD_BYTES+1], stat;
    int x, y;

    array[0] = W_TX_PAYLOAD;    // nRF command to fill Tx FIFO
    for (x = 0, y = 1; x < bytes; x++, y++) {
        array[y] = txdata[x];        // Copy data to send into array (after nRF command)
    }
    SPIM_PutArray(array, bytes+1);  // Send the array to the nRF chip
    CE_Write(0);          // Enable chip for Tx
    stat = spiRead1(NRF_CONFIG);   // Read nRF config register
    stat &= ~CFG_PRIM_RX;             // Clear the PRIM_RX bit
    spiWrite1(NRF_CONFIG, stat);    // Write new value to config register
    CE_Write(1);                             // We've waited > 10uSec, so send CE HI
    stat = spiRead1(NRF_CONFIG);   // Read the config register
    stat |= CFG_PRIM_RX;               // Set the PRIM_RX bit
    spiWrite1(NRF_CONFIG, stat);   // Write value back to config reg
}

That seems to work (as seen my the logic analyzer outputs below). image description image description

So my first question is; does that look correct (am I actually transmitting the 3 bytes I think I am)?

Second, why is the IRQ going LO, I haven't recv'd an ACK and didn't use the NO_ACK Tx command?

Third, how do I receive that data? On another PCB I have an nRF intialized the same way as above, when I check with analyzer CE is always LO, the status register returns 0x0E and the config register returns 0x0F. Do I need to set the receiver up differently or am I missing something?

Related