printf() working on one project but not another
I have 2 projects for a nucleo-H536ZI. the first project the printf()s work and are tied to the _write() function which I have debugged and proven. The second project the printfs() do not work using the same printf() & _write() function code again and I have verified it gets to the correct _write(), code shown below. Both projects have the same pins (verified) and the same MX_USART2_UART_Init() as shown below. I did copy and drop the BSP folder from the repository incase it maters on the project that doesn't work.
Both have the same debugger configurations set up. I have shown the code that both projects use in main() to get to the first printf() statement. I am out of ideas why one works and the other does not, any help is most appreciated.
PA0 CTS
PA3 Rx
PD4 RTS
PD5 Tx
====================================
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_I3C1_Init();
MX_ICACHE_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
printf("Hello comm setup.\n"); //This works on project 1 not project 2
...
====================================
static void MX_USART2_UART_Init(void)
{
/* USER CODE BEGIN USART2_Init 0 */
/* USER CODE END USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
====================================
int _write(int file, char *ptr, int len)
{
for(int DataIdx=0; DataIdx < len; DataIdx++)
{
//please note, I have proven I get to this line for both projects, I
//just have not seen output in the SWV ITM Data Console port0 with trace on.
ITM_SendChar(*ptr++); //Send/Display string char by char.
}
return len;
}
/* USER CODE END USART2_Init 2 */
}
