Firstly, note that I am a newbie in RTOS world and I've been playing around with ChibiOS for a few days. I have a custom board with a STM32F103RE IC on it, and I've been trying to get some PWM action happening. Unfortunately, the compilation fails and I've been banging my head against the wall trying to figure out why, and I am sure some kind soul will figure it out in a matter of seconds.
The code is:
Code: Select all
#include "ch.h"
#include "hal.h"
static PWMConfig pwmconf = {
10000,
5000,
NULL, /* No call back function */
/* Channels 3 and 4 on TIM3 enabled */
{
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
},
0,
0,
#if STM32_PWM_USE_ADVANCED
0
#endif
};
int main(void) {
halInit();
chSysInit();
/* Enable PWM output TIM3, ch3 and ch4 (LED(PB0) and PB1) */
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATE(2));
palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATE(2));
pwmStart(&PWMD3, &pwmconf);
pwmEnableChannel(&PWMD3, 3, 5000);
pwmEnableChannel(&PWMD3, 4, 5000);
while (TRUE) {
chThdSleepMilliseconds(5000);
}
}
Looking at the datasheet, PB1 and PB0 should be TIM3_CH4 and TIM3_CH3. However the compilation fails with the following:
Code: Select all
main.c: In function 'main':
main.c:44:3: warning: implicit declaration of function 'PAL_MODE_ALTERNATE' [-Wimplicit-function-declaration]
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATE(2));
^
Linking build/chARMINARM_PWM.elf
build/obj/main.o: In function `main':
/home/igor/Code/ChibiOS_2.6.6/demos/ARMCM3-STM32F103-ARMINARM_PWM/main.c:44: undefined reference to `PAL_MODE_ALTERNATE'
/home/igor/Code/ChibiOS_2.6.6/demos/ARMCM3-STM32F103-ARMINARM_PWM/main.c:45: undefined reference to `PAL_MODE_ALTERNATE'
collect2: error: ld returned 1 exit status
../../os/ports/GCC/ARMCMx/rules.mk:210: recipe for target 'build/chARMINARM_PWM.elf' failed
make: *** [build/chARMINARM_PWM.elf] Error 1
I have enabled the PWM driver in halconf.h and #define STM32_PWM_USE_TIM3 TRUE.
I also have a custom board.h for my board and I can post that if needed.
Any hints?
Thanks,
-Igor