Monitor backup battery (VBAT) using LVD

Hi, I want to monitor the backup battery voltage (VBAT) on an RA6M5 with FSP-5.1. I added the LVD stack to the project but I see BSP_FEATURE_LVD_HAS_EXT_MONITOR is disabled everywhere.
1. How can I enable it?
2. Also, should I select Monitor Number 1 or 2?

regards
Johann

Parents
  • Hello,

    The LVD module can only monitor the VCC pin - not VBATT pin.

    The battery backup function should be used after the voltage monitor 0 reset is enabled (OFS1.LVDAS bit is 0).
    Voltage monitor 0 level should be higher than VBATT switch level.

    The LVD module only supports configuring voltage monitor 1 and voltage monitor 2. Voltage monitor 0 can be configured by setting the appropriate bits in the OFS1 register. This means that voltage monitor 0 settings cannot be changed at runtime.

    Regards

  • Hi.
    Thanks for the information.
    - My voltage monitor 0 reset is enabled (attached).
    - The voltage monitor 0 level was already 2.8V and the level for V(BATTSW) is 2.7V, so it is higher.

    According to my understanding of the section "Battery Backup Function" in the manual, I must:
    - set bit0 of VBATTMNSEL to enable VBATT low voltage detect function.
    - I check if the battery is low by reading bit0 of VBATTMON.
    - I leave VBTICTLR unchanged (bits VCH0INEN=0, VCH1INEN=0, VCH2INEN=1). I already use input capture on the RTC (via P404) and it works.

    QUESTIONS:
    1.  I currently try to set VBATTMNSEL with the code below, but it gets stuck on the 1st while loop and never actually sets the bit0.  What is the trick to set it?

    2.  I cannot find a setting for VBATTMNSEL in the configuration.xml file or FSP API, is this correct?

    3. Only R_SYSTEM->VBTICTLR is set up in R_BSP_Init_RTC() and bsp_vbatt_init(), and not the other related Battery Backup registers like VBATTMNSEL. Is this a bug?

    4.  I don't see the battery-low interrupt (VBTLVDICR) in the configuration.xml view. Do I also need to set this up manually like VBATTMNSEL?

    5. Do you have an example code for low-battery detection as I don't see it in the example projects for RA6M5?

     

    bool b_battbak_init(void)
    {
      R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_OM_LPC_BATT);
      //R_SYSTEM->VBTICTLR |= (uint8_t) (1U << vbatt_index);
      R_SYSTEM->VBATTMNSELR_b.VBATTMNSEL = 1; //VBATT Low Voltage Detect Function Select Bit
      while(R_SYSTEM->VBATTMNSELR_b.VBATTMNSEL != 1) { };
      
      R_SYSTEM->VBTLVDICR_b.VBTLVDIE = 1; //VBATT Pin Low Voltage Detect Enable Bit
      while(R_SYSTEM->VBTLVDICR_b.VBTLVDIE != 1) { };
      
      R_BSP_RegisterProtectEnable(BSP_REG_PROTECT_OM_LPC_BATT);
      return true;
    }

  • Hello,

    Please try this to change the VBATTMNSEL bit. The PCR3 bit needs to be 1 to enable write.

        //Set the PRCR.PRC3 bit to 1 (write enabled)
        R_SYSTEM->PRCR = 0xA508 ;
    
        R_SYSTEM->VBATTMNSELR_b.VBATTMNSEL = 1; //VBATT Low Voltage Detect Function Select Bit
        while(R_SYSTEM->VBATTMNSELR_b.VBATTMNSEL != 1);
    
        //Set the PRCR.PRC3 bit to 0 (write disabled)
        R_SYSTEM->PRCR = 0xA500 ;

    There is no VBTLVDICR register on RA6M5 because the Battery Backup function does not support VBATT pin low voltage detection as other devices do (for example RA4M1).

    The Battery Backup Function on RA6M5 supports only:

    - Battery power supply switch
    - Backup registers
    - Time capture pin detection

    Do you want to monitor VBATT pin or just switch to VBATT when VCC drops ? 

Reply
  • Hello,

    Please try this to change the VBATTMNSEL bit. The PCR3 bit needs to be 1 to enable write.

        //Set the PRCR.PRC3 bit to 1 (write enabled)
        R_SYSTEM->PRCR = 0xA508 ;
    
        R_SYSTEM->VBATTMNSELR_b.VBATTMNSEL = 1; //VBATT Low Voltage Detect Function Select Bit
        while(R_SYSTEM->VBATTMNSELR_b.VBATTMNSEL != 1);
    
        //Set the PRCR.PRC3 bit to 0 (write disabled)
        R_SYSTEM->PRCR = 0xA500 ;

    There is no VBTLVDICR register on RA6M5 because the Battery Backup function does not support VBATT pin low voltage detection as other devices do (for example RA4M1).

    The Battery Backup Function on RA6M5 supports only:

    - Battery power supply switch
    - Backup registers
    - Time capture pin detection

    Do you want to monitor VBATT pin or just switch to VBATT when VCC drops ? 

Children