STM32 Nucleo-F302R8

Support for the STM32 Nucleo-F302R8.

Overview

Not yet available upstream, see PR 6615

The Nucleo-F302 is a board from ST’s Nucleo family supporting a ARM Cortex-M4 STM32F302R8 microcontroller with 16KB of RAM and 64KB of ROM.

Hardware

MCU

MCU STM32F302R8
Family ARM Cortex-M4
Vendor ST Microelectronics
RAM 16KB
Flash 64KB
Frequency up to 72MHz
FPU yes
Timers 9 (5x 16-bit, 1x 32-bit [TIM2], 2 watchdog, 1 systick)
ADCs 1 with selectable resolution (6,8,10,12-bit)
UARTs 3
SPIs 2
I2Cs 3
RTC 1
Vcc 2.0V - 3.6V
Datasheet Datasheet
Reference Manual Reference Manual
Programming Manual Programming Manual
Board Manual Board Manual

MCU

MCU STM32F302R8
Family ARM Cortex-M4
Vendor ST Microelectronics
RAM 16KB
Flash 64KB
Frequency up to 72MHz
FPU yes
Timers 9 (5x 16-bit, 1x 32-bit [TIM2], 2 watchdog, 1 systick)
ADCs 1 with selectable resolution (6,8,10,12-bit)
UARTs 3
SPIs 2
I2Cs 3
RTC 1
Vcc 2.0V - 3.6V
Datasheet Datasheet
Reference Manual Reference Manual
Programming Manual Programming Manual
Board Manual Board Manual

Implementation Status

Device ID Supported Comments
MCU STM32F302R8 partly Energy saving modes not fully utilized
Low-level driver GPIO yes
PWM one PWM (D5)
UART three UART
I2C no
SPI one SPI (SPI2)
USB no
Timer one 32 timer (TIM2)

Flashing the device

The ST Nucleo-F302 board includes an on-board ST-LINK V2-1 programmer. The easiest way to program the board is to use OpenOCD. Once you have installed OpenOCD (look here for installation instructions), you can flash the board simply by typing

1
make BOARD=nucleo-f302 flash
and debug via GDB by simply typing
1
make BOARD=nucleo-f302 debug

Troubleshooting

For some reason the ST Link programmer can be outdated, making it impossible to flash or to access the debug UART via USB. To fix this, please use the ST Link firmware update tool following this documentation.

Troubleshooting

For some reason the ST Link programmer can be outdated, making it impossible to flash or to access the debug UART via USB. To fix this, please use the ST Link firmware update tool following this documentation.

Supported Toolchains

For using the ST Nucleo-F303RE board we strongly recommend the usage of the GNU Tools for ARM Embedded Processors toolchain.

CLOCK_CORECLOCK
1
(72000000U)
CLOCK_HSE
1
(8000000U)
CLOCK_LSE
1
(1)
CLOCK_AHB_DIV
1
RCC_CFGR_HPRE_DIV1
CLOCK_AHB
1
(CLOCK_CORECLOCK / 1)
CLOCK_APB1_DIV
1
RCC_CFGR_PPRE1_DIV2     /* max 36MHz */
CLOCK_APB1
1
(CLOCK_CORECLOCK / 2)
CLOCK_APB2_DIV
1
RCC_CFGR_PPRE2_DIV1     /* max 72MHz */
CLOCK_APB2
1
(CLOCK_CORECLOCK / 1)
CLOCK_PLL_PREDIV
1
(1)
CLOCK_PLL_MUL
1
(9)
ADC_NUMOF
1
(0)
const timer_conf_t timer_config()
1
2
3
4
5
6
7
8
9
= {
    {
        .dev      = TIM2,
        .max      = 0xffffffff,
        .rcc_mask = RCC_APB1ENR_TIM2EN,
        .bus      = APB1,
        .irqn     = TIM2_IRQn
    }
}
TIMER_0_ISR
1
isr_tim2
TIMER_NUMOF
1
(sizeof(timer_config) / sizeof(timer_config[0]))
const uart_conf_t uart_config()
UART_0_ISR
1
(isr_usart2)
UART_1_ISR
1
(isr_usart1)
UART_2_ISR
1
(isr_usart3)
UART_NUMOF
1
(sizeof(uart_config) / sizeof(uart_config[0]))
const pwm_conf_t pwm_config()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
= {
    {
        .dev      = TIM16,
        .rcc_mask = RCC_APB2ENR_TIM16EN,
        .chan     = { { .pin = GPIO_PIN(PORT_B, 4) , .cc_chan = 0 },
                      { .pin = GPIO_UNDEF,                   .cc_chan = 0 },
                      { .pin = GPIO_UNDEF,                   .cc_chan = 0 },
                      { .pin = GPIO_UNDEF,                   .cc_chan = 0 } },
        .af       = GPIO_AF1,
        .bus      = APB2
    }
}
PWM_NUMOF
1
(sizeof(pwm_config) / sizeof(pwm_config[0]))
const uint8_t spi_divtable()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
= {
    {       
        7,  
        6,  
        4,  
        2,  
        1   
    },
    {       
        7,  
        7,  
        5,  
        3,  
        2   
    }
}
const spi_conf_t spi_config()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
= {
    {
        .dev      = SPI2,
        .mosi_pin = GPIO_PIN(PORT_B, 15),
        .miso_pin = GPIO_PIN(PORT_B, 14),
        .sclk_pin = GPIO_PIN(PORT_B, 13),
        .cs_pin   = GPIO_PIN(PORT_B, 12),
        .af       = GPIO_AF5,
        .rccmask  = RCC_APB1ENR_SPI2EN,
        .apbbus   = APB1
    }
}
SPI_NUMOF
1
(sizeof(spi_config) / sizeof(spi_config[0]))
const i2c_conf_t i2c_config()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
= {
    {
        .dev            = I2C1,
        .speed          = I2C_SPEED_NORMAL,
        .scl_pin        = GPIO_PIN(PORT_B, 8),
        .sda_pin        = GPIO_PIN(PORT_B, 9),
        .scl_af         = GPIO_AF4,
        .sda_af         = GPIO_AF4,
        .bus            = APB1,
        .rcc_mask       = RCC_APB1ENR_I2C1EN,
        .rcc_sw_mask    = RCC_CFGR3_I2C1SW,
        .irqn           = I2C1_ER_IRQn
    },
    {
        .dev            = I2C3,
        .speed          = I2C_SPEED_NORMAL,
        .scl_pin        = GPIO_PIN(PORT_A, 8),
        .sda_pin        = GPIO_PIN(PORT_A, 5),
        .scl_af         = GPIO_AF5,
        .sda_af         = GPIO_AF8,
        .bus            = APB1,
        .rcc_mask       = RCC_APB1ENR_I2C3EN,
        .rcc_sw_mask    = RCC_CFGR3_I2C3SW,
        .irqn           = I2C3_ER_IRQn
    }
}
I2C_0_ISR
1
isr_i2c1_er
I2C_1_ISR
1
isr_i2c3_er
I2C_NUMOF
1
(sizeof(i2c_config) / sizeof(i2c_config[0]))