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

HOW TO GET RSSI

HI,i have some problems about RSSI (51882) BELOW IS MY CODE. who can tell me why I can not get RSSI from variable t

int main(void)
{
	uint8_t *p;
	uint8_t t = 0;
    // Start 16 MHz crystal oscillator.
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART    = 1;

    // Wait for the external oscillator to start up.
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) 
    {
        // Do nothing.
    }
  
    // Set Port 1 as output.
    nrf_gpio_range_cfg_output(LED_START, LED_STOP);

    // Set radio configuration parameters.
    radio_configure();

    nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, 0x55);

    while(true)
    {
        // Set payload pointer.
        NRF_RADIO->PACKETPTR    = (uint32_t)packet;
			 // p = (uint8_t *); 
        NRF_RADIO->EVENTS_READY = 0U;        
        NRF_RADIO->TASKS_RXEN   = 1U; // Enable radio.

        while(NRF_RADIO->EVENTS_READY == 0U) // Wait for an event to be ready.
        {
            // Do nothing.
        }

        NRF_RADIO->EVENTS_END  = 0U;     
				 
        NRF_RADIO->TASKS_START = 1U; // Start listening and wait for address received event.
       // NRF_RADIO->TASKS_RSSISTART = 1U;
        // Wait for the end of the packet.
        while(NRF_RADIO->EVENTS_END == 0U)
        {
            // Do nothing.
        }
				//NRF_RADIO->EVENTS_RSSIEND = 0U;	
			//	NRF_RADIO->TASKS_RSSISTART  = 1U;		  	
				while(NRF_RADIO->EVENTS_RSSIEND == 0U)
				{
					 
				}
        t = NRF_RADIO->RSSISAMPLE;
				//nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, NRF_RADIO->RSSISAMPLE);

				// Write received data to port 1 on CRC match.
        if (NRF_RADIO->CRCSTATUS == 1U)
        {
          nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[0]);
					nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[1]);
					nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[2]);
					nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[3]);
					nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[4]);
					nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[5]);
	//				nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[6]);
	//				nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[7]);
	//				nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[8]);
			//		t = NRF_RADIO->RSSISAMPLE;
					//p = &packet;   

        }
				
//				while(NRF_RADIO->EVENTS_RSSIEND == 0U)
//				{
//				      
//				}


        NRF_RADIO->EVENTS_DISABLED = 0U;    
				NRF_RADIO->TASKS_RSSISTOP  = 1U;	
        NRF_RADIO->TASKS_DISABLE   = 1U;  // Disable the radio.
        
        while(NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // Do nothing.
        }
    }      
}

void radio_configure()
{
    // Radio config
	  NRF_RADIO->SHORTS  = RADIO_SHORTS_ADDRESS_RSSISTART_Msk  ; //( RADIO_SHORTS_DISABLED_RSSISTOP_Enabled << RADIO_SHORTS_DISABLED_RSSISTOP_Pos )   ; 
    NRF_RADIO->TXPOWER   = (RADIO_TXPOWER_TXPOWER_Neg30dBm << RADIO_TXPOWER_TXPOWER_Pos);
    NRF_RADIO->FREQUENCY = 2UL;           // Frequency bin 7, 2407MHz
    NRF_RADIO->MODE      = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
   // NRF_RADIO->PACKETPTR = 
    // Radio address config
    NRF_RADIO->PREFIX0 = 
        ((uint32_t)swap_bits(0xC3) << 24) // Prefix byte of address 3 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC2) << 16) // Prefix byte of address 2 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC1) << 8)  // Prefix byte of address 1 converted to nRF24L series format
      | ((uint32_t)swap_bits(0x57) << 0); // Prefix byte of address 0 converted to nRF24L series format
  
    NRF_RADIO->PREFIX1 = 
        ((uint32_t)swap_bits(0xC7) << 24) // Prefix byte of address 7 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC6) << 16) // Prefix byte of address 6 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC4) << 0); // Prefix byte of address 4 converted to nRF24L series format

    NRF_RADIO->BASE0       = bytewise_bitswap(0x42594c4BUL);  // Base address for prefix 0 converted to nRF24L series format
    NRF_RADIO->BASE1       = bytewise_bitswap(0x89ABCDEFUL);  // Base address for prefix 1-7 converted to nRF24L series format
  
    //NRF_RADIO->TXADDRESS   = 0x00UL;      // Set device address 0 to use when transmitting
    NRF_RADIO->RXADDRESSES = 0x01UL;    // Enable device address 0 to use to select which addresses to receive

    // Packet configuration
    NRF_RADIO->PCNF0 = (PACKET_S1_FIELD_SIZE     << RADIO_PCNF0_S1LEN_Pos) |
                       (PACKET_S0_FIELD_SIZE     << RADIO_PCNF0_S0LEN_Pos) |
                       (PACKET_LENGTH_FIELD_SIZE << RADIO_PCNF0_LFLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"

    // Packet configuration
    NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
                       (RADIO_PCNF1_ENDIAN_Big       << RADIO_PCNF1_ENDIAN_Pos)  |
                       (PACKET_BASE_ADDRESS_LENGTH   << RADIO_PCNF1_BALEN_Pos)   |
                       (PACKET_STATIC_LENGTH         << RADIO_PCNF1_STATLEN_Pos) |
                       (PACKET_PAYLOAD_MAXSIZE       << RADIO_PCNF1_MAXLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"

    // CRC Config
    NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
    if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO->CRCINIT = 0xFFFFUL;      // Initial value      
        NRF_RADIO->CRCPOLY = 0x11021UL;     // CRC poly: x^16+x^12^x^5+1
    }
    else if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_One << RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO->CRCINIT = 0xFFUL;        // Initial value
        NRF_RADIO->CRCPOLY = 0x107UL;       // CRC poly: x^8+x^2^x^1+1
    }
}

hope u can help me ..

Related