Some sort of printf via SWV
Hello,
Firstly I'd like to say I have googled for examples and worked independently by reading ST docs and looked at the suggested topics before posting. I did begin to hijack another thread but I'll start one instead.
What a long and painful tradition printing with ST dev boards is!
My latest attempt is to follow this SWV tutorial for another board.
Apologies if it's something ridiculous, I'm new!
Having just tested the code before posting tonight, even with non blink related code commented out it has stopped blinking but still some help please :D
https://www.youtube.com/watch?v=sPzQ5CniWtw
Here is the code I am running.
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h" //The printf function is here
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
ETH_HandleTypeDef heth;
UART_HandleTypeDef huart3;
PCD_HandleTypeDef hpcd_USB_OTG_FS;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ETH_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_USB_OTG_FS_PCD_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int _write(int file, char *ptr, int len)
{
/* Implement your write code here, this is used by puts and printf for example */
int i=0;
for(i=0 ; i<len ; i++)
ITM_SendChar((*ptr++));
return len;
}
uint8_t count = 0; //rigtht data type?
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ETH_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init(); //not helping?
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOB, LD1_Pin); //Toggle the LED
count++; //Increment the count var
printf ("HELLO WORLD count = %d \n", count); // print the count var
HAL_Delay(250);
}
/* USER CODE END 3 */
}
Which involves rewriting the write() function. I also tried this write function
int _write(int file, char *ptr, int len)
{
int DataIdx;
for(DataIdx=0; DataIdx<len; DataIdx++)
{
ITM_SendChar(*ptr++);
}
return len;
}My debugger is shutting down (RGB lights out) and sometimes has to be power cycled.
I have tried various core clock settings in the debug config tab.
here are photos of the clock page, debug config and RCC options.
Thank you TeslaDelorian for trying to help in the previously hijacked thread. Here is my clock info.
Thanks
