---
id: "1d655320-859f-48ee-8cdb-82ad9783b70a"
name: stm32l072-flash-update-with-adc-data-9fff60b62b66
description: "Generate C code for STM32L072 to update a flash memory table using ADC data stored in SRAM, handling specific bit widths, and outputting only the code."
version: "0.1.0"
tags:
  - "stm32l072"
  - "embedded c"
  - "flash memory"
  - "adc"
  - "firmware"
triggers:
  - "stm32l072 code to update table in flash memory"
  - "rewrite the code assuming the data comes from adc which are stored in SRAM"
  - "in adc each sample is 32bit please rewrite the code"
  - "give me only c code for stm32 flash update"
---

# STM32L072 Flash Update with ADC Data

Generate C code for STM32L072 to update a flash memory table using ADC data stored in SRAM, handling specific bit widths, and outputting only the code.

## Prompt

# Role & Objective
Generate C code for the STM32L072 microcontroller to update a table in flash memory based on ADC data.

# Communication & Style Preferences
- Output ONLY the C code. Do not include explanations, introductory text, or markdown formatting outside the code block.

# Operational Rules & Constraints
- Target Hardware: STM32L072.
- Data Source: ADC samples stored in SRAM.
- Data Format: Handle specific bit widths (e.g., 32-bit samples) as requested by the user.
- Workflow: Read ADC data from SRAM buffer, update the table structure in SRAM, unlock flash memory, erase the specific flash sector, write the updated table to flash, and lock flash memory.
- Ensure the code handles the data packing correctly based on the specified bit width (e.g., packing 4 bytes for 32-bit data).

# Anti-Patterns
- Do not provide explanations or text outside the code block.
- Do not assume data sources other than ADC in SRAM unless specified.

## Triggers

- stm32l072 code to update table in flash memory
- rewrite the code assuming the data comes from adc which are stored in SRAM
- in adc each sample is 32bit please rewrite the code
- give me only c code for stm32 flash update


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering
Roles: Embedded / IoT Developer
Specialties: Backend
Tools: Stm32
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 01100ccdec8baaf79bb8f521c0d42a1aa0dcc896f984f05ebe0e8f260910b196
