STM Micro-controllers
Here is the Quick Start Guide for the STM32 family: https://www.st.com/resource/en/application_note/dm00164549-getting-started-with-stm32f7-series-mcu-hardware-development-stmicroelectronics.pdf
Contents
ocdb/utils/micro-controllers
micro-controller
public defn micro-controller (params:Tuple<KeyValue>) -> (Tuple<KeyValue<Symbol,?>> -> Instantiable)
Calling micro-controller
will lookup a micro-controller from the JITX Parts Database. The component is wrapped inside a pcb-module
generator. micro-controller
calls the Part Query API with the list of attributes provided by the argument parameters and design variables. This function requires internet access to succeed.
Syntax
#use-added-syntax(jitx)
defpackage main :
import core
import jitx
import jitx/commands
; Required: import the micro-controllers package that defines the generator
import ocdb/utils/micro-controllers
pcb-module my-design :
; ...
; First, we specify the list of query parameters to query an MCU
val query-params = [
"core" => "ARM Cortex-M3"
]
; Next we look up the MCU generator using our query parameters.
val mcu-generator = micro-controller(query-params)
; Next, we specify the generator params. This tuple may be empty.
val generator-params = [
`cap-bypass-package => 4.7e-6
]
; Finally, we can call the generator and add it to our design.
inst mcu : generator(generator-params)
; ...
micro-controller(["core" => "ARM Cortex-M3"])
is a module generator for an STM micro-controller
based on the ARM Cortex-M3. It optionally can be run with argument [
`cap-bypass-package => 4.7e-6]
for our micro-controller
API to generate a module with the required configuration and requested capacitance for the package power supply bypass.
See the supported parameters for available query and generator parameters.
MicroController
Struct
public defstruct MicroController <: Component :
; Generic properties
manufacturer: String
mpn: String
trust: String
x: Double with: (as-method => true)
y: Double with: (as-method => true)
z: Double|False
mounting: String
rated-temperature: MinMaxRange|False
; Specific properties
core: String
core-architecture: String
data-width: Int
flash: Double
frequency: Double
io: Int
line: String
mfg-package: String
ram: Double
eeprom: Double
series: String
supply-voltage: MinMaxRange
rated-esd: Double|False
sellers: Tuple<Seller>|False with: (as-method => true)
resolved-price: Double|False with: (as-method => true)
pin-properties: STMPinProperties
bundles: Tuple<STMBundle>
supports: Tuple<STMSupports>
public defstruct MinMaxRange :
min: Double
max: Double
The MicroController
struct represents a micro-controller that can be converted into an instance or module. micro-controller
parts queries will populate the fields of this struct. Solvers may use this struct to access data without routing calls through the JITX language.
to-jitx
Takes a MicroController
struct and returns an Instantiable
.
defmethod to-jitx (m: MicroController) -> Instantiable
Syntax
#use-added-syntax(jitx)
defpackage my-design :
import core
import collections
import jitx
import jitx/commands
import ocdb/utils/db-parts
import ocdb/utils/micro-controllers
pcb-module my-module :
val mcu = MicroController(["max-io" => 40])
inst res : to-jitx(micro-controller)
MicroController
Query API
defn MicroController (parameters:Tuple<KeyValue>) -> MicroController
defn MicroController (parameters:Tuple<KeyValue>,
exist:Tuple<String>) -> MicroController
defn MicroController (parameters:Tuple<KeyValue>,
exist:Tuple<String>,
sort:Tuple<String>,
operating-temperature:[Double, Double]|False) -> MicroController
Create a Microcontroller
struct object from a set of query parameters using the Part Query API. This call requires internet access to reach the JITX parts database.
Arguments:
exist
: We can require the resulting micro-controller to have an attribute that is otherwise optional (for example "tolerance").sort
: overrides the sorting arguments that would otherwise beOPTIMIZE-FOR
.operating-temperature
: overrides the rated temperature range that would otherwise beOPERATING-TEMPERATURE
.
See the supported query parameters for available arguments to the parameters
field.
Syntax
Example: Find the best micro-controllers for our design requirements (optimizes by area by default, which is configured in `ocdb/utils/design-vars')
defpackage mcu-query :
import core
import collections
import jitx
import jitx/commands
import ocdb/utils/micro-controllers
val mcu = MicroController([])
println(mcu)
MicroController(
mpn = STM32L031G6U6
trust = low
(x, y, z) = (4.0, 4.0, 0.55)
mounting = smd
rated-temperature = MinMaxRange(min=-40.0, max=85.0)
core = ARM Cortex-M0+
core-architecture = ARM
data-width = 32
flash = 16000.0
frequency = 32000000.0
io = 21
line = STM32L0x1
mfg-package = UFQFPN28
ram = 8000.0
eeprom = 1024000.0
series = STM32L0
supply-voltage = MinMaxRange(min=-40.0, max=85.0)
rated-esd = 2000.0
sellers =
Seller(
company-name = Mouser
resolved-price = 2.55
offers = (
SellerOffer(
inventory-level = 110
prices = (
SellerOfferPrice(quantity = 1, converted-price = 3.29)
SellerOfferPrice(quantity = 10, converted-price = 2.96)
SellerOfferPrice(quantity = 50, converted-price = 2.96)
SellerOfferPrice(quantity = 100, converted-price = 2.55)
SellerOfferPrice(quantity = 250, converted-price = 2.4)
SellerOfferPrice(quantity = 500, converted-price = 2.11)
SellerOfferPrice(quantity = 1000, converted-price = 1.83)
SellerOfferPrice(quantity = 5880, converted-price = 1.82)
SellerOfferPrice(quantity = 10000, converted-price = 1.83)))))
resolved-price = 2.55)
public defn MicroControllers (properties:Tuple<KeyValue>, exist:Tuple<String>) -> Tuple<MicroController>
Similar to MicroController
but querying up to 25 micro-controllers (note the trailing s).
public defn MicroController (raw-json: JObject) -> MicroController
Creates a MicroController
from a JObject
.
Example:
defpackage query-mcu :
import core
import json
import jitx
import jitx/commands
import ocdb/utils/db-parts
import ocdb/utils/micro-controllers
val result = dbquery-first(["category" => "microcontroller"
"flash" => 32.0e3
"_stock" => 1,
"_sellers" => ["Mouser"] ])
val mcu = MicroController(result as JObject)
println(mcu)
MicroController(
mpn = STM32L010C6T6
trust = low
(x, y, z) = (9.0, 9.0, 1.6)
mounting = smd
rated-temperature = Toleranced(-40.0 <= 22.5 <= 85.0)
core = ARM Cortex-M0+
core-architecture = ARM
data-width = 32
flash = 32000.0
frequency = 32000000.0
io = 38
line = STM32L0x0
mfg-package = LQFP48
ram = 8000.0
eeprom = 256000.0
series = STM32L0
supply-voltage = MinMaxRange(min=1.8, max=3.6)
rated-esd = 2000.0
sellers =
Seller(
company-name = Mouser
resolved-price = 2.89
offers = (
SellerOffer(
inventory-level = 2
prices = (
SellerOfferPrice(quantity = 1, converted-price = 2.89)
SellerOfferPrice(quantity = 10, converted-price = 2.61)
SellerOfferPrice(quantity = 25, converted-price = 2.46)
SellerOfferPrice(quantity = 50, converted-price = 2.46)
SellerOfferPrice(quantity = 100, converted-price = 2.1)
SellerOfferPrice(quantity = 250, converted-price = 1.97)
SellerOfferPrice(quantity = 500, converted-price = 1.73)
SellerOfferPrice(quantity = 1000, converted-price = 1.43)
SellerOfferPrice(quantity = 3000, converted-price = 1.31)
SellerOfferPrice(quantity = 10000, converted-price = 1.31)))))
resolved-price = 2.89)
look-up-micro-controllers
public defn look-up-micro-controllers (attribute: String) -> Tuple
public defn look-up-micro-controllers (attribute: String, filter-properties:Tuple<KeyValue>) -> Tuple
Looks up the list of available query results for attribute
amongst micro-controllers in the JITX database. Results are capped at 1000.
This call filters on the same properties as MicroController. Additional properties filter-properties
can
be given in argument to restrict further criteria on the considered micro-controllers.
Syntax
defpackage lookup-micro-contollers :
import core
import jitx
import jitx/commands
import ocdb/utils/micro-controllers
; Query available cores in the JITX Parts Database
val available-cores = look-up-micro-controllers("core")
; Print them out
println("Available cores:")
for core in available-cores do :
println(" %_" % [core])
This function is useful for querying the currently available components in the JITX parts database.
ocdb/utils/stm-to-jitx
mcu-module
defn mcu-module (component:Instantiable) -> (Tuple<KeyValue<Symbol,?>> -> Instantiable) :
Create a microcontroller module generator from a component generated with to-jitx
from a MicroController
object.
Syntax
#use-added-syntax(jitx)
defpackage create-mcu-module :
import core
import collections
import jitx
import jitx/commands
import ocdb/utils/db-parts
import ocdb/utils/micro-controllers
import ocdb/utils/stm-to-jitx
pcb-module my-module :
; First create a MicroController object
val mcu-object = MicroController(["core" => "ARM Cortex-M3"])
; Then create an MCU instance
val mcu-instantiable = to-jitx(mcu-object)
; Now we can create an mcu-module generator
val mcu-module-generator = mcu-module(mcu-instantiable)
; And finally, create the module by calling the generator.
inst mcu : mcu-module-generator([])
micro-controller
is a wrapper around the logic above.
Supported Parameters
Supported Micro-controller Query Parameters
Parameter | Type | Description |
---|---|---|
"manufacturer" | String | The name of the manufacturer, for example `"STMicroelectronics" |
"mpn" | String | The MPN of the device. |
"line" | String | The product line of the device. |
"series" | String | The product series of the device. |
"core" | String | The core of the device, for example "ARM Cortex-M0" . |
"core-architecture" | String | The ISA of the device, for example "ARM" . |
"data-width" | Double | The data width of the device. |
"frequency" | Double | The core frequency of the device. |
"io" | Double | The number of GPIOs on the device. |
"flash" | Double | The amount of flash memory on the device. |
"ram" | Double | The amount of RAM on the device. |
"eeprom" | Double | The amount of EEPROM on the device. |
"rated-esd" | Double | The ESD rating of the device. |
"supply-voltage" | [Double, Double] | The [min, max] voltage supply requirements of the device. |
"mfg-package" | String | The package of the device. |
"rated-temperature" | [Double, Double] | The rated temperature of the device. Set by default with [../utils/design-vars.md]. |
"dimensions" | [Double, Double, Double, Double] | The [x, y, z, area] parameters of the device. |
"mounting" | String | The mounting of the component, for example "smd" or "th" |
Supported Micro-controller Module Generator Parameters
Option | Values | Default | Units | Description |
---|---|---|---|---|
`reset-pullup | Double | 10.0e3 | Ohms | The pullup resistor value on the reset pin and power. |
`reset-cap | Double | 10.0e-9 | Farads | The capacitor value between the reset pin and power. |
`p-bypass-package | Double | 4.7e-6 | Farads | The bypass capacitor value between the package power supply and ground. |
`p-bypass-pin | Double | 100.0e-9 | Farads | The bypass capacitor value between every power pin and ground. |
`boot-from | "flash" , "system" , "sram" | "flash" | The boot configuration option. | |
`boot-resistor | Double | 10.0e3 | Ohms | The boot pin resistor value. |
`debug-interface | Bundle | swd() | The desired debug interface. | |
`debug-connector | Instantiable | ocdb/components/tag-connect/TC2050-IDC-NL/module | The desired debug connector. | |
`HSE-freq | Double | 16.0e6 | Hz | High-frequency clock configuration |
`HSE-ppm | Double | 30.0e-6 | parts per million | |
`HSE-source | "crystal" , "osc" | "crystal" | ||
`LSE-freq | Double | 32.768e3 | Hz | Low-frequency clock configuration |
`LSE-ppm | Double | 0.05 | parts per million | |
`LSE-source | "crystal" , "osc" | "crystal" |
See the Parts Query API for a detailed reference on parts database queries.