Hi Sir,
I have PWM several issue with STM32L443RC mcu.
TIM1,TIM2,TIM15,TIM16 PWM function works only channel1 for each Timer with this code "
main:
GPIO_Digital_output (@GPIOH_BASE,_GPIO_PINMASK_1 )
delay_ms(100)
PWM_TIM2_Init(6000)
PWM_TIM2_Set_Duty(2000,_PWM_NON_INVERTED,_PWM_CHANNEL1)
PWM_TIM2_Start(_PWM_CHANNEL1,@_GPIO_MODULE_TIM2_PA0)
PWM_TIM1_Init(6000)
PWM_TIM1_Set_Duty(2000,_PWM_NON_INVERTED,_PWM_CHANNEL1)
PWM_TIM1_Start(_PWM_CHANNEL1,@_GPIO_MODULE_TIM1_PA8)
PWM_TIM15_Init(6000)
PWM_TIM15_Set_Duty(2000,_PWM_NON_INVERTED,_PWM_CHANNEL1)
PWM_TIM15_Start(_PWM_CHANNEL1,@_GPIO_MODULE_TIM15_PA2)
PWM_TIM16_Init(6000)
PWM_TIM16_Set_Duty(2000,_PWM_NON_INVERTED,_PWM_CHANNEL1)
PWM_TIM16_Start(_PWM_CHANNEL1,@_GPIO_MODULE_TIM16_PA6)
while 1
GPIOH_ODR.B1 = not GPIOH_ODR.B1
delay_ms(100)
wend
end.
But for other PWM channels I could not get PWM output.
With this code MCU hanging !!
main:
GPIO_Digital_output (@GPIOH_BASE,_GPIO_PINMASK_1 )
delay_ms(100)
PWM_TIM1_Init(6000)
PWM_TIM1_Set_Duty(2000,_PWM_NON_INVERTED,_PWM_CHANNEL2)
PWM_TIM1_Start(_PWM_CHANNEL2,_GPIO_TIM1_CH2_PA9)
while 1
GPIOH_ODR.B1 = not GPIOH_ODR.B1
delay_ms(100)
wend
end.
This code also same result;
main:
GPIO_Digital_output (@GPIOH_BASE,_GPIO_PINMASK_1 )
delay_ms(100)
PWM_TIM2_Init(6000)
PWM_TIM2_Set_Duty(2000,_PWM_NON_INVERTED,_PWM_CHANNEL2)
PWM_TIM2_Start(_PWM_CHANNEL2,_GPIO_TIM2_CH2_PA1)
while 1
GPIOH_ODR.B1 = not GPIOH_ODR.B1
delay_ms(100)
wend
end.
So I mean I can use only channel1 for each timers. Other channels not work.
Do you have some commad for this issue..
STM32L443RC PWM library
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: STM32L443RC PWM library
Hello,
You are missing the @ operator in front of the GPIO structures.
Regards,
You are missing the @ operator in front of the GPIO structures.
Code: Select all
PWM_TIM1_Start(_PWM_CHANNEL2,@_GPIO_TIM1_CH2_PA9)
PWM_TIM2_Start(_PWM_CHANNEL2,@_GPIO_TIM2_CH2_PA1)
Filip Grujcic
Re: STM32L443RC PWM library
Hi Filip,
Thanks for your reply, but "@" operator not work.
Thanks for your reply, but "@" operator not work.
- Attachments
-
- syntax error.png (39.83 KiB) Viewed 1991 times
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: STM32L443RC PWM library
Hello,
I apologize I made an oversight -- you are trying to use the predefined library constant instead of the GPIO module structure that you need to be using.
This is the reason it doesn't work.
Should be:
These structures are most likely missing from your GPIO defs file. You can add them yourself, since GPIO defs is open source, however I have attached the defs file with the structures already there.
Copy the .mbas file to:
...\Mikroelektronika\mikroBasic PRO for ARM v6.2.0\Uses\ST M4
Regards,
I apologize I made an oversight -- you are trying to use the predefined library constant instead of the GPIO module structure that you need to be using.
This is the reason it doesn't work.
Code: Select all
PWM_TIM1_Start(_PWM_CHANNEL2,@_GPIO_TIM1_CH2_PA9)
PWM_TIM2_Start(_PWM_CHANNEL2,@_GPIO_TIM2_CH2_PA1)
Code: Select all
PWM_TIM1_Start(_PWM_CHANNEL2, @_GPIO_MODULE_TIM1_PA8)
PWM_TIM2_Start(_PWM_CHANNEL2, @_GPIO_MODULE_TIM2_PA1)
Copy the .mbas file to:
...\Mikroelektronika\mikroBasic PRO for ARM v6.2.0\Uses\ST M4
Regards,
- Attachments
-
- __Lib_GPIO_32L43x_Defs.zip
- (2.22 KiB) Downloaded 53 times
Filip Grujcic
Re: STM32L443RC PWM library
Many Thanks for your reply,
I understood how it should be. But other PWM channels still missing but I can add myself.
Thanks again
I understood how it should be. But other PWM channels still missing but I can add myself.
Thanks again
Re: STM32L443RC PWM library
Hi,
I added all PWM channels to the defs file.
But PORTC alternate functions still missing. Is it possible to add ?
I added all PWM channels to the defs file.
But PORTC alternate functions still missing. Is it possible to add ?
- Attachments
-
- __Lib_GPIO_32L43x_Defs.rar
- (2.09 KiB) Downloaded 64 times
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: STM32L443RC PWM library
Hello,
You can add everything that is in the GPIO defs file. Simply copy the existing structure or constant and alter it according to your needs.
Regards,
You can add everything that is in the GPIO defs file. Simply copy the existing structure or constant and alter it according to your needs.
Regards,
Filip Grujcic