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

How to measure RSSI with NRF51822?

Hello!

I would like to measure RSSI for different channels so as to decide which channel is the least noisy one (and more particularly, which ones are already used). I cannot make it work, so I am asking you for help.

My code:

for(i=0; i<20; ++i) 
{
	NRF_RADIO->FREQUENCY = i;
	NRF_RADIO->EVENTS_READY = 0U;
	NRF_RADIO->TASKS_RXEN = 1U;
	while(NRF_RADIO->EVENTS_READY == 0U);
	NRF_RADIO->EVENTS_END = 0U;
	
	NRF_RADIO->TASKS_START = 1U;
	
	NRF_RADIO->EVENTS_RSSIEND = 0U;
	NRF_RADIO->TASKS_RSSISTART = 1U;
	while(NRF_RADIO->EVENTS_RSSIEND == 0U);
	
	rssi[i] = NRF_RADIO->RSSISAMPLE;
	
	NRF_RADIO->EVENTS_DISABLED = 0U;    
	NRF_RADIO->TASKS_DISABLE   = 1U;  // Disable the radio.

	while(NRF_RADIO->EVENTS_DISABLED == 0U)
	{
			// Do nothing.
	}
}

With this code, even if a module is continuously emitting signal, rssi is 90 (0x5A) for every channel. Am I missing something? Isn't it possible to measure RSSI without receiving any packet?

Best regards, Nicolas

Parents
  • my code...

    void radio_init() {

    radio_configure();

    NRF_RADIO->SHORTS |= RADIO_SHORTS_ADDRESS_RSSISTART_Msk; //RSSI enable

    NRF_RADIO->EVENTS_READY = 0U; NRF_RADIO->TASKS_RXEN = 1; // Enable radio and wait for ready.

    while (NRF_RADIO->EVENTS_READY == 0U) { }

    }

    uint8_t radio_rssi_get (void) {

    uint8_t sample;

    NRF_RADIO->EVENTS_RSSIEND = 0; NRF_RADIO->TASKS_RSSISTART = 1U;

    while (NRF_RADIO->EVENTS_RSSIEND == 0) { } sample = (NRF_RADIO->RSSISAMPLE & RADIO_RSSISAMPLE_RSSISAMPLE_Msk);

    NRF_RADIO->EVENTS_RSSIEND = 0;

    return sample;

    }

    void main()

    {

    uint8_t rssi = 0; 
    
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART    = 1;
      
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {} 
    

    radio_init();

    while(true) 
    {
        rssi = radio_rssi_get();
    }
    

    }

Reply
  • my code...

    void radio_init() {

    radio_configure();

    NRF_RADIO->SHORTS |= RADIO_SHORTS_ADDRESS_RSSISTART_Msk; //RSSI enable

    NRF_RADIO->EVENTS_READY = 0U; NRF_RADIO->TASKS_RXEN = 1; // Enable radio and wait for ready.

    while (NRF_RADIO->EVENTS_READY == 0U) { }

    }

    uint8_t radio_rssi_get (void) {

    uint8_t sample;

    NRF_RADIO->EVENTS_RSSIEND = 0; NRF_RADIO->TASKS_RSSISTART = 1U;

    while (NRF_RADIO->EVENTS_RSSIEND == 0) { } sample = (NRF_RADIO->RSSISAMPLE & RADIO_RSSISAMPLE_RSSISAMPLE_Msk);

    NRF_RADIO->EVENTS_RSSIEND = 0;

    return sample;

    }

    void main()

    {

    uint8_t rssi = 0; 
    
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART    = 1;
      
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {} 
    

    radio_init();

    while(true) 
    {
        rssi = radio_rssi_get();
    }
    

    }

Children
No Data
Related