Page 1 of 2

halconf and mcuconf for pwm: #error compile time

Posted: Tue Mar 15, 2016 2:22 pm
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

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

Posted: Tue Mar 15, 2016 2:26 pm
by Giovanni
Used by the ST driver.

Giovanni

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

Posted: Tue Mar 15, 2016 2:31 pm
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?

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

Posted: Tue Mar 15, 2016 2:35 pm
by Giovanni
Documentation is your friend http://chibios.sourceforge.net/docs3/ha ... __s_t.html

Giovanni

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

Posted: Tue Mar 15, 2016 2:39 pm
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?

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

Posted: Tue Mar 15, 2016 2:41 pm
by Giovanni
You can free it by disabling the tickless mode.

Giovanni

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

Posted: Tue Mar 15, 2016 2:49 pm
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?

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

Posted: Tue Mar 15, 2016 3:18 pm
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

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

Posted: Tue Mar 15, 2016 3:24 pm
by enrico.dallavia
but it does not work, since TIM3 is not a 32 bit timer :(

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

Posted: Tue Mar 15, 2016 3:43 pm
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?