From 8f576045ed7a30f99e93bc0b0855747e307ff28d Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Mon, 28 Apr 2025 20:40:04 +0200 Subject: [PATCH] add systemview for debugging purposes --- .gitmodules | 3 +++ Drivers/SystemView | 1 + Makefile | 7 ++++++- Src/main.c | 8 ++++++++ Src/stm32g0xx_it.c | 5 +++-- compile_flags.txt | 3 +++ 6 files changed, 24 insertions(+), 3 deletions(-) create mode 160000 Drivers/SystemView diff --git a/.gitmodules b/.gitmodules index c7477c3..bfbbd8f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "Drivers/RTT"] path = Drivers/RTT url = https://github.com/SEGGERMicro/RTT.git +[submodule "Drivers/SystemView"] + path = Drivers/SystemView + url = https://github.com/SEGGERMicro/SystemView.git diff --git a/Drivers/SystemView b/Drivers/SystemView new file mode 160000 index 0000000..d8bbf3f --- /dev/null +++ b/Drivers/SystemView @@ -0,0 +1 @@ +Subproject commit d8bbf3f6e779af76a09cf7000c2003ab17ca11c6 diff --git a/Makefile b/Makefile index a9afc44..64ff4cf 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,8 @@ Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c \ Drivers/RTT/RTT/SEGGER_RTT.c \ Drivers/RTT/RTT/SEGGER_RTT_printf.c \ Drivers/RTT/Syscalls/SEGGER_RTT_Syscalls_GCC.c \ +Drivers/SystemView/SYSVIEW/SEGGER_SYSVIEW.c \ +Drivers/SystemView/Sample/NoOS/Config/Cortex-M0/SEGGER_SYSVIEW_Config_NoOS_CM0.c\ Src/system_stm32g0xx.c # ASM sources @@ -124,7 +126,10 @@ C_INCLUDES = \ -IDrivers/CMSIS/Device/ST/STM32G0xx/Include \ -IDrivers/CMSIS/Include \ -IDrivers/RTT/Config \ --IDrivers/RTT/RTT +-IDrivers/RTT/RTT \ +-IDrivers/SystemView/Config \ +-IDrivers/SystemView/SEGGER \ +-IDrivers/SystemView/SYSVIEW # compile gcc flags diff --git a/Src/main.c b/Src/main.c index 2bb25b7..20fa865 100644 --- a/Src/main.c +++ b/Src/main.c @@ -21,6 +21,7 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "SEGGER_SYSVIEW.h" #include "SEGGER_RTT.h" #include "stm32g0b1xx.h" #include "stm32g0xx_hal_cortex.h" @@ -119,6 +120,7 @@ void init_UART1_dma(){ } void USART1_IRQHandler(){ + SEGGER_SYSVIEW_RecordEnterISR(); if(USART1->ISR & USART_ISR_RXNE_RXFNE){ //printf("%x ", USART1->RDR); rxBuffer[rxBufferPos++] = USART1->RDR; @@ -150,14 +152,17 @@ void USART1_IRQHandler(){ USART1->ICR = USART_ICR_UDRCF; printf("UDR\n"); } + SEGGER_SYSVIEW_RecordExitISR(); } void DMA1_Channel1_IRQHandler(){ + SEGGER_SYSVIEW_RecordEnterISR(); if(DMA1->ISR & DMA_ISR_TCIF1){ DMA1->IFCR = DMA_IFCR_CTCIF1; DMA1_Channel1->CCR &= ~( DMA_CCR_EN ); DMA1_Channel1->CMAR = ( uint32_t )&rxBuffer[0]; } + SEGGER_SYSVIEW_RecordExitISR(); } /* USER CODE END 0 */ @@ -167,9 +172,12 @@ void DMA1_Channel1_IRQHandler(){ */ int main(void) { + /* USER CODE BEGIN 1 */ SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL); printf("Moin!\n"); + + SEGGER_SYSVIEW_Conf(); /* Configure and initialize SystemView */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ diff --git a/Src/stm32g0xx_it.c b/Src/stm32g0xx_it.c index eee2e64..a519df9 100644 --- a/Src/stm32g0xx_it.c +++ b/Src/stm32g0xx_it.c @@ -23,6 +23,7 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "stdio.h" +#include "SEGGER_SYSVIEW.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -126,11 +127,11 @@ void PendSV_Handler(void) void SysTick_Handler(void) { /* USER CODE BEGIN SysTick_IRQn 0 */ - + SEGGER_SYSVIEW_RecordEnterISR(); /* USER CODE END SysTick_IRQn 0 */ HAL_IncTick(); /* USER CODE BEGIN SysTick_IRQn 1 */ - + SEGGER_SYSVIEW_RecordExitISR(); /* USER CODE END SysTick_IRQn 1 */ } diff --git a/compile_flags.txt b/compile_flags.txt index 5efdd1b..92d6f97 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -9,6 +9,9 @@ -IDrivers/CMSIS/Include -IDrivers/RTT/Config -IDrivers/RTT/RTT +-IDrivers/SystemView/Config +-IDrivers/SystemView/SEGGER +-IDrivers/SystemView/SYSVIEW -Og -Wall -fdata-sections