cancel
Showing results for 
Search instead for 
Did you mean: 

osKernelStart faults to HardFault handler

DaveBy2
Associate

Hi All

I working on a data logger code.   It is basic at the moment. 

1, set a an ISRTimmer for 1sec.

2, When ISR triggered set a read bit in Datalogger register i set up.

3, Next loop thru main i test Datalogger register, if set go to a function and read A0, A1 ports and store back into an array i have set up.

Every time i run this code it completes 5 susessful looit always crashes on the 6th loop in the same spot reading A1.

The Fault has the same sequence.  1, call A1 read, 2, straight to HardFault_Handler.  According to the stack it happen straight after the osKernalStart (see attached pic).

I was wondering if this is an ISRtimmer confilct with ADC issue?

Any tips would be greatly appreciated

Set Up;

Portenta H7 (STMH7), VS Code using PIO

 

1 REPLY 1
nouirakh
ST Employee

Hello  @DaveBy2 

Since the crash always occurs on the 6th iteration when reading from A1,  and considering the sequence you've described, could you please verify these points:

  • ISR and ADC conflict: 

    If the ADC read is not properly synchronized with the ISR, it could cause a conflict.

    • Synchronization: Make sure that the ADC is not being accessed from both the ISR and the main loop simultaneously.
    • ADC Configuration: Verify that the ADC is properly configured before each read, and that it is not being reconfigured or shut down by the ISR. Make sure other peripherals are not interfering with the ADC operation.

     

  • Interrupt priority: 

    If the priority of the ISR is not set correctly, it might interfere with the operation of other critical system functions.

    • Priority Configuration: Check the priority level of the ISR and ensure it is set to an appropriate level that does not interfere with other system operations, especially if you're using an RTOS. If you're using an RTOS, ensure that the ADC read is properly managed within the RTOS's scheduling and resource management mechanisms.

     

  • Hardware Issues: 

    It's possible there's a hardware issue with the A1 pin or the ADC channel associated with it.

    • Test Hardware: Try reading from a different analog pin to see if the issue persists.
    • Inspect Hardware: Look for any signs of damage or improper connections on the A1 pin.

     

Try to simplify your ISR to the bare minimum to see if the problem still occurs. Start with the simplest and most likely causes, and work your way through the possibilities systematically.
If the problem persists, please provide more details on your setting project if possible, attach a ZIP file of your project configuration.