2019-04-10 04:26 PM
Hi,
I am using the Nucleo-H743ZI, when trying to printf a buffer I see lots of data missing. Even when just trying to printf a counter I see the same issue, I tried it in Atollic as well as ST_LINK and I get same issue.
I saw many issues in the past and was able to find a solution to print something here:
https://community.st.com/s/question/0D50X00009XkhURSAZ/stm32h7-swo-printf-not-working
But still this causing the issue above.
I am using the code below in order to enable the ITM.
void ITM_enable(void)
{
*(__IO uint32_t*)(0x5C001004) = 0x00700000;
//UNLOCK FUNNEL
*(__IO uint32_t*)(0x5C004FB0) = 0xC5ACCE55;
*(__IO uint32_t*)(0x5C003FB0) = 0xC5ACCE55;
//SWO current output divisor register
//This divisor value (0x000000C7) corresponds to 400Mhz
//To change it, you can use the following rule
// value = (CPU Freq/sw speed )-1
*(__IO uint32_t*)(0x5C003010) = (*(__IO uint32_t*)(0x5C003010) & 0xfffff000) | 0x000000C7;
//SWO selected pin protocol register
*(__IO uint32_t*)(0x5C0030F0) = 0x00000002;
//Enable ITM input of SWO trace funnel
*(__IO uint32_t*)(0x5C004000) = *(__IO uint32_t*)(0x5C004000) | 0x00000001;
//RCC_AHB4ENR enable GPIOB clock
*(__IO uint32_t*)(0x580244E0) = *(__IO uint32_t*)(0x580244E0) | 0x00000002;
// Configure GPIOB pin 3 as AF
*(__IO uint32_t*)(0x58020400) = (*(__IO uint32_t*)(0x58020400) & 0xffffff3f) | 0x00000080;
// Configure GPIOB pin 3 Speed
*(__IO uint32_t*)(0x58020408) = *(__IO uint32_t*)(0x58020408) | 0x00000080;
// Force AF0 for GPIOB pin 3
*(__IO uint32_t*)(0x58020420) = *(__IO uint32_t*)(0x58020420) & 0xFFFF0FFF;
}
Thanks
Sharon
2019-04-10 05:56 PM
The issue in the other thread was *nothing* coming out. Are you at least getting some of the expected data?
What firmware version are you using on the ST-LINK ?
The above code presumes a 400 MHz CPU clock, and a 2 MHz SWD clock
2019-04-10 08:48 PM
Hi,
I am using ST_Link-V4.4.0.0
I do get the expected data but I can see that data is missing, as mentioned I did a test running a counter and printing the counter and I can see group of numbers missing. As the example below shows the left number is the counter (the right are numbers from the ADC-DMA) after sample 3091 the data is corrupted and you can clearly see some shift in the numbers that next correct sample is 4060. As I mentioned I can see it on ST-Link as well as Atollic.
I am using 400Mhz with 2 MHz SWD clock.
3087, 14658
3088, 23800
3089, 52624
3090, 64345
3091, 5
059, 45055
4060, 1684
4061, 62496
4062, 24112
4063, 13970
4064, 43582
4065, 11263
4066
Thanks
Sharon