embeded/Cortex-M4 STM2026. 2. 6. 11:15

ART ON/OFF가 보이는데 정작 끄는법이나 켜는 법 혹은 클럭 트리에서 설정법이 안보여서 찾는데..

G4는 아닌 F4 쪽에서는 아래의 명령을 이용해서 켜고 끈다고 한다.

FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;

[링크 : https://community.st.com/t5/stm32-mcus-products/enable-disable-art-accelerator/td-p/551007]

 

 

[링크 : https://www.st.com/resource/en/product_training/STM32G4-Memory-Flash_FLASH.pdf]

 

3.1 Firmware tips and tricks
3.1.1 Common firmware configuration
ART configuration
The ART Accelerator™ is a memory accelerator which is optimized for STM32 ARM® Cortex™-Mx processors. It balances the inherent performance advantage of the ARM Cortex-Mx over Flash memory technologies, which normally requires the processor to wait for the Flash memory at higher operating frequencies. Thanks to the ART Accelerator™, the CPU can operate up to 120 MHz without wait states, thereby increasing the overall system speed and efficiency.
To release the full processor 150 DMIPS performance at this frequency, the accelerator implements an instruction prefetch queue and instruction/data, which enables program execution from Flash memory at up to 120 MHz without wait states.

To avoid extra power consumption it is recommended to configure the ART as follows:
/* Disable prefetch buffer */
 FLASH->ACR & = ~FLASH_ACR_PRFTEN;
/* Enable flash instruction cache */
 FLASH->ACR |= FLASH_ACR_ICEN;
/* Enable flash data cache */
 FLASH->ACR |= FLASH_ACR_DCEN;

The system performance can be adjusted to the current needs. This can be done either from start, according to performance estimations, or on-the-fly on a running system to adjust the performance to the current condition. In this way the prefetch can be enabled or disabled on-the-fly depending on user needs.
Disabling the prefetch buffer avoids extra Flash access that consumes 20 mA for 128-bit line fetching.

[링크 : https://www.st.com/resource/en/application_note/dm00033348.pdf]

 

I read in that document: STMicroelectronics: AN3430 - Application Note of How to achieve the lowest current consumption with STM32F2xx

On page 17 (3.1.1) they say that enabling the buffer prefetch will consume additional 20mA (for 128-bit-line fetching). Maybe at 168 MHz you power supply gets unstable?? Maybe you can try it with lower clock speed (120MHz), where the cpu is very power efficient.

[링크 : https://stackoverflow.com/questions/11358547/how-to-enable-art-accelerator-stm32f407vgt6]

 

그래서 프로젝트에서 검색해보니 이렇게 걸려 나오는데

HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError)
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)

__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_OB_DBankConfig(uint32_t DBankConfig)

HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data)

 

ICEN은 Program 쪽에서는 빠진다. 아무래도 데이터 쪽이라 그런가?

HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError)
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)

__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_OB_DBankConfig(uint32_t DBankConfig)

'embeded > Cortex-M4 STM' 카테고리의 다른 글

stm32g473 flash doubleword  (0) 2026.02.04
STM32G47x dual bank flash  (0) 2026.02.03
STM32F429I-DISC1 with lvgl  (0) 2026.02.03
32F469IDISCOVERY with lvgl  (0) 2026.02.02
UM2195 audio streaming Expansion Package for STM32Cube  (0) 2026.01.05
Posted by 구차니
embeded/Cortex-M4 STM2026. 2. 4. 17:12

일단 코드 상으로는 FAST는 안 먹어서 찾아봐야겠고, doubleword 로만 써진다.

 

일단은 DBANK는 체크되어 있는게 기본값이고

 

bank1에 0802000에 쓰니 쓰여지긴 한데 64bit wide라서 의도한대로 딱딱 붙어있지 않고 4byte씩 띄엄띄엄 써진다.

 

해당 페이지 삭제하려고 했는데 0x0802 0000이 아닌 0x0804 0000 이고

체크하고 삭제하면 삭제되었다고 메시지는 뜨지만

 

정작 해당 위치를 다시 가면 내용이 남아있다.

그 와중에 0x0804 0000 위치로 가면 비어있는걸로 나온다.

 

먼가 이상한데.. 머가 이상한거라고 딱찝어 말하기 힘드네..

 

CubeProgrammer를 버전업해봐야하나? 2.21 버전이 최신이었던것 같은데..

 

2.21.0 흐음... 

[링크 : https://www.st.com/en/development-tools/stm32cubeprog.html]

 

+

웃긴게 sdk 문제인지

bank 2에 page 0 대신

bank 1 에 page 64로 하면 잘된다. 머냐?

'embeded > Cortex-M4 STM' 카테고리의 다른 글

stm32g473 ART accelerator on/off ?  (0) 2026.02.06
STM32G47x dual bank flash  (0) 2026.02.03
STM32F429I-DISC1 with lvgl  (0) 2026.02.03
32F469IDISCOVERY with lvgl  (0) 2026.02.02
UM2195 audio streaming Expansion Package for STM32Cube  (0) 2026.01.05
Posted by 구차니
embeded/Cortex-M4 STM2026. 2. 3. 17:58

플래시가 연속된 주소가 아니게 보인다.

63번 0x0801 F800

64번 0x0804 0000 신기하네..

 

Option Byte 에는 BFB2 / DBANK 등이 처음보는 녀석이고..

 

내용은 좀 더 봐야 할 듯.

ART/MIF 를 통해서 NVM Bank 1 / 2에 접근하는거라면.. ART를 그럼 사실상 강제하게 되는건가?

 

서로 다른 채널에 read / write 를 동시에 할 수 있다가 dual bank 의 장점인가?

The dual bank memory can be configured and used as a single large NVM block with continuous addressing (with few exceptions, not covered in this document). There are significant advantages when the NVM is configured to serve as two parallel blocks, the most important is the possibility to write on one bank without interrupting reading (and fetching instructions) from the other bank. This is the most important prerequisite to perform the updates without breaking the execution of the code from the program NVM.

[링크 : https://www.st.com/resource/en/application_note/an4767-onthefly-firmware-update-for-dual-bank-stm32-microcontrollers-stmicroelectronics.pdf]

 

Option byte의 DBANK 설정에 따라서

뱅크를 1개 쓰냐 2개 쓰냐인데

0으로 하면 싱글 뱅크, 4 Kbyte Page * 128 이 되고

1으로 하면 듀얼 뱅크, 2 Kbyte Page * 128 * 2가 되는건가?

 

ART를 켜면 올라가는걸 보면 일단 높은 수치가 성능이 좋은거 같은데,

ART OFF 에서 Single Bank가 성능이 더 좋은다고 보면되나?

[링크 : https://www.st.com/resource/en/product_training/STM32G4-Memory-Flash_FLASH.pdf]

 

+

2026.02.04

심심해서(?) DBANK 풀고

 

내부 플래시 구조를 보니

개별 페이지(?)당 용량은 2배로 늘고

총 페이지는 절반으로 줄어들었다.

'embeded > Cortex-M4 STM' 카테고리의 다른 글

stm32g473 ART accelerator on/off ?  (0) 2026.02.06
stm32g473 flash doubleword  (0) 2026.02.04
STM32F429I-DISC1 with lvgl  (0) 2026.02.03
32F469IDISCOVERY with lvgl  (0) 2026.02.02
UM2195 audio streaming Expansion Package for STM32Cube  (0) 2026.01.05
Posted by 구차니
embeded/Cortex-M4 STM2026. 2. 3. 11:30

그냥 받아서 하니 잘된다.

 

git clone https://github.com/littlevgl/stm32f429_disco_no_os_sw4stm32.git --recurse-submodules

[링크 : https://github.com/lvgl/lv_port_stm32f429_disco]

 

회사에 굴러 다니던게 있었을 줄이야 -_-

[링크 : https://www.st.com/en/evaluation-tools/32f429idiscovery.html]

 

  • Core: Arm® 32-bit Cortex®-M4 CPU with FPU, Adaptive real-time accelerator (ART Accelerator™) allowing 0-wait state execution from flash memory, frequency up to 180 MHz, MPU, 225 DMIPS/1.25 DMIPS/MHz (Dhrystone 2.1), and DSP instructions
  • Memories
    • 512 bytes of OTP memory
    • Up to 2 MB of flash memory organized into two banks allowing read-while-write
    • Up to 256+4 KB of SRAM including 64 KB of CCM (core coupled memory) data RAM
    • Flexible external memory controller with up to 32-bit data bus: SRAM, PSRAM, SDRAM/LPSDR SDRAM, compact flash/NOR/NAND memories
  • LCD parallel interface, 8080/6800 modes
  • LCD-TFT controller with fully programmable resolution (total width up to 4096 pixels, total height up to 2048 lines and pixel clock up to 83 MHz)
  • Chrom-ART Accelerator™ for enhanced graphic content creation (DMA2D)

[링크 : https://www.st.com/en/microcontrollers-microprocessors/stm32f429zi.html]

 

그나저나 main 함수 엄청 단촐하다.

int main(void)
{

HAL_Init();

/* Configure the system clock to 180 MHz */
SystemClock_Config();

/*Start up indication*/
BSP_LED_Init(LED3);
uint32_t i;
for (i = 0; i < 8; i++) {
BSP_LED_Toggle(LED3);
HAL_Delay(50);
}

lv_init();

tft_init();
touchpad_init();

// lv_example_scroll_3();
// lv_example_chart_7();

lv_demo_widgets();

while (1)
{
HAL_Delay(3);
lv_task_handler();
}
}

 

 

빌드하니 생각외로 용량은 적게 나온다. 이미지는 어떻게 처리한거지?

 

'embeded > Cortex-M4 STM' 카테고리의 다른 글

stm32g473 flash doubleword  (0) 2026.02.04
STM32G47x dual bank flash  (0) 2026.02.03
32F469IDISCOVERY with lvgl  (0) 2026.02.02
UM2195 audio streaming Expansion Package for STM32Cube  (0) 2026.01.05
stm32g4 cordic fmac  (0) 2025.11.28
Posted by 구차니
embeded/Cortex-M4 STM2026. 2. 2. 17:55

곧 다뤄보게 될 예정.

STM32F469 high-performance MCUs with ARM®Cortex®-M4 core and Chrom-ART Accelerator™
4 inches 800x480 pixel TFT color LCD with MIPI DSI interface and capacitive touch screen

[링크 : https://www.st.com/en/evaluation-tools/32f469idiscovery.html#overview]

 

spi가 아니라 dsi 라서 걱정했는데 다행히(!) 누군가가 benchmark 포팅해서 올려놔서 좀 날로 먹을수 있을 듯.

[링크 : https://github.com/lvgl/lv_port_stm32f469_disco/tree/master]

'embeded > Cortex-M4 STM' 카테고리의 다른 글

STM32G47x dual bank flash  (0) 2026.02.03
STM32F429I-DISC1 with lvgl  (0) 2026.02.03
UM2195 audio streaming Expansion Package for STM32Cube  (0) 2026.01.05
stm32g4 cordic fmac  (0) 2025.11.28
STM32CubeProgrammer / uart / parity  (0) 2025.11.28
Posted by 구차니
embeded/Cortex-M4 STM2026. 1. 5. 17:46

'embeded > Cortex-M4 STM' 카테고리의 다른 글

STM32F429I-DISC1 with lvgl  (0) 2026.02.03
32F469IDISCOVERY with lvgl  (0) 2026.02.02
stm32g4 cordic fmac  (0) 2025.11.28
STM32CubeProgrammer / uart / parity  (0) 2025.11.28
stm32flash 0.5 0.7 버전과 stm32g473  (0) 2025.11.28
Posted by 구차니
embeded/Cortex-M4 STM2025. 11. 28. 15:50

대충 21페이지에서 발견

3.8 CORDIC
The CORDIC provides hardware acceleration of certain mathematical functions, notably
trigonometric, commonly used in motor control, metering, signal processing and many other
applications.
It speeds up the calculation of these functions compared to a software implementation,
allowing a lower operating frequency, or freeing up processor cycles in order to perform
other tasks.
Cordic features
• 24-bit CORDIC rotation engine
• Circular and Hyperbolic modes
• Rotation and Vectoring modes
• Functions: Sine, Cosine, Sinh, Cosh, Atan, Atan2, Atanh, Modulus, Square root,
Natural logarithm
• Programmable precision up to 20-bit
• Fast convergence: 4 bits per clock cycle
• Supports 16-bit and 32-bit fixed point input and output formats
• Low latency AHB slave interface
• Results can be read as soon as ready without polling or interrupt
• DMA read and write channels

 

3.9 Filter mathematical accelerator (FMAC)
The filter mathematical accelerator unit performs arithmetic operations on vectors. It
comprises a multiplier/accumulator (MAC) unit, together with address generation logic,
which allows it to index vector elements held in local memory.
The unit includes support for circular buffers on input and output, which allows digital filters
to be implemented. Both finite and infinite impulse response filters can be realized.
The unit allows frequent or lengthy filtering operations to be offloaded from the CPU, freeing
up the processor for other tasks. In many cases it can accelerate such calculations
compared to a software implementation, resulting in a speed-up of time critical tasks.
FMAC features
• 16 x 16-bit multiplier
• 24+2-bit accumulator with addition and subtraction
• 16-bit input and output data
• 256 x 16-bit local memory
• Up to three areas can be defined in memory for data buffers (two input, one output),
defined by programmable base address pointers and associated size registers
• Input and output sample buffers can be circular
• Buffer “watermark” feature reduces overhead in interrupt mode
• Filter functions: FIR, IIR (direct form 1)
• AHB slave interface
• DMA read and write data channels

[링크 : https://www.st.com/resource/en/datasheet/stm32g473cb.pdf]

 

함수 3회 호출할 만큼 부하를 상쇄할 만큼 하드웨어 계산이 빠른거겠지?

1. Configure the CORDIC:
LL_CORDIC_Config(
    CORDIC,
    LL_CORDIC_FUNCTION_COSINE, /* cosine function */

    LL_CORDIC_PRECISION_6CYCLES, /* max precision for q1.31 cosine */
    LL_CORDIC_SCALE_0, /* no scale */
    LL_CORDIC_NBWRITE_1, /* One input data: angle. Second input data (modulus) is 1 af ter cordic reset */
    LL_CORDIC_NBREAD_2, /* Two output data: cosine, then sine */
    LL_CORDIC_INSIZE_32BITS, /* q1.31 format for input data */
    LL_CORDIC_OUTSIZE_32BITS
); /* q1.31 format for output data */

If only this configuration is used, this step is done once at initialization. Otherwise, it must be repeated each
time one of the above parameters changes.
2. Write the input argument(s):
/* Write angle */
LL_CORDIC_WriteData(CORDIC, ANGLE_CORDIC);
In this case, there is only one argument, the angle (defined as a constant value π/8). The other argument is
the default modulus of 1, so does not need to be written.
As soon as the expected number of arguments is written, the calculation starts.
3. Read the result(s):
/* Read cosine */
cosOutput = (int32_t)LL_CORDIC_ReadData(CORDIC);
/* Read sine */
sinOutput = (int32_t)LL_CORDIC_ReadData(CORDIC);

[링크 : https://www.st.com/resource/en/application_note/an5325-how-to-use-the-cordic-to-perform-mathematical-functions-on-stm32-mcus-stmicroelectronics.pdf]

 

FMAC configuration
The FMAC can be configured using the HAL driver from the STM32CubeG4 MCU Package. Before accessing
any FMAC registers, the FMAC clock must be enabled:
__HAL_RCC_FMAC_CLK_ENABLE();
An area of system memory must be reserved for the coefficients:
/* Declare an array to hold the filter coefficients */
static int16_t aFilterCoeffB[51];
We must also declare a structure to contain the FMAC parameters:
FMAC_HandleTypeDef hfmac;
Now we can configure the FMAC using the HAL_FMAC_FilterConfig() function:
FMAC_FilterConfigTypeDef sFmacConfig; /* declare a filter configuration structure */
sFmacConfig.CoeffBaseAddress = 0; /* Set the coefficient buffer base address */
sFmacConfig.CoeffBufferSize = 51; /* Set the coefficient buffer size to the number of coeffs */
sFmacConfig.InputBaseAddress = 51; /* Set the Input buffer base address to the next free address */
sFmacConfig.InputBufferSize = 100; /* Set the input buffer size greater than the number of coeffs */
sFmacConfig.InputThreshold = 0; /* Set the input watermark to zero since we are using DMA */
sFmacConfig.OutputBaseAddress = 151; /* Set the Output buffer base address to the next free address */
sFmacConfig.OutputBufferSize = 100; /* Set the output buffer size */
sFmacConfig.OutputThreshold = 0; /* Set the output watermark to zero since we are using DMA */

/* No A coefficients since FIR */

sFmacConfig.pCoeffA = NULL;
sFmacConfig.CoeffASize = 0;
sFmacConfig.pCoeffB = aFilterCoeffB; /* Pointer to the coefficients in memory */
sFmacConfig.CoeffBSize = 51; /* Number of coefficients */
sFmacConfig.Filter = FMAC_FUNC_CONVO_FIR; /* Select FIR filter function */
sFmacConfig.InputAccess = FMAC_BUFFER_ACCESS_DMA; /* Enable DMA input transfer */
sFmacConfig.OutputAccess = FMAC_BUFFER_ACCESS_DMA; /* Enable DMA output transfer */
sFmacConfig.Clip = FMAC_CLIP_ENABLED; /* Enable clipping of the output at 0x7FFF and 0x8000 */
sFmacConfig.P = 51; /* P parameter contains number of coefficients */
sFmacConfig.Q = FILTER_PARAM_Q_NOT_USED; /* Q parameter is not used */
sFmacConfig.R = 0; /* R parameter contains the post-shift value (none) */
if (HAL_FMAC_FilterConfig(&hfmac, &sFmacConfig) != HAL_OK) /* Configure the FMAC */
Error_Handler(); /* Configuration Error */
The HAL_FMAC_FilterConfig() function programs the configuration and control registers, and loads the
coefficients into the FMAC local memory (X2 buffer).

[링크 : https://www.st.com/resource/en/application_note/an5305-digital-filter-implementation-with-the-fmac-using-stm32cubeg4-mcu-package-stmicroelectronics.pdf]

Posted by 구차니
embeded/Cortex-M4 STM2025. 11. 28. 15:41

아무생각없이 57600-None 으로 했더니 정체 불명의(?) NACK가 뜬다.

 

57600-Even 로 해주니 잘된다.

'embeded > Cortex-M4 STM' 카테고리의 다른 글

UM2195 audio streaming Expansion Package for STM32Cube  (0) 2026.01.05
stm32g4 cordic fmac  (0) 2025.11.28
stm32flash 0.5 0.7 버전과 stm32g473  (0) 2025.11.28
stm32g473 ADC calibration  (0) 2025.11.28
stm32f411 black fill board  (0) 2025.11.22
Posted by 구차니
embeded/Cortex-M4 STM2025. 11. 28. 15:36

ubuntu 22.04 패키지로 설치된 건 0.5 버전인데

stm32g473을 boot0 핀을 이용해서 내장 부트로더로 올려보려고 하니 이런 에러가 발생한다.

0x469 장치 아이디 미지원.. 쩝..

$ stm32flash /dev/ttyUSB0
stm32flash 0.5

http://stm32flash.sourceforge.net/

Interface serial_posix: 57600 8E1
Unknown/unsupported device (Device ID: 0x469)

 

소스가 0.7 인데 받아서 빌드하고 해보니 잘된다.

$ ./stm32flash /dev/ttyUSB0
stm32flash 0.7

http://stm32flash.sourceforge.net/

Interface serial_posix: 57600 8E1
Version      : 0x31
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0469 (STM32G47xxx/48xxx)
- RAM        : Up to 96KiB  (16384b reserved by bootloader)
- Flash      : Up to 512KiB (size first sector: 1x2048)
- Option RAM : 48b
- System RAM : 28KiB

'embeded > Cortex-M4 STM' 카테고리의 다른 글

stm32g4 cordic fmac  (0) 2025.11.28
STM32CubeProgrammer / uart / parity  (0) 2025.11.28
stm32g473 ADC calibration  (0) 2025.11.28
stm32f411 black fill board  (0) 2025.11.22
stm32g473 adc  (0) 2025.11.03
Posted by 구차니
embeded/Cortex-M4 STM2025. 11. 28. 14:45

전압이 이상하게(?) 낮게 나와서 찾아 보는데 (대충 0.3v 정도?) gpt도 캘리브레이션 하라고 한다.

cubeide에 의해서 생성된 코드로 adc 가 초기화되고 나서

캘리브레이션 한 다음 약 2usec 이후에 HAL_ADC_GetValue(&hadc1); 하면 된다고 한다.

  MX_ADC1_Init();
  /* USER CODE BEGIN 2 */
  extern ADC_HandleTypeDef hadc1;
  HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
  HAL_Delay(2);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {

  }

 

stm32g4 인데 캘리브레이션 하지 않으면 0.924 V가 나왔고

1148
0.924902 * 24 = 22.197655

 

캘리브레이션 이후에는 0.979 V가 나왔다.

1216
0.979688 * 24 = 23.512501

[링크 : https://jeonhj.tistory.com/22]

'embeded > Cortex-M4 STM' 카테고리의 다른 글

stm32g4 cordic fmac  (0) 2025.11.28
STM32CubeProgrammer / uart / parity  (0) 2025.11.28
stm32flash 0.5 0.7 버전과 stm32g473  (0) 2025.11.28
stm32f411 black fill board  (0) 2025.11.22
stm32g473 adc  (0) 2025.11.03
Posted by 구차니