nrf21540 Program UICR EFUSE problem

Hi, 

I have problem with program nrf21540 UICR EFUSE. The first time, WR-UICR was able to successfully write, and after reset the reading of reg0 displayed correctly. But the second attempt to write WR-UICR failed, and after reset, reading reg0 is the value written in the first attempt.

so,May I ask if the nrf21540 gain adjustment can only be set once? 

thanks.

my code:

//1 read reg 0
data = Spi_Read(0x00);
NRF_LOG_INFO("0x%x",data);
//2 write reg 1,enable uICR
Spi_Write(0x04,0x01);
data = Spi_Read(0x01);
NRF_LOG_INFO("0x%x",data);
nrf_delay_ms(100);
Spi_Write(0xf0,0x01);
data = Spi_Read(0x01);
NRF_LOG_INFO("0x%x",data);
nrf_gpio_pin_set(LED_1);
nrf_delay_ms(100);

//3. write reg3
Spi_Write(0x04,0x03);
nrf_delay_ms(10);
data = Spi_Read(0x03);
NRF_LOG_INFO("reg3--0x%x",data);

//4.write reg 2
Spi_Write(0x81,0x02);
nrf_delay_ms(10);
data = Spi_Read(0x02);
NRF_LOG_INFO("reg2-0x%x",data);
nrf_delay_ms(10);
//5.reset 
PDN_LOW;
nrf_delay_ms(100);
PDN_HIGH;

Parents
  • Hello, as I know, the UICR is typically used for one-time programming, meaning that once you write to certain registers, you cannot change them back to their original state. I think you might want to enhance your code with additional checks and ensure proper sequencing. Here’s an example of how you might structure your code: slope game

    // 1. Read reg 0
    data = Spi_Read(0x00);
    NRF_LOG_INFO("0x%x", data);
    
    // 2. Write reg 1, enable UICR
    Spi_Write(0x04, 0x01);
    data = Spi_Read(0x01);
    NRF_LOG_INFO("0x%x", data);
    nrf_delay_ms(100);
    
    // 3. Check if UICR is enabled before writing
    if (data & 0x01) {
        // 4. Write reg 3
        Spi_Write(0x04, 0x03);
        nrf_delay_ms(10);
        data = Spi_Read(0x03);
        NRF_LOG_INFO("reg3--0x%x", data);
    
        // 5. Write reg 2
        Spi_Write(0x81, 0x02);
        nrf_delay_ms(10);
        data = Spi_Read(0x02);
        NRF_LOG_INFO("reg2-0x%x", data);
        
        // 6. Reset
        PDN_LOW;
        nrf_delay_ms(100);
        PDN_HIGH;
    } else {
        NRF_LOG_ERROR("UICR not enabled. Cannot write.");
    }

Reply Children
No Data
Related