BusFault at 0x4004B020 on FS32K144W

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

BusFault at 0x4004B020 on FS32K144W

跳至解决方案
1,082 次查看
ArkAndyFraser
Contributor III

So, this is a similar issue as I have seen before which appeared to be down to a poorly soldered crystal. However, this board does not use an external crystal and the clock has been set to use FIRC.

I have configured all my clocks, peripherals and pins and then initialise them in a function. 

	//
	// Setup the clocks.
	//
	CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
	CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

	//
	// Setup the I/O pins.
	//
	PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);

	//
	// Setup the UART.
	//
	LPUART_DRV_Init(lpUartInstance, lpUartState, lpUartInitConfig);
	LPUART_DRV_InstallRxCallback(lpUartInstance, rxCallback, NULL);

As soon as the code calls the PINS_DRV_Init, the processor crashes with a bus fault.

NUM_OF_CONFIGURED_PINS0 holds 8 and g_pin_mux_InitConfigArr0 looks like:

/* clang-format off */
/*
 * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
BOARD_InitPins:
- options: {callFromInitBoot: 'true', coreID: core0}
- pin_list:
  - {pin_num: '38', peripheral: ADC0, signal: 'se, 0', pin_signal: PTA0}
  - {pin_num: '40', peripheral: CAN1, signal: 'rxd, rxd', pin_signal: PTC6}
  - {pin_num: '39', peripheral: CAN1, signal: 'txd, txd', pin_signal: PTC7}
  - {pin_num: '41', peripheral: PORTA, signal: 'port, 13', pin_signal: PTA13, direction: OUTPUT}
  - {pin_num: '17', peripheral: LPUART0, signal: rxd, pin_signal: PTC2}
  - {pin_num: '16', peripheral: LPUART0, signal: txd, pin_signal: PTC3, direction: OUTPUT}
  - {pin_num: '42', peripheral: PORTA, signal: 'port, 12', pin_signal: PTA12, direction: OUTPUT}
  - {pin_num: '35', peripheral: PORTA, signal: 'port, 3', pin_signal: PTA3, direction: OUTPUT}
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
 */
/* clang-format on */

/* Generate array of configured pin structures */
pin_settings_config_t g_pin_mux_InitConfigArr0[NUM_OF_CONFIGURED_PINS0] = {
    {
        .base            = PORTA,
        .pinPortIdx      = 0U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_PIN_DISABLED,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = NULL,
        .digitalFilter   = false,
    },
    {
        .base            = PORTA,
        .pinPortIdx      = 12U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_AS_GPIO,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = PTA,
        .direction       = GPIO_OUTPUT_DIRECTION,
        .digitalFilter   = false,
        .initValue       = 0U,
    },
    {
        .base            = PORTA,
        .pinPortIdx      = 13U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_AS_GPIO,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = PTA,
        .direction       = GPIO_OUTPUT_DIRECTION,
        .digitalFilter   = false,
        .initValue       = 0U,
    },
    {
        .base            = PORTA,
        .pinPortIdx      = 3U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_AS_GPIO,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = PTA,
        .direction       = GPIO_OUTPUT_DIRECTION,
        .digitalFilter   = false,
        .initValue       = 0U,
    },
    {
        .base            = PORTC,
        .pinPortIdx      = 2U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_ALT4,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = NULL,
        .digitalFilter   = false,
    },
    {
        .base            = PORTC,
        .pinPortIdx      = 3U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_ALT4,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = NULL,
        .digitalFilter   = false,
    },
    {
        .base            = PORTC,
        .pinPortIdx      = 6U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_ALT3,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = NULL,
        .digitalFilter   = false,
    },
    {
        .base            = PORTC,
        .pinPortIdx      = 7U,
        .pullConfig      = PORT_INTERNAL_PULL_NOT_ENABLED,
        .driveSelect     = PORT_LOW_DRIVE_STRENGTH,
        .passiveFilter   = false,
        .mux             = PORT_MUX_ALT3,
        .pinLock         = false,
        .intConfig       = PORT_DMA_INT_DISABLED,
        .clearIntFlag    = false,
        .gpioBase        = NULL,
        .digitalFilter   = false,
    },
};

If I step through the code with the debugger, it gets to:

    for (i = 0U; i < pinCount; i++)
    {
        PINS_Init(&config[i]);
    }

And on the first iteration of the above loop it crashes in here:

void PINS_Init(const pin_settings_config_t * config)
{
    DEV_ASSERT(config->base != NULL);
    DEV_ASSERT((PORT_MUX_AS_GPIO != config->mux) || (config->gpioBase != NULL));
    DEV_ASSERT(config->pinPortIdx < PORT_PCR_COUNT);
    uint32_t regValue = config->base->PCR[config->pinPortIdx];
    uint32_t directions;
    uint32_t digitalFilters;
    port_mux_t muxing;

On the line 

uint32_t regValue = config->base->PCR[config->pinPortIdx];

config->base holds 0x40049000 which I think is correct for port A and pinPortIdx holds 0.

Can anyone please help ?

Andy

0 项奖励
1 解答
995 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

I try to disable crystal and SPLL of lpuart_s32k144w and select FIRC as clock source of LPUART. It will not enter fault.

disable SOSC SPLL S32K144W.png

在原帖中查看解决方案

0 项奖励
9 回复数
1,037 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Andy,

It seems that the clock gate of PORTA is not enabled, so accessing the register of PORTA will cause fault.

Please call CLOCK_DRV_Init(&clockMan1_InitConfig0); instead of call CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE); 


Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 项奖励
1,013 次查看
ArkAndyFraser
Contributor III

Robin, thank you for your help.

Unfortunately, it now crashes while setting up the clock.

The stack trace looks like:

ArkAndyFraser_0-1695282307949.png

I get a "Possible BusFault location: 0x690B3A11" with the call to:

CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);

Interestingly, in another project I have, I use CLOCK_SYS_Init and it works fine.

I actually love the way S32DS allows you to configure the peripherals and I/O and generate all the code for you however, it would be nice if it generated a file which did all this initialisation for us.

Andy

 

标记 (1)
0 项奖励
876 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

When you call CLOCK_DRV_Init, you don't need to callCLOCK_SYS_Init and CLOCK_SYS_UpdateConfiguration anymore.

0 项奖励
852 次查看
ArkAndyFraser
Contributor III

@Robin_Shen Thanks

Andy

0 项奖励
996 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

I try to disable crystal and SPLL of lpuart_s32k144w and select FIRC as clock source of LPUART. It will not enter fault.

disable SOSC SPLL S32K144W.png

0 项奖励
971 次查看
ArkAndyFraser
Contributor III

@Robin_Shen Many thanks, this is now working

Best Regards

Andy

0 项奖励
963 次查看
ArkAndyFraser
Contributor III

Okay, I was too quick to say it is fixed

I added a simple line to my main function and rebuilt and it is crashing setting up the oscillators again.

ArkAndyFraser_0-1695325833441.png

The line I added was:

LPUART_DRV_SendDataBlocking(lpUartInstance, (uint8_t *)oneSecondMsg, strlen(oneSecondMsg), TIMEOUT);

But it does not even get there as it fails right at the start of my code when I initialise the clock and peripherals. This is really, really frustrating.

0 项奖励
962 次查看
ArkAndyFraser
Contributor III

Here is my clock configuration:

ArkAndyFraser_0-1695325975419.png

And pins:

ArkAndyFraser_1-1695326007139.png

 

And peripherals:

ArkAndyFraser_2-1695326038294.png

 

0 项奖励
1,006 次查看
ArkAndyFraser
Contributor III

Interestingly, sometimes when I single step, it gets through CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE) fine but then crashes as per the original way when PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0) is called !

Andy

0 项奖励