AnsweredAssumed Answered

Accessing VBAT register file hard faults K22 with KSDK 2.4.1

Question asked by Lucas Magasweran on Apr 10, 2019
Latest reply on Apr 10, 2019 by Robin_Shen

Attempting to access RFVBAT->REG[0] hard faults my K22 (with KSDK 2.4.1).

 

I've used the VBAT register file before on previous designs with different Kinetis parts (KL27). I know it is supported by the K22 from the reference manual.

 

The only difference is my current design doesn't have VBAT connected but that should still allow me to read/write the register (and see that values are not preserved). I read in "Kinetis Quick Reference User Guide, Rev. 3, 05/2014" section 5.1.2.1 that "If VBAT supply is not present, then accesses to the RTC registers may not occur and could result in a core-lockup type reset in the MCU.", is the same true for the VBAT register file RFVBAT?

 

I've tried accessing the first 32-bit register directly and via the REG[8] array. Both hard fault.

 

// from MK22F51212.h
typedef struct {
  __IO uint32_t REG[8];
} RFVBAT_Type;
#define RFVBAT_BASE                              (0x4003E000u)
#define RFVBAT                                   ((RFVBAT_Type *)RFVBAT_BASE)

#if FSL_FEATURE_SOC_RFVBAT_COUNT
#define VBAT_REG (*((unsigned int*)RFVBAT_BASE))
uint32_t vbat_reg()
{
     RFVBAT_Type *base = RFVBAT;
     uint8_t reg = 0;
     uint32_t val;

     val = VBAT_REG;
     val = base->REG[reg];

     return val;
}
#endif

 

  1. How should I troubleshoot this?
  2. Is there a peripheral clock I need to enable? I don't see one for the RFVBAT in fsl_clocks.h.
  3. Do I need to configure the AIPS-Lite Peripheral Bridge in order to access the VBAT register file on slot 62? As a test, I tried accessing the FlexTimer (FTM0) on slot 56 and it worked.

Outcomes