Skip to content

STM32H503xx analogWrite() error infinite loop due to ICACHE config #2480

Closed
@LightningStalker

Description

@LightningStalker

Call to analogWrite() on DAC pin fail since AnalogWrite() called HAL_DAC_ConfigCannel() it tries read of PACKAGE_BASE ln# 1315.

  if ((*(tmp_package) & 0x1FUL) == 0x0FUL)

Invalid data read due to ICACHE in the way.
Detail at
(https://community.st.com/t5/stm32-mcus/how-to-avoid-a-hardfault-when-icache-is-enabled-on-the-stm32h5/ta-p/630085)
(https://github.com/orgs/stm32duino/discussions/2383#discussioncomment-10325580)
Test evaluates TRUE and MCU enters error loop.
stm32duino handling ICACHE configuration setups and so probably address there.

To Reproduce

void setup() {
    pinMode(PA4, OUTPUT);
    Serial.begin(9600);
}
void loop() {
    Serial.println(dac_value);
    analogWrite(PA4, dac_value);
    dac_value = (dac_value < 4095) ? (16 + dac_value) : 0;
}

Steps to reproduce the behavior:

  1. Upload code to Nucleo
  2. Watch serial

Expected behavior
PA4 voltage change, numbers on serial

Desktop

  • OS: Linux
  • Arduino IDE version: 2.3.2
  • STM32 core version: 2.8.1
  • Tools menu settings if not the default: Default Nucleo64 H503RB
  • Upload method: SWD

Board

  • Name: NUCLEO-H503RB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions