BusFault at 0x4004B020 on FS32K144W

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BusFault at 0x4004B020 on FS32K144W

Jump to solution
2,576 Views
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 Kudos
Reply
1 Solution
2,489 Views
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

View solution in original post

0 Kudos
Reply
13 Replies
2,531 Views
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 Kudos
Reply
2,507 Views
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

 

Tags (1)
0 Kudos
Reply
2,370 Views
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 Kudos
Reply
2,346 Views
ArkAndyFraser
Contributor III

@Robin_Shen Thanks

Andy

0 Kudos
Reply
2,490 Views
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 Kudos
Reply
2,465 Views
ArkAndyFraser
Contributor III

@Robin_Shen Many thanks, this is now working

Best Regards

Andy

0 Kudos
Reply
2,457 Views
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 Kudos
Reply
2,456 Views
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 Kudos
Reply
2,500 Views
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 Kudos
Reply
1,462 Views
ArkAndyFraser
Contributor III

Okay, so I have come back to the FS32K144 processor again and created a new project and I am again seeing a crash when initializing the I/O ports.

I have ensured that the SPLL and crystal clock paths are disabled and ensured the UARTS use the FIRC clock.

I have tried initializing the clock with:

    CLOCK_SYS_Init( g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT );
    CLOCK_SYS_UpdateConfiguration( 0U, CLOCK_MANAGER_POLICY_AGREEMENT );

 and with:

CLOCK_DRV_Init( &clockMan1_InitConfig0 );

but the code is still crashing in:

PINS_DRV_Init( NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0 );

with a Possible BusFault location: 0x40049000. 

If I comment out the above pin initialization code and go on to initialize the UART with:

LPUART_DRV_Init( lpUSBUartInstance, lpUSBUartState, lpUSBUartInitConfig );

I get: An imprecise (asynchronous) data access error has occurred. 

My clock configuration is:

ArkAndyFraser_0-1718655475567.png

I could really use some help getting to the bottom of this as I am on a tight deadline to get a project shipped.

Best Regards

Andy

0 Kudos
Reply
1,426 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

https://community.nxp.com/t5/S32-SDK/SDK-problem-in-S32-Design-Studio-for-ARM-2-2/m-p/986190 Here you can find some information between CLOCK_DRV_Init and CLOCK_SYS_Init.

What's the version of S32K1xx SDK are you using? Please refer to the CLOCK_DRV_Init usage in hello_world_s32k144 of S32K1xx SDK RTM v4.0.3 Example Projects.

0 Kudos
Reply
1,415 Views
ArkAndyFraser
Contributor III

@Robin_Shen I am using SDK version 4.0.3.

I compared my configuration with a previous project that was working and noticed that I had set a flash clock divider of 4 to set the flash clock to 12MHz - in this current project is was a divisor of 2 (24MHz). Now that I have dropped the flash clock to 12MHz, it seems to be working.

Does this make sense? Is 24MHz too high for the flash memory?

ArkAndyFraser_0-1718717818017.png

 

Andy

 

0 Kudos
Reply
1,399 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Table 26. Device clock specifications fFlash Flash clock S32K14xW.png

0 Kudos
Reply