JTAG Error at Inconsistant Locations in Code
Pasted below is the information copied from STM32CubeMX’s Pin Configuration’s SYS tab:
PA13 SYS_JTMS-SWDIO n/a n/a n/a n/a false
PA14 SYS_JTCK-SWCLK n/a n/a n/a n/a false
PA15 SYS_JTDI n/a n/a n/a n/a false
PB3 SYS_JTDO-TRACESWO n/a n/a n/a n/a false
PE2 SYS_TRACECK Alternate Function Push Pull No pull up pull down Low n/a false
PE3 SYS_TRACED0 Alternate Function Push Pull No pull up pull down Low n/a false
PE4 SYS_TRACED1 Alternate Function Push Pull No pull up pull down Low n/a false
PE5 SYS_TRACED2 Alternate Function Push Pull No pull up pull down Low n/a false
PE6 SYS_TRACED3 Alternate Function Push Pull No pull up pull down Low n/a false
The proper JTAG assignments appear to have been done in STM32CubeMX. However in the code that STM32CubeMX generated the JTAG error I get does happen when GPIOA is configured. Here is that code:
/*Configure GPIO pins : PAPin PAPin */
GPIO_InitStruct.Pin = Test_PointA2_Pin|Test_PointA9_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
There is no change made to pins PA13, PA14, or PA15 here. But it is suspicious that it happens when changes to pins on this port that contains these JTAG pins are are done.
When the above is commented out I find the JTAG error also happens here:
/*Configure GPIO pin : PB10 */
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
Once again it happens when a port that contains JTAG pins has one of its non JTAG pins changed.
But it also happens here:
/*Configure GPIO pins : PBPin PBPin PBPin PBPin */
GPIO_InitStruct.Pin = PWM2_TIM15_Ch1_Alternate_Pin|PWM2_TIM15_Ch1N_Alternate_Pin|JTAG_TRST_Pin|USART_INVALID_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
Which does change a JTAG pin. Obviously the ST-Link V2 ISO is functioning up to this point, so I see no reason for STM32CubeMX to assign these JTAG pins. Should I remove all the JTAG pin assignments from the STM32CubeMX project file?