Problem with PWM Complementry signal
Posted: Wed Feb 15, 2017 4:42 pm
Hi Giovani,
I successfully generated PWM with complementry singnal on STM32 disco board for a Motor control application.
I used palSetPadMode(GPIOC,7, PAL_MODE_ALTERNATE(3)) for actual PWM signal and palSetPadMode(GPIOB,0, PAL_MODE_ALTERNATE(3)) for its complementry signal using timer 8. Its working fine on stm32 disco board.
But when I executed the same program on custom made board with STM32F437 only by changing the complementy pin to PB0 to PH14 I am facing a problem which i have explained below.
Following is the configuration on custom made board.
palSetPadMode(PHASE_B_HIGH_PORT,PHASE_B_HIGH_PIN,PAL_MODE_ALTERNATE(3)) - this is PC7 pin as actual PWM signal and palSetPadMode(PHASE_B_LOW_PORT,PHASE_B_LOW_PIN,PAL_MODE_ALTERNATE(3)) - this is PH14 pin as its complementry signal.
The problem is when I congiure the PWM channel mode like this, PWM_OUTPUT_ACTIVE_HIGH |PWM_COMPLEMENTARY_OUTPUT_DISABLED,
I expected the pin PH14 to be disabled and there will be no output, but it is ON and I got PWM signal at PC7 as expected. This will cause problem since FETs will on at the same time. This problem did not arise when i used the stm32 disco board.
I am using the board.h and board.c file same as stm32 demo. I also noticed, PH14 was configured as input pullup in GPIOH setup in board.h file of stm32 demo. I believe PH14 is ON because it is configured as input pullup initially and I have just configured it as PAL_MODE_ALTERNATE(3) in main.c file.
Could you please let me know how to configure PH14 and all PWM output pins as PAL_MODE_ALTERNATE(3) and also as pushpull?
I tried like following to configure all PWM pins and also as pushpull.
1. palSetPadMode(PHASE_B_HIGH_PORT,PHASE_B_HIGH_PIN,PAL_MODE_OUTPUT_PUSHPULL|PAL_MODE_ALTERNATE(3) )in this case there is no error and also no output from PWM even though the channel mode is PWM_OUTPUT_ACTIVE_HIGH.
2.palSetPadMode(PHASE_B_HIGH_PORT,PHASE_B_HIGH_PIN,PAL_MODE_STM32_ALTERNATE_PUSHPULL) in this case there is a following error
'main.c:384:27: error: 'PAL_MODE_STM32_ALTERNATE_PUSHPULL' undeclared (first use in this function)
palSetPadMode(GPIOC,6,PAL_MODE_STM32_ALTERNATE_PUSHPULL);
Please let me know how i can resolve this issue. Also please tell me know what i have to keep in mind when using board.c and board.h of stm32 disco for custom made board.
Kind regards,
Arun
I successfully generated PWM with complementry singnal on STM32 disco board for a Motor control application.
I used palSetPadMode(GPIOC,7, PAL_MODE_ALTERNATE(3)) for actual PWM signal and palSetPadMode(GPIOB,0, PAL_MODE_ALTERNATE(3)) for its complementry signal using timer 8. Its working fine on stm32 disco board.
But when I executed the same program on custom made board with STM32F437 only by changing the complementy pin to PB0 to PH14 I am facing a problem which i have explained below.
Following is the configuration on custom made board.
palSetPadMode(PHASE_B_HIGH_PORT,PHASE_B_HIGH_PIN,PAL_MODE_ALTERNATE(3)) - this is PC7 pin as actual PWM signal and palSetPadMode(PHASE_B_LOW_PORT,PHASE_B_LOW_PIN,PAL_MODE_ALTERNATE(3)) - this is PH14 pin as its complementry signal.
The problem is when I congiure the PWM channel mode like this, PWM_OUTPUT_ACTIVE_HIGH |PWM_COMPLEMENTARY_OUTPUT_DISABLED,
I expected the pin PH14 to be disabled and there will be no output, but it is ON and I got PWM signal at PC7 as expected. This will cause problem since FETs will on at the same time. This problem did not arise when i used the stm32 disco board.
I am using the board.h and board.c file same as stm32 demo. I also noticed, PH14 was configured as input pullup in GPIOH setup in board.h file of stm32 demo. I believe PH14 is ON because it is configured as input pullup initially and I have just configured it as PAL_MODE_ALTERNATE(3) in main.c file.
Could you please let me know how to configure PH14 and all PWM output pins as PAL_MODE_ALTERNATE(3) and also as pushpull?
I tried like following to configure all PWM pins and also as pushpull.
1. palSetPadMode(PHASE_B_HIGH_PORT,PHASE_B_HIGH_PIN,PAL_MODE_OUTPUT_PUSHPULL|PAL_MODE_ALTERNATE(3) )in this case there is no error and also no output from PWM even though the channel mode is PWM_OUTPUT_ACTIVE_HIGH.
2.palSetPadMode(PHASE_B_HIGH_PORT,PHASE_B_HIGH_PIN,PAL_MODE_STM32_ALTERNATE_PUSHPULL) in this case there is a following error
'main.c:384:27: error: 'PAL_MODE_STM32_ALTERNATE_PUSHPULL' undeclared (first use in this function)
palSetPadMode(GPIOC,6,PAL_MODE_STM32_ALTERNATE_PUSHPULL);
Please let me know how i can resolve this issue. Also please tell me know what i have to keep in mind when using board.c and board.h of stm32 disco for custom made board.
Kind regards,
Arun