This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem facing with RSSI value in nRF51822

Hi,

I am new to nRF microcontroller and communication . currently, I am working on nRF51822 microcontroller. I am able to communicate between two nRF51822 microcontrollers(without any protocol stack).

I want to measure RSSI value. I got RSSI new 1test.ccode from the nordic website. When I integrated RSSI code with my code, I got constant RSSI value that is 46. I didn't know what is the mistake. I have attached my code with this.

Parents
  • You will need to start the RSSI in while (NRF_RADIO->EVENTS_END == 0U), and then read the RRSI in if(NRF_RADIO->CRCSTATUS == 1U) in read_packet().

    Code:

    /**@brief Function for reading packet.
     */
    uint32_t read_packet()
    {
        uint32_t result = 0;
        uint8_t rssi_sample;
        
        NRF_RADIO->EVENTS_READY = 0U;
        // Enable radio and wait for ready
        NRF_RADIO->TASKS_RXEN = 1U;
    
        while (NRF_RADIO->EVENTS_READY == 0U)
        {
            // wait
        }
        
        NRF_RADIO->EVENTS_END = 0U;
        // Start listening and wait for address received event
        
        NRF_RADIO->TASKS_START = 1U;
            
        // Wait for end of packet or buttons state changed
        
        while (NRF_RADIO->EVENTS_END == 0U)
        {
            NRF_RADIO->TASKS_RSSISTART = 1;
            // wait
        }
    
        if (NRF_RADIO->CRCSTATUS == 1U)
        {
            result = packet;
            rssi_sample = NRF_RADIO->RSSISAMPLE;
            NRF_RADIO->TASKS_RSSISTOP = 1;
        }
        
        //NRF_LOG_INFO("rssi is: %d\r\n", (unsigned int)rssi_sample);
        printf("rssi is: %d\r\n", (unsigned int)rssi_sample);
        
        NRF_RADIO->EVENTS_DISABLED = 0U;
        // Disable radio
        NRF_RADIO->TASKS_DISABLE = 1U;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // wait
        }
        return result;
    }
    
Reply
  • You will need to start the RSSI in while (NRF_RADIO->EVENTS_END == 0U), and then read the RRSI in if(NRF_RADIO->CRCSTATUS == 1U) in read_packet().

    Code:

    /**@brief Function for reading packet.
     */
    uint32_t read_packet()
    {
        uint32_t result = 0;
        uint8_t rssi_sample;
        
        NRF_RADIO->EVENTS_READY = 0U;
        // Enable radio and wait for ready
        NRF_RADIO->TASKS_RXEN = 1U;
    
        while (NRF_RADIO->EVENTS_READY == 0U)
        {
            // wait
        }
        
        NRF_RADIO->EVENTS_END = 0U;
        // Start listening and wait for address received event
        
        NRF_RADIO->TASKS_START = 1U;
            
        // Wait for end of packet or buttons state changed
        
        while (NRF_RADIO->EVENTS_END == 0U)
        {
            NRF_RADIO->TASKS_RSSISTART = 1;
            // wait
        }
    
        if (NRF_RADIO->CRCSTATUS == 1U)
        {
            result = packet;
            rssi_sample = NRF_RADIO->RSSISAMPLE;
            NRF_RADIO->TASKS_RSSISTOP = 1;
        }
        
        //NRF_LOG_INFO("rssi is: %d\r\n", (unsigned int)rssi_sample);
        printf("rssi is: %d\r\n", (unsigned int)rssi_sample);
        
        NRF_RADIO->EVENTS_DISABLED = 0U;
        // Disable radio
        NRF_RADIO->TASKS_DISABLE = 1U;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // wait
        }
        return result;
    }
    
Children
No Data
Related