2017-02-07 08:36 AM
Hi
CubeMX generates the following code for a timer (timer2) with 4 PWM channels.
Each of the channels are configured with the same parameters.
Obviously for channel1 the line:
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
is missing. Timer2 channel 1 do not work before inserting this line by hand.
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
{
GPIO_InitTypeDef GPIO_InitStruct;
if(timHandle->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspPostInit 0 */
/* USER CODE END TIM1_MspPostInit 0 */
/**TIM1 GPIO Configuration
PA8 ------> TIM1_CH1
*/
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN TIM1_MspPostInit 1 */
/* USER CODE END TIM1_MspPostInit 1 */
}
else if(timHandle->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspPostInit 0 */
/* USER CODE END TIM2_MspPostInit 0 */
/**TIM2 GPIO Configuration
PA0 ------> TIM2_CH1
PA1 ------> TIM2_CH2
PB10 ------> TIM2_CH3
PB11 ------> TIM2_CH4
*/
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN TIM2_MspPostInit 1 */
/* USER CODE END TIM2_MspPostInit 1 */
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
BTW How can one format source code in postings at st.com?
Everything which I tried results in a mess.
There should be a preview option also.
Regards
Dieter
2017-02-07 09:32 AM
Hello,
Which CubeMx version are you using ? I will check your issue and come back to you as soon as I have needed details.
About
format source code, y
ou should expand toolbar by clicking on [...] icon, then click on ''More >> Syntax Highlighter''.Best Regards
Imen
2017-02-07 02:28 PM
Hi Imen
I'm using the latest CubeMX 4.19
When trying 'Syntax highlighter' the syntax of the text becomes highlighted but ugly formatted or not formatted at all.
Because there is no preview I was wondering whether I should click the send botton.
Regards
Dieter
2017-02-08 09:18 AM
Hi
Br_ggemann.Dieter
,I cannot reproduce your issue.
Please share your .ioc fileto check this case and identify what is going wrong.
Regards
Imen
2017-02-08 10:47 AM
Hi
I can see the error in .ioc, but look at the screenshots of the GUI.
Regards
Dieter
________________ Attachments : L433CCTx-mini-sys.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyxN&d=%2Fa%2F0X0000000bEK%2FI.gzeyRShzgdt6vbjt_LPhaf29WINnCPiG2G21gbk1Q&asPdf=falseCubeMX-screen0.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyxD&d=%2Fa%2F0X0000000bEJ%2F2pqyN3Tt8Wt9N5lt0CvvgPrFSn_5vJXoXpfZYx_.zKc&asPdf=falseCubeMX-screen1.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyru&d=%2Fa%2F0X0000000bEH%2FBBx0afx0hovAkF_iehLGFSQXy8tWpq6dGtaZYOj.mEk&asPdf=falseCubeMX-screen2.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyx3&d=%2Fa%2F0X0000000bEG%2F3s_BBaNHIesEx76mmAexRx6iZ9vmG2aOAWybTUpkXrs&asPdf=false2017-02-08 11:20 AM
If I fix the .ioc file by hand and import the project into a fresh started CubeMX, CubeMX do not complain.
But when I have then the code generated again the .ioc file becomes broken again.
In contrast the .pdf file from the report generation reflects what the GUI is telling me.
Regards
Dieter
2017-02-08 12:32 PM
There are more errors within the .ioc file. MCU Pins are also completely wrong.
When creating a new project from scratch, doing only pinout -> peripherals and clock configuration without touching configuration tab, the error occurs again.
2017-02-08 02:53 PM
I was wrong with my statement regarding MCU pins within the .ioc file. For these pins only the green ones seems to count.
2017-02-13 08:12 AM
Hi
Are there any news to this case?
I have tested it on another Linux box wich gaves the same result.
Dieter
2017-02-13 09:24 AM
Hi
Br_ggemann.Dieter
,Sorry for my own delay and I want to thank you for the information and screenshotsprovided,this is helpful for us.
I confirm from my side the missing line (GPIO_InitStruct.Alternate = GPIO_AF1_TIM2)for Timer2 channel 1
andI would inform you that I have
reported internally this issueand will come back to youas soon as wehave needed updates.
All comments and suggestions are welcome to improve our solutions.
Regards
Imen