halconf and mcuconf for pwm: #error compile time

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

Hello,
I have a problem I don't understand. I'm using stm072R8-discovery board, and I'm trying to bring up various functionality: ADC, DAC, watchdog, PWM output.
I'm facing a problem with pwm.
after enabling in halconf.h

Code: Select all

#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
#define HAL_USE_PWM                 TRUE
#endif


and inside mcuconf.h

Code: Select all

/*
 * PWM driver system settings.
 */
#define STM32_PWM_USE_ADVANCED              FALSE
#define STM32_PWM_USE_TIM1                  FALSE
#define STM32_PWM_USE_TIM2                  TRUE
#define STM32_PWM_USE_TIM3                  FALSE
#define STM32_PWM_TIM1_IRQ_PRIORITY         3
#define STM32_PWM_TIM2_IRQ_PRIORITY         3
#define STM32_PWM_TIM3_IRQ_PRIORITY         3


I got #error "ST requires TIM2 but the timer is already used"

The pin I'm using is PB3 that corresponds to TIM2_CH2 and I don't think I'm using TIM2 for other functionality

What could be the problem?

Thanks
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: halconf and mcuconf for pwm: #error compile time

Post by Giovanni »

Used by the ST driver.

Giovanni
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

Thanks for the answer, but I don't understand.
you mean TIM2 is already used by st driver for something else? If yes, for what?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: halconf and mcuconf for pwm: #error compile time

Post by Giovanni »

Documentation is your friend http://chibios.sourceforge.net/docs3/ha ... __s_t.html

Giovanni
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

Indeed it is!!

so TIM2 is used by Chibios if I'm not mistaken

This module implements a system tick timer in order to support the underlying operating system.


That means TIM2 will not be ever available for anything?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: halconf and mcuconf for pwm: #error compile time

Post by Giovanni »

You can free it by disabling the tickless mode.

Giovanni
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

Ok, thanks.
could you kindly answer me one more question?
If I'm disabling the thickless, what are the drawbacks? I can't use, for example,chVTGetSystemTimeX() function?

from this thread [url]
viewtopic.php?f=3&t=339
[/url]

I see that timeout also stop working, that means every function that got a timeout parameter as input, will stop working?
also chThdSleepMilliseconds(xxx); will stop working?

I see now from the source code that also TIM3 is needed by the low level driver.
That means only TIM1 is free to be used by application code?
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

from another post I understand that it is possible to choose which timer must be used for systick

here
[url]
viewtopic.php?f=24&t=2280
[/url]

changing the line
#define STM32_ST_USE_TIMER 3
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

but it does not work, since TIM3 is not a 32 bit timer :(
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: halconf and mcuconf for pwm: #error compile time

Post by enrico.dallavia »

from here
[url]
http://www.chibios.org/dokuwiki/doku.ph ... :kernel_vt
[/url]
it seems that if I disable thickless mode, the power consumption will increase, CPU usage is increased by the frequent IRQ servicing, ecc...

but the other functions should work as usual? Should I reduce the system resolution from 10000 to 1000 to reduce the impact on the system?
Post Reply