Accessing VBAT register file hard faults K22 with KSDK 2.4.1

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Accessing VBAT register file hard faults K22 with KSDK 2.4.1

跳至解决方案
1,184 次查看
lucasrangit
Contributor III

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.
标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,035 次查看
mjbcswitzerland
Specialist V

Hi Lucas

Attempted access to RTC registers using VBAT will result in a hard fault if the VBAT is below its threshold (or not present).

See the following: How to detect if VBAT supply is present for RTC to work? 

In the uTasker project the following is used to test VBAT presence in operation to avoid needing to recover from a hard fault when the battery is not present, is removed during operation or its voltage drops below its lower limit. [A DMA read failure is easy to recover from]

            unsigned long ulRegCopy;
            POWER_UP_ATOMIC(6, RTC);                                     // ensure the RTC is powered
            if (DMA_ERROR_OCCURRED == fnConfigDMA_buffer(4, 0, sizeof(ulRegCopy), (void *)RTC_BLOCK, &ulRegCopy, (DMA_DIRECTION_INPUT | DMA_LONG_WORDS | DMA_SINGLE_CYCLE | DMA_FIXED_ADDRESSES | DMA_SW_TRIGGER_WAIT_TERMINATION), 0, 0)) { // configure the transfer, start and wait for termination
                // RTC cannot be accessed - probably due to missing VBAT voltage
                // - avoid RTC access
            }
            else {
                // ulRegCopy has the present RTC_TSR content, meaning that the RTC could be accessed
                //
                fnStartRTC(0);                                           // start the RTC if it isn't yet operating
            }

Regards

Mark


Complete Kinetis solutions, training and support: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html

RTC and time keeping: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,034 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

As Mark said, you need apply power to the VBAT pin.

Best Regards,

Robin

0 项奖励
回复
1,036 次查看
mjbcswitzerland
Specialist V

Hi Lucas

Attempted access to RTC registers using VBAT will result in a hard fault if the VBAT is below its threshold (or not present).

See the following: How to detect if VBAT supply is present for RTC to work? 

In the uTasker project the following is used to test VBAT presence in operation to avoid needing to recover from a hard fault when the battery is not present, is removed during operation or its voltage drops below its lower limit. [A DMA read failure is easy to recover from]

            unsigned long ulRegCopy;
            POWER_UP_ATOMIC(6, RTC);                                     // ensure the RTC is powered
            if (DMA_ERROR_OCCURRED == fnConfigDMA_buffer(4, 0, sizeof(ulRegCopy), (void *)RTC_BLOCK, &ulRegCopy, (DMA_DIRECTION_INPUT | DMA_LONG_WORDS | DMA_SINGLE_CYCLE | DMA_FIXED_ADDRESSES | DMA_SW_TRIGGER_WAIT_TERMINATION), 0, 0)) { // configure the transfer, start and wait for termination
                // RTC cannot be accessed - probably due to missing VBAT voltage
                // - avoid RTC access
            }
            else {
                // ulRegCopy has the present RTC_TSR content, meaning that the RTC could be accessed
                //
                fnStartRTC(0);                                           // start the RTC if it isn't yet operating
            }

Regards

Mark


Complete Kinetis solutions, training and support: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html

RTC and time keeping: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

0 项奖励
回复