Setting up the board.h for STM32F100

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

Moderator: RoccoMarco

Post Reply
noether
Posts: 91
Joined: Wed Nov 16, 2011 3:18 pm

Setting up the board.h for STM32F100

Post by noether »

Hi,

whereas the setting up for STM32F4 is quite clear in board.h, in my opinion it is a little bit confusing for STM32F100.
I have taken the example for the DiscoveryVL board and I am trying to modify it. My board.h looks like

Code: Select all

/*
 * IO pins assignments.
 */
#define GPIOA_CH1               0
#define GPIOA_CH2               1
#define GPIOA_USART2_TX    2
#define GPIOA_USART2_RX    3
#define GPIOA_ADC1_IN4       4
#define GPIOA_ADC1_IN5       5
#define GPIOA_CH5                6
#define GPIOA_CH6                7
#define GPIOA_JTMS             13
#define GPIOA_JTCK              14
#define GPIOA_JTDI               15

#define GPIOB_JTDO              3
#define GPIOB_NJTRST           4
#define GPIOB_SAFETY          5


Where CHx stands for TIM acting as a PWM.

How should I define VAL_GPIOACRL for PWM? and for the ADC? the same for I2C and JTAG (specially here, because I want to communicate with the micro after the set up).
So far it works for JTAG just assigning an '8' to their pins, but according to the doc in the file this is a "Digital input with PullUp or PullDown resistor depending on ODR.". But JTDO is
an output isnt it?

I would like to do not put any initialization code outside of the board.{c, h} (beside of adcStart or pwmStart)

Can I start this peripherals directly in board.h just with the default defines? or should I write some "palSetGroupMode" and "AFIO->MAPR | blabla" in board.c?


EDIT
-------
Also about the clock. My external clock is 24MHz. According to the documentation the SYSCLK can not be higher than 24MHz. Then I would like a Prediv equal to 1, or just HSE as a SYSCLK, but
the value 1 is not allowed for STM32_PLLMUL_VALUE.

Setting STM32_PLLMUL_VALUE = 2, and STM32_PLLXTPRE = STM32_PLLXTPRE_DIV2 works, is that right in order to have a SYSCLK of 24MHz? I do not know whether this is the configuration with higher accuracy.


Thanks in advance!
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Setting up the board.h for STM32F100

Post by Giovanni »

Hi,

The GPIO is different (and older) on the F100 so the setup is different.

In the board.h file there is legend for I/O settings, the PWM should be alternate push-pull (9, A or B), the ADC inputs should be Analog (0). Keep JTAG pin settings to the defaults described in the RM, probably you just need the SWD pins only because the ST-Link uses that, not all JTAG pins are required (see board schematic).

You can setup your pins in board.h but sometimes it is better to put all pins in a safe state in board.h and then switch them to the real mode AFTER starting the driver in order to avoid glitches.

About the clock, you could use HSE as clock source and do not activate the PLL at all, this would save some power.

Giovanni
noether
Posts: 91
Joined: Wed Nov 16, 2011 3:18 pm

Re: Setting up the board.h for STM32F100

Post by noether »

Thank you very much for your answers Giovanni.

The board is custom and I prefer JTAG with my current set up. I have put all of them at "8", and so far I can communicate with the micro without problems.
Good point about selecting the HSE instead of the output of the PLL, I will give it a try.

Thanks also for the advise of setting up the peripherals after the starting the driver, I will take a look at it.
Post Reply