Clock configuration issues on STM32F105 board

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

Moderators: RoccoMarco, barthess

jsavonet
Posts: 11
Joined: Fri Mar 01, 2019 10:00 am
Location: France, Lyon
Been thanked: 1 time

Clock configuration issues on STM32F105 board

Postby jsavonet » Fri Mar 01, 2019 10:24 am

Hi,

I'm trying to do a simple blinker thread example on a custom STM32F105 based board. The board has no external oscillator and is 100% functionnal (tested all peripherals in CubeMx).

So, I started from an existing ChibiOS project (ChibiOS/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP) and I tried to configure the clock so that it can use the internal clock.

Here is what I did in mcuconf.h:

Code: Select all

#define STM32F107_MCUCONF

/*
 * HAL driver system settings.
 */
#define STM32_NO_INIT                       FALSE
#define STM32_HSI_ENABLED                   TRUE
#define STM32_LSI_ENABLED                   FALSE
#define STM32_HSE_ENABLED                   FALSE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSI

//#define STM32_PREDIV1SRC                    STM32_PLLSRC_HSI
//#define STM32_PREDIV1_VALUE                 2
//#define STM32_PLLMUL_VALUE                  8
//#define STM32_PREDIV2_VALUE                 1
//#define STM32_PLL2MUL_VALUE                 8
//#define STM32_PLL3MUL_VALUE                 8
//#define STM32_PPRE2                         STM32_PPRE2_DIV1
//#define STM32_ADCPRE                        STM32_ADCPRE_DIV2

#define STM32_OTG_CLOCK_REQUIRED            FALSE
#define STM32_OTGFSPRE                      STM32_OTGFSPRE_DIV3
#define STM32_I2S_CLOCK_REQUIRED            FALSE
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL                        STM32_RTCSEL_NOCLOCK
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0


And also what I have in board.h in order to avoid compilation error about
STM32_PLLxCLKIN outside acceptable range


Code: Select all

/*
 * Board frequencies.
 */
#define STM32_LSECLK            0
#define STM32_HSECLK            25000000


The project is compiling fine without errors and warning but LED pin stay high and never blinks0.

I think LED pin is correctly configured:

Code: Select all

/*
 * Port A setup.
 * Everything input with pull-up except:
 * PA8  - output push-pull  (LED1).
 * PA9  - output push-pull  (LED2).
 */
#define VAL_GPIOACRL            0x88888888      /*  PA7...PA0 */
#define VAL_GPIOACRH            0x88888833      /* PA15...PA8 */
#define VAL_GPIOAODR            0xFFFFFFFF


And for information, here is the main thread:

Code: Select all

#include "ch.h"
#include "hal.h"

/*
 * Green LED blinker thread, times are in milliseconds.
 */
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {

  (void)arg;
  chRegSetThreadName("blinker");
  while (TRUE) {
    palClearPad(GPIOA, GPIOA_LED_1);
    chThdSleepMilliseconds(500);
    palSetPad(GPIOA, GPIOA_LED_1);
    chThdSleepMilliseconds(500);
  }
}

/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state.
   */
  while (true) {
    chThdSleepMilliseconds(500);
  }
}


I wonder now what I'm doing wrong with the clock configuration and why LED is not blinking ?

I can provide the full project as a zip file if it is needed.

Thank you in advance,
Jeremy

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Clock configuration issues on STM32F105 board

Postby Giovanni » Fri Mar 01, 2019 10:54 am

Hi,

I don't have HW to test is so it is pointless.

Is the thread running? place a breakpoint inside and see if it is hit periodically. If it is running the I would check GPIO settings.

Giovanni

jsavonet
Posts: 11
Joined: Fri Mar 01, 2019 10:00 am
Location: France, Lyon
Been thanked: 1 time

Re: Clock configuration issues on STM32F105 board

Postby jsavonet » Fri Mar 01, 2019 3:02 pm

Hi again,

Many many thanks Giovanni.
I figured out why the led wouldn't blink.
In fact, it was not a clock issue but a halconf issue.
The STM32F107 have a mac support and the F105 doesn't. And, as you can imagine I forgot to set the HAL_USE_MAC to false.

Now it fully functionnal.

Thank again,
Jeremy


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 20 guests