Skip to content

Fix LPUART1 ISR priority override causing FreeRTOS assert in boost mode#7

Draft
Copilot wants to merge 13 commits intospecfrom
copilot/nl-spec-implementation
Draft

Fix LPUART1 ISR priority override causing FreeRTOS assert in boost mode#7
Copilot wants to merge 13 commits intospecfrom
copilot/nl-spec-implementation

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 11, 2026

HW_TRACER_EMB_StartRX() hardcodes LPUART1 NVIC priority to 3, silently overriding the compliant priority-5 set in HW_TRACER_EMB_Init(). When LPUART1 RXNE fires (e.g. STM32CubeMonitor response during active USB-PD trace traffic), GUI_CALLBACK_RX() calls osMessageQueuePut() from priority-3 context — below configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY = 5 — triggering vPortValidateInterruptPriority assert → taskDISABLE_INTERRUPTS() + for(;;). In boost mode this manifests as a hung default task with HRTIM still switching (priority 1 unaffected by BASEPRI=0x50); in buck mode there is no inbound LPUART traffic so the assert never fires and the system runs normally.

Changes

  • tracer_emb_hw.cHW_TRACER_EMB_StartRX(): replace hardcoded priority 3 with TRACER_EMB_TX_IRQ_PRIORITY (defined as 5 in tracer_emb_conf.h), consistent with the priority already set in HW_TRACER_EMB_Init().
// Before
NVIC_SetPriority(TRACER_EMB_USART_IRQ, 3);

// After
NVIC_SetPriority(TRACER_EMB_USART_IRQ, TRACER_EMB_TX_IRQ_PRIORITY);

TRACER_EMB_TX_IRQ_PRIORITY = 5 sits exactly at the FreeRTOS syscall ceiling, so osMessageQueuePut() in GUI_CALLBACK_RX() is now called from a compliant ISR priority in both modes.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 11, 2026 19:46
…, adc_monitor, pd_interface modules)

Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
… constant, HRTIM reconfigure)

Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement NLSpec based on generated code and project spec NLSpec Implementation: Buck-Boost Regulator Firmware Mar 11, 2026
@electricalhog electricalhog requested a review from TG-Techie March 11, 2026 20:32
Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
Copilot AI changed the title NLSpec Implementation: Buck-Boost Regulator Firmware Bootstrap reset, TIM7 IRQ fix, HRTIM bit corrections, default test task Mar 13, 2026
Copilot AI requested a review from electricalhog March 13, 2026 18:36
#define PIN_OUTPUT_DIS_PIN GPIO_PIN_9

/* =========================================================================
* SECTION 6: HRTIM TIMING CONSTANTS
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timer constants should be compiled from time-based calculations instead of assuming a period count

* Called from HAL_ADC_ConvCpltCallback. Reads adc1_dma_buffer and updates
* adc_measurements.v_out_mv, i_inductor_ma, i_out_ma, i_in_ma.
*
* May also be called directly from the PID ISR for a synchronous read.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice feature for grabbing vales off the buffer

Comment on lines +42 to +57
/**
* PidConfig — tuning coefficients and execution parameters.
*
* These values are runtime-mutable (§8.7): they may be written from the
* debug interface without stopping the regulator. The PID ISR reads them
* on every execution cycle.
*/
typedef struct
{
float kp; /**< Proportional gain. Default 1.0 (§8.7). */
float ki; /**< Integral gain. Default 100.0 (§8.7). */
float kd; /**< Derivative gain. Default 0.0 (§8.7). */
float dt_seconds; /**< Execution period in seconds. Default 50 µs. */
float output_min; /**< Minimum clamped output (PID_OUTPUT_MIN). */
float output_max; /**< Maximum clamped output (PID_OUTPUT_MAX). */
} PidConfig;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely placed at the top

* 1. Reconfigure HRTIM output fault levels to INACTIVE (all FETs off on
* fault). CubeMX sets FaultLevel = NONE; this corrects it (§5.5).
* 2. Enable FLT1 and FLT2 fault response on Timer A and Timer B.
* 3. Configure backstop Compare 1 registers on Timer A and Timer B (§10.3).
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update compare for blanking and backstop

Comment on lines +45 to +49
typedef enum
{
SLOPE_COMP_MODE_BUCK = 0, /**< Buck: downslope = V_out / L */
SLOPE_COMP_MODE_BOOST = 1 /**< Boost: downslope = (V_out − V_in) / L */
} SlopeCompMode;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could reference the other mode type

Comment on lines +287 to +294
if (regulator_mode == REGULATOR_MODE_BUCK)
{
hrtim_apply_buck_mode_static_leg();
}
else
{
hrtim_apply_boost_mode_static_leg();
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs future-proofing for buck-boost

HAL_HRTIM_WaveformOutputStart(&hhrtim1,
HRTIM_OUTPUT_TB1 | HRTIM_OUTPUT_TB2);
}
else /* BOOST */
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not always boost, may be 4-switch later

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to implement external event blanking using compare 1, so increasing index of backstop and bootstrap is necessary.

…log ring buffer

Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
Copilot AI changed the title Bootstrap reset, TIM7 IRQ fix, HRTIM bit corrections, default test task HRTIM CMP reassignment (blanking/backstop/bootstrap), debug_log ring buffer, fix CMake sources Mar 14, 2026
Copilot AI requested a review from electricalhog March 14, 2026 19:10
…LPUART1/DMA 3/0→5

Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
Copilot AI changed the title HRTIM CMP reassignment (blanking/backstop/bootstrap), debug_log ring buffer, fix CMake sources Fix FreeRTOS ISR priority violations causing configASSERT at port.c:754 Mar 14, 2026
… immediate VIN_RANGE fault

Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
Copilot AI changed the title Fix FreeRTOS ISR priority violations causing configASSERT at port.c:754 Fix wrong BOOST mode selection on first regulator_start() due to stale v_in_mv=0 Mar 15, 2026
Copilot AI changed the title Fix wrong BOOST mode selection on first regulator_start() due to stale v_in_mv=0 Fix LPUART1 ISR priority override causing FreeRTOS assert in boost mode Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants