Introduction to STM32WB55
Table of Contents
About STMicroelectronics
STMicroelectronics is a leading provider of semiconductor solutions that are seamlessly integrated into billions of electronic devices used by people worldwide on a daily basis.
The semiconductor company builds products, solutions, and ecosystems that enable smarter mobility, more efficient power and energy management, and the wide-scale deployment of the Internet of Things and connectivity technologies. To know more about STMicroelectronics refer to its website: www.st.com.
Going back in history, ST was formed in 1987 by the merger of two government-owned semiconductor companies: Italian SGS Microelettronica (where SGS stands for Società Generale Semiconduttori, “Semiconductors’ General Company”), and French Thomson Semiconductors, the semiconductor arm of Thomson.
In this blog, we are going to start with ST IoT-based Nucleo Board STm32WB55.
What is STM32WB Series all about?
The STM32WB55xx and STM32WB35xx are advanced multiprotocol wireless devices that boast ultra-low-power consumption. These devices are equipped with a powerful and efficient radio that is compliant with the Bluetooth® Low Energy SIG specification 5 and IEEE 802.15.4-2011 (Zigbee). Additionally, they feature a dedicated Arm® Cortex®-M0+ processor that handles all real-time low-layer operations.
These cutting-edge devices are perfect for a wide range of applications that require reliable and efficient wireless communication. Whether you’re working on a smart home project, a wearable device, or an industrial automation system, the STM32WB55xx and STM32WB35xx are the ideal choices.
With their advanced features and capabilities, these devices are sure to revolutionize the way we think about wireless communication. So why wait? Start exploring the possibilities today and discover what the STM32WB55xx and STM32WB35xx can do for you!
The devices have been meticulously crafted to operate on minimal power and are built around the high-performance Arm® Cortex®-M4 32-bit RISC core, which can operate at a frequency of up to 64 MHz. This core boasts a Floating-point unit (FPU) single precision that supports all Arm® single-precision data-processing instructions and data types. Additionally, it is equipped with a full set of DSP instructions and a memory protection unit (MPU) that enhances application security.
These devices have been designed with the utmost care and attention to detail, ensuring that they are not only efficient but also highly effective. The Arm® Cortex®-M4 32-bit RISC core is a powerful tool that enables these devices to perform at an exceptional level, while the FPU single precision and DSP instructions provide unparalleled accuracy and precision. Furthermore, the memory protection unit (MPU) ensures that your applications are secure and protected from any potential threats.
Enhanced inter-processor communication is provided by the IPCC with six bidirectional channels. The HSEM provides hardware semaphores used to share common resources between the two processors.
The devices embed high-speed memories (up to 1 Mbyte of flash memory for STM32WB55xx, up to 512 Kbytes for STM32WB35xx, up to 256 Kbytes of SRAM for STM32WB55xx, 96 Kbytes for STM32WB35xx), a Quad-SPI flash memory interface (available on all packages) and an extensive range of enhanced I/Os and peripherals. 
About STM32WB55
Architecture
The host application is housed on an Arm® Cortex®-M4 CPU (named CPU1) that connects with a generic microcontroller subsystem.
The RF subsystem is made up of a specialized Arm® Cortex®-M0+ microprocessor (named CPU2), Bluetooth Low Energy and 802.15.4 digital MAC blocks, an RF analog front end, and proprietary peripherals. All Bluetooth Low Energy and 802.15.4 low-layer stack functions are handled by the RF subsystem, which limits communication with the CPU1 to high-level exchanges.
Some functions are shared between the RF subsystem CPU (CPU2) and the Host CPU (CPU1):
- Flash memories
- SRAM1, SRAM2a, and SRAM2b (SRAM2a can be retained in Standby mode)
- Security peripherals (RNG, AES1, PKA)
- Clock RCC
- Power control (PWR)
Memories
2.1. Adaptive real-time memory accelerator (ART Accelerator)
The ART Accelerator is a memory accelerator optimized for STM32 industry-standard Arm® Cortex®-M4 processors. It balances the inherent performance advantage of the Arm® Cortex®-M4 over flash memory technologies.
To release the processor near 80 DMIPS performance at 64 MHz, the accelerator implements an instruction prefetch queue and branch cache, which increases program execution speed from the 64-bit flash memory. Based on CoreMark benchmark, the performance achieved thanks to the ART accelerator is equivalent to 0 wait state program execution from flash memory at a CPU frequency up to 64 MHz.
2.2. Memory protection unit
In order to prevent one task from unintentionally corrupting the memory or resources used by any other active task, the memory protection unit (MPU) is used to manage the CPU1’s accesses to memory. This memory area is organized into up to eight protected areas.
The MPU is especially helpful for applications where some critical or certified code must be protected against the misbehavior of other tasks. It is usually managed by an RTOS (real-time operating system).
2.3. Embedded flash memory
The STM32WB55xx and STM32WB35xx devices feature, respectively, up to 1 Mbyte and 512 Kbytes of embedded flash memory available for storing programs and data, as well as some customer keys.
2.4. Embedded SRAM
The STM32WB55xx devices feature up to 256 Kbytes of embedded SRAM, split in three blocks:
- SRAM1: up to 192 Kbytes mapped at address 0x2000 0000
- SRAM2a: 32 Kbytes located at address 0x2003 0000 also mirrored at 0x1000 0000, with hardware parity check (this SRAM can be retained in Standby mode)
- SRAM2b: 32 Kbytes located at address 0x2003 8000 (contiguous with SRAM2a) and mirrored at 0x1000 8000 with hardware parity check.
Security and Safety
The STM32WB55xx contain many security blocks both for the Bluetooth Low Energy or IEEE 802.15.4 and the Host application. It includes:
- Customer storage of the Bluetooth Low Energy and 802.15.4 keys
- Secure flash memory partition for RF subsystem-only access
- Secure SRAM partition, that can be accessed only by the RF subsystem
- True random number generator (RNG)
- Advance encryption standard hardware accelerators (AES-128bit and AES-256bit, supporting chaining modes ECB, CBC, CTR, GCM, GMAC, CCM)
- Private key acceleration (PKA)
- Cyclic redundancy check calculation unit (CRC)
True random number generator (RNG)
The devices embed a true RNG that delivers 32-bit random numbers generated by an integrated analog circuit.
RF Subsystem
The STM32WB55xx embeds an ultra-low power multi-standard radio Bluetooth Low Energy and 802.15.4 network processor, compliant with Bluetooth specification 5.3 and IEEE® 802.15.4-2011. The Bluetooth Low Energy features 1 Mbps and 2 Mbps transfer rates, supports multiple roles simultaneously acting at the same time as Bluetooth Low Energy sensor and hub device.
The Bluetooth Low Energy stack and 802.15.4 Low Level layer run on an embedded Arm® Cortex®-M0+ core (CPU2). The stack is stored on the embedded flash memory, which is also shared with the Arm® Cortex®-M4 (CPU1) application, making it possible in-field stack update.
4.1. RF Front-End Block Diagram
The RF front-end is based on a direct modulation of the carrier in Tx, and uses a low IF architecture in Rx mode. Thanks to an internal transformer at RF pins, the circuit directly interfaces the antenna (single ended connection, impedance close to 50 Ω).
In Transmit mode, the maximum output power is user selectable through the programmable LDO voltage of the power amplifier. A linearized, smoothed analog control offers clean power ramp-up.
In Receiving mode the circuit can be used in standard high performance or in reduced power consumption (user programmable). The Automatic gain control (AGC) is able to reduce the chain gain at both RF and IF locations, for optimized interference rejection.
4.2. BLE Description
It integrates a 2.4 GHz RF transceiver and a powerful Cortex®-M0+ core, on which a complete power-optimized stack for Bluetooth Low Energy protocol runs, providing master / slave role support
- GAP: central, peripheral, observer or broadcaster roles
- ATT/GATT: client and server
- SM: privacy, authentication and authorization
- L2CAP
- Link layer: AES-128 encryption and decryption
In addition, according to Bluetooth specification 5.3, the Bluetooth Low Energy block provides:
- Multiple roles simultaneous support
- Master/slave and multiple roles simultaneously
- LE data packet length extension (making it possible to reach 800 kbps at application level)
- LE privacy 1.2
- LE secure connections
- Flexible Internet connectivity options
- High data rate (2 Mbps)
The device also supports Piconet and Scatternet.
Ultra-low-power sleep modes and very short transition time between operating modes result in very low average current consumption.
4.3. Zigbee (802.15.4) Description
The STM32WB55xx embeds a dedicated 802.15.4 hardware MAC:
- Support for 802.15.4 release 2011
- Advanced MAC frame filtering; hardwired firewall: Programmable filters based on source/destination addresses, frame version, security enabled, frame type
- 256-byte RX FIFO; Up to 8 frames capacity, additional frame information (timing, mean RSSI, LQI)
- 128-byte TX FIFO with retention
- Automatic frame acknowledgment, with programmable delay
- Advanced channel access features
- Configuration registers with retention available down to Standby mode for software/auto-restore
- Autonomous sniffer, wake-up based on timer or CPU2 request
- Automatic frame transmission/reception/sleep periods, Interrupt to the CPU2 on particular events
Low Power Modes
- Sleep
In Sleep mode, only the CPU1 is stopped. All peripherals, including the RF subsystem, continue to operate and can wake up the CPU when an interrupt/event occurs.
- Low-power run
This mode is achieved with VCORE supplied by the low-power regulator to minimize the regulator operating current. The code can be executed from SRAM or from the flash memory, and the CPU1 frequency is limited to 2 MHz. The peripherals with independent clock can be clocked by HSI16. The RF subsystem is not available in this mode and must be OFF.
- Low-power sleep
This mode is entered from the low-power run mode. Only the CPU1 clock is stopped. When wake-up is triggered by an event or an interrupt, the system reverts to the low-power run mode. The RF subsystem is not available in this mode and must be OFF.
- Stop 0, Stop 1 and Stop 2
Stop modes achieve the lowest power consumption while retaining the content of all the SRAM and registers. The LSE (or LSI) is still running. The RTC can remain active (Stop mode with RTC, Stop mode without RTC). Some peripherals with wake-up capability can enable the HSI16 RC during Stop modes to detect their wake-up condition. Three modes are available: Stop 0, Stop 1 and Stop 2.
In Stop 2 mode, most of the VCORE domain is put in a lower leakage mode.
Stop 1 offers the largest number of active peripherals and wake-up sources, a smaller wake-up time but a higher consumption than Stop 2.
In Stop 0 mode the main regulator remains ON, allowing a very fast wake-up time but with higher consumption. In these modes the RF subsystem can wait for incoming events in all Stop modes. The system clock when exiting from Stop 0, Stop1 or Stop2 modes can be either MSI up to 48 MHz or HSI16 if the RF subsystem is disabled.
- Standby
The Standby mode is used to achieve the lowest power consumption with BOR. The internal regulator is switched off so that the VCORE domain is powered off. The RTC can remain active (Standby mode with RTC).
After entering Standby mode, SRAM1, SRAM2b and register contents are lost except for registers in the Backup domain and Standby circuitry. Optionally, SRAM2a can be retained in Standby mode, supplied by the low-power regulator (Standby with 32 KB SRAM2a retention mode).
The system clock after wake-up is 16 MHz, derived from the HSI16. If used, the SMPS is restarted automatically. In this mode the RF can be used.
- Shutdown
This mode achieves the lowest power consumption. The internal regulator is switched off so that the VCORE domain is powered off. The RTC can remain active (Shutdown mode with RTC, Shutdown mode without RTC). The BOR is not available in Shutdown mode. No power voltage monitoring is possible in this mode, therefore the switch to Backup domain is not supported. SRAM1, SRAM2a, SRAM2b and register contents are lost except for registers in the Backup domain.
The system clock after wake-up is 4 MHz, derived from the MSI. In this mode the RF is no longer operational.
Clocks and Startup
The STM32WB55xx device integrate several clock sources:
- LSE: 32.768 kHz external oscillator, for accurate RTC and calibration with other embedded RC oscillators
- LSI1: 32 kHz on-chip low-consumption RC oscillator
- LSI2: almost 32 kHz, on-chip high-stability RC oscillator, can be used by the RF subsystem instead of LSE
- HSE: high-quality 32 MHz external oscillator with trimming, needed by the RF subsystem
- HSI16: 16 MHz high accuracy on-chip RC oscillator
- MSI: 100 kHz to 48 MHz multiple speed on-chip low power oscillator, can be trimmed using the LSE signal
- HSI48: 48 MHz on-chip RC oscillator, for USB crystal-less purpose.
STM32 WB55 has Clock Controller, which has following features:
- Clock prescaler: to get the best trade-off between speed and current consumption, the clock frequency to the CPU and peripherals can be adjusted by a programmable prescaler • Safe clock switching: clock sources can be changed safely on the fly in run mode through a configuration register.
- Clock management: to reduce power consumption, the clock controller can stop the clock to the core, individual peripherals or memory.
- System clock source: four different clock sources can be used to drive the master clock SYSCLK.
- Auxiliary clock source: two ultralow-power clock sources that can be used to drive the LCD controller and the real-time clock.
- Peripheral clock sources: Several peripherals (RNG, SAI, USARTs, I2Cs, LPTimers, ADC) have their own independent clock whatever the system clock. Two PLLs, each having three independent outputs for the highest flexibility, can generate independent clocks for the ADC, the RNG and the SAI.
- Startup clock: after reset, the microcontroller restarts by default with an internal 4 MHz clock (MSI). The prescaler ratio and clock source can be changed by the application program as soon as the code execution starts.
- Clock security system (CSS): this feature can be enabled by software. If an HSE clock failure occurs, the master clock is automatically switched to HSI16 and a software interrupt is generated if enabled. LSE failure can also be detected and an interrupt generated.
GPIO
Each of the GPIO pins can be configured by software as output (push-pull or open-drain), as input (with or without pull-up or pull-down) or as peripheral alternate function. Most of the GPIO pins are shared with digital or analog alternate functions. Fast I/O toggling can be achieved thanks to their mapping on the AHB2 bus.
DMA
Direct memory access (DMA) is used to provide high-speed data transfer between peripherals and memory as well as between memories. Data can be quickly moved by DMA without any CPU action. This keeps CPU resources free for other operations.
Here the two DMA embeds inside the controllers have fourteen channels in total, a full cross matrix allows any peripheral to be mapped on any of the available DMA channels. Each DMA has an arbiter for handling the priority between DMA requests.
Interrupts and Events
9.1. NVIC (Nested Vectored Interrupt Controller)
The devices embed a nested vectored interrupt controller able to manage 16 priority levels, and handle up to 63 maskable interrupt channels plus the 16 interrupt lines of the Cortex®-M4 with FPU.
The NVIC benefits are the following:
- Closely coupled NVIC gives low latency interrupt processing
- Interrupt entry vector table address passed directly to the core
- Allows early processing of interrupts
- Processing of late arriving higher priority interrupts
- Support for tail chaining
- Processor state automatically saved
- Interrupt entry restored on interrupt exit with no instruction overhead
9.2. Extended Interrupts and Events Controller (EXTI)
The EXTI manages wake-up through configurable and direct event inputs. It provides wake-up requests to the Power control, and generates interrupt requests to the CPUx NVIC and events to the CPUx event input.
ADC
The device embeds a successive approximation analog-to-digital converter with the following features:
- 12-bit native resolution, with built-in calibration.
- Up to 16-bit resolution with 256 oversampling ratio.
- 4.26 Msps maximum conversion rate with full resolution .
- Up to sixteen external channels and three internal channels: internal reference voltages, temperature sensor • Single-ended and differential mode inputs.
- Low-power design .
- Highly versatile digital interface.
Comparators (COMP)
The STM32WB55xx device embeds two rail-to-rail comparators with programmable reference voltage (internal or external), hysteresis, and speed (low-speed for low power) and with selectable output polarity.
The reference voltage can be one of the following:
- External I/O .
- Internal reference voltage or submultiple (1/4, 1/2, 3/4).
Touch Sensing Controller
The touch sensing controller provides a simple solution for adding capacitive sensing functionality to any application. Capacitive sensing technology is able to detect finger presence near an electrode which is protected from direct touch by a dielectric such as glass or plastic.
The main features of the touch sensing controller are the following:
- Robust surface charge transfer acquisition principle
- Supports up to 18 capacitive sensing channels
- Up to six capacitive sensing channels can be acquired in parallel offering a very good response time.
- Spread spectrum feature to improve system robustness in noisy environments.
- Full hardware management of the charge transfer acquisition sequence
- Programmable charge transfer frequency
- Programmable sampling capacitor I/O pin
- Programmable channel I/O pin.
- Programmable max count value to avoid long acquisition when a channel is faulty.
- Dedicated end of acquisition and max count error flags with interrupt capability .
- One sampling capacitor for up to three capacitive sensing channels to reduce the system components.
- Compatible with proximity, touch key, linear and rotary touch sensor implementation.
Liquid crystal display controller (LCD)
The STM32WB55xx devices embed an LCD controller with the following characteristics:
- Highly flexible frame rate control.
- Supports Static, 1/2, 1/3, 1/4 and 1/8 duty.
- Supports Static, 1/2, 1/3 and 1/4 bias.
- Double-buffered memory allows data in LCD_RAM registers to be updated at any time by the application firmware without affecting the integrity of the data displayed.
- Software selectable LCD output voltage (contrast) from VLCDmin to VLCDmax.
- No need for external analog components.
- The contrast can be adjusted using two different methods.
- Full support of low-power modes: the LCD controller can be displayed in Sleep, Low-power run, Low-power sleep and Stop modes, or can be fully disabled to reduce power consumption.
- Built in phase inversion for reduced power consumption and EMI (electromagnetic interference).
- Start of frame interrupt to synchronize the software when updating the LCD data RAM. • Blink capability.
Timers and watchdogs
The STM32WB55xx includes one advanced 16-bit timer, one general purpose 32-bit timer, two 16-bit basic timers, two low-power timers, two watchdog timers and a SysTick timer.
Real-time clock (RTC) and backup registers
The RTC is an independent BCD timer/counter, supporting the following features:
- Calendar with subsecond, seconds, minutes, hours (12 or 24 format), week day, date, month, year, in BCD (binary-coded decimal) format.
- Automatic correction for 28, 29 (leap year), 30, and 31 days of the month.
- Two programmable alarms.
- On-the-fly correction from 1 to 32767 RTC clock pulses. This can be used to synchronize it with a master clock.
- Reference clock detection: a more precise second source clock (50 or 60 Hz) can be used to enhance the calendar precision.
- Digital calibration circuit with 0.95 ppm resolution, to compensate for quartz crystal inaccuracy.
- Three anti-tamper detection pins with programmable filter.
- Timestamp feature, which can be used to save the calendar content. This function can be triggered by an event on the timestamp pin, or by a tamper event, or by a switch to VBAT mode.
- 17-bit auto-reload wake-up timer (WUT) for periodic events with programmable resolution and period.
The backup registers are 32-bit registers used to store 80 bytes of user application data when VDD power is not present. They are not reset by a system or power reset, or when the device wakes up from Standby or Shutdown mode.
Inter Integrated Circuit (I2C)
The I2C bus interface handles communications between the microcontroller and the serial I2C bus. It controls all I2C bus-specific sequencing, protocol, arbitration and timing.
The device has 2 I2C peripherals which supports:
- Slave and master modes, multimaster capability
- Standard-mode (Sm), with a bitrate up to 100 kbit/s
- Fast-mode (Fm), with a bitrate up to 400 kbit/s .
- Fast-mode Plus (Fm+), with a bitrate up to 1 Mbit/s and 20 mA output drive I/Os .
- 7-bit and 10-bit addressing mode, multiple 7-bit slave addresses .
- Programmable setup and hold times .
- Optional clock stretching.
UART
UART
The devices embed one universal synchronous receiver transmitter. and one Low-Power UART.
The USART is able to communicate at speeds of up to 4 Mbit/s.It provides hardware management of the CTS and RTS signals, and RS485 driver enable.
The USART has a clock domain independent from the CPU clock, allowing it to wake up the MCU from Stop mode using baud rates up to 200 kbaud. The wake up events from Stop mode are programmable and can be:
- the start bit detection
- any received data frame
- a specific programmed data frame.
The USART interface can be served by the DMA controller.
LP-UART
The device embeds one Low-Power UART, enabling asynchronous serial communication with minimum power consumption. The LPUART supports half duplex single wire communication and modem operations (CTS/RTS), allowing multiprocessor communication.
The LPUART has a clock domain independent from the CPU clock, and can wake-up the system from Stop mode using baud rates up to 220 kbaud. The wake up events from Stop mode are programmable and can be:
- the start bit detection
- any received data frame
- a specific programmed data frame.
Only a 32.768 kHz clock (LSE) is needed for LPUART communication up to 9600 baud. Therefore, even in Stop mode, the LPUART can wait for an incoming frame while having an extremely low energy consumption. Higher speed clock can be used to reach higher baud rates.
The LPUART interfaces can be served by the DMA controller.
SPI
Two SPI interfaces enable communication up to 32 Mbit/s in master and up to 24 Mbit/s in slave modes, in half-duplex, full-duplex and simplex modes. The 3-bit prescaler gives 8 master mode frequencies and the frame size is configurable from 4 bits to 16 bits. The SPI interfaces support NSS pulse mode, TI mode and Hardware CRC calculation.
The SPI interfaces can be served by the DMA controller.
Serial audio interfaces (SAI)
The device embeds a dual channel SAI peripheral that supports full duplex audio operation. The SAI bus interface handles communications between the microcontroller and the serial audio protocol.
The SAI peripheral supports:
- One independent audio sub-block that can be a transmitter or a receiver, with the respective FIFO
- 8-word integrated FIFOs
- Synchronous or asynchronous mode
- Master or slave configuration
- Clock generator to target independent audio frequency sampling when audio sub-block is configured in master mode
- Data size configurable: 8-, 10-, 16-, 20-, 24-, 32-bit
- Peripheral with large configurability and flexibility allowing to target as example the following audio protocol: I2S, LSB or MSB-justified, PCM/DSP, TDM, AC’97 and SPDIF out
- Up to 16 slots available with configurable size and with the possibility to select which ones are active in the audio frame
- Number of bits by frame may be configurable
- Frame synchronization active level configurable (offset, bit length, level) • First active bit position in the slot is configurable
- LSB first or MSB first for data transfer
- Mute mode
- Stereo/Mono audio frame capability
- Communication clock strobing edge configurable (SCK)
- Error flags with associated interrupts if enabled respectively.
- DMA interface with two dedicated channels to handle access to the dedicated integrated FIFO of the SAI audio sub-block.
QUADSPI
The Quad-SPI is a specialized communication interface targeting single, dual or quad SPI flash memories.
It can operate in any of the three following modes:
- Indirect mode: all the operations are performed using the QUADSPI registers
- Status polling mode: the external memory status register is periodically read and an interrupt can be generated in case of flag setting
- Memory-mapped mode: the external flash memory is mapped and is seen by the system as if it
REFERENCES
What is Microcontroller Technology?
Brief history of Microcontroller Microcontroller is an innovative technology that has revolutionize the world and made the electronic items so much feasible for us. Though microcontrollers have been in world since 1960’s. Its been around 60 years since the invention of Microcontroller technology and their are more then x amount of microcontroller being deployed right now in world. Lets explore and go back to history of microcontroller’s: What are Microcontrollers is an electronic chip which is designed in a way to do general tasks till eternity The life cycle of Microcontroller’s Microcontroller is designed from transistors, millions and millions and even billions of transistors are minitirised into small size, to form building blocks of MCU, and these building blocks give them ability to control anything. The building blocks of MCU are: CPU, Memory and Peripherals. We will dive into these blocks after couple of minutes. The designing of these transistors is an art and science behind the chip designing. This art of technology is called as VLSI( Very Large Scale Integration). And Once the designing is done then these Chips are fabricated/manufactured to give us a final by product that is physical MCU chip. And This part is done by fabrication companies like TSMC. And after that fabrication, the packaging/assemble of integrated chip happens so that these millions and millions of transistors which are minitiasuered are enabled for practical usage in electronic devices. And after that programming on these MCU and extra circuietry around these MCU’s is developed to make the MCU do any specific task till eternity. These part are referred as Embedded Systems, in which software and hardware arounf the microcontroller is developed to make it use in final end product. Part of Software development for Microcontrolleris called Embedded Software Development and part of Hardware development for MCU is called Embedded Hardware Development. In this video and cahpter we will just get ourselves stick to microcontroller technology, and focus on what things are involved for learning and using microcontroller. Though their are many topics and technologies which can be deep dive, which we will do in separate videos. Building blocks of Microcontroller chip are Microcontroller chips have 3 building block, first is CPU, second is Memory and third is peripherals. For better understanding take the analogy of microcontroller with human body. Just like their is human body, same way their is microcontroller. In human body we have brain which does all the processing, calculations and thinking. In the case of microcontroller, CPU does all that. Then in human body we have body parts to interact with outside world, same way microcontroller have different peripherals to interact with outside world. We humans have memory/yadash based on which we do the work and do the tasks. How to sit, how to walk, how to use legs, how to use different body parents, and all these things are feed in our memory, same way microcontrollers have memory, into which instructions are written on how to use its different peripherals and how to control those peripherals and what to do when some data comes from those peripherals. Now lets just deep dive into these functional blocks in more technical understadning and learning. CPU CPU stands for Central Processing Unit, it is an integral part of microcontroller which does all the hardcore computing work. computing work in terms of electronic chip means: addition, subtraction, multiplication, division of electronic data. How fast this can be done and level of complex calculations it can do. CPU does the computing work, by a set of basic rules on how a CPU should work. These set of rules are called as Instruction Set Architecture(ISA). Their are 2 most popular types of ISA: RISC( Reduced Instruction Set Computer) CISC(Complex Instruction Set Computer) In Current modern world, RISC architecture based CPUs and microcontroller are what is widely used and adaptoped. Examples of RISC is ARM CPU that we see in Apple MAC book the M1 chip. another example is RISC-5 CPU, that we can see in Vega processor, which is Indias first indegenoious CPU designed by xyz organization Examples of CISC is Intel 4004, which is world’s first commercially avialable CPU launched in 1971. Another is x86 CPU, most desktops and laptops sold are based on x86 CPU. Ther terminology which we hear intel I5 processor and all they all are part os these CPU’s. Often CPU word/terminology is used interchanagible with processor or core. So whereever we mention, processor/core or CPU words they mean same thing. Another important factor on which CPU computing work matters is bit size of CPU. Meaning how much size of data CPU can execute at a time. We measure this thing in bits unit. So their are 8 bits, 16 bits and 32 bits CPU’s. In Which 8 bit CPU means it can at a time can execute data of 8 bit length. 16 and 32 bit CPU means they can execute data of 16 bit and 32 bit length. Now as the bit size of CPU increases, it means more pwoerfull and fast tehy are. For now we are not going too much in detail about CPU types, history and its world as that will deviate us from current topic of microcontroller. We will explore in detail about these terminologies in what is microprocessor technology. Peripherals: Peripherals are body parts of Microcontroller, it is peripherals through which micrcontroller interacts with outside world. Their can be more then 20 peripherals in some MCU’s and in some MCU’s their can be just 5 peripherals. Their are some general purpose peripheral which are their in all or most of the MCU’s: which are GPIO, ADC, TIMERS, I2C, SPI, UART. Using these peripherals one can process and control any sensor/module connected to MCU. I2C, SPI and UART are communication protocol via which we can connect almost any sensor/module to MCU. Be it LCD screen, ethernet module, audio devices, wifi modules or any other sensor. And via GPIO, TIMER and ADC peripherals we can sample and
FlexTimer peripheral of NXP S32K1xx MCU( S32K144 MCU and ElecronicsV3 Board)
About FlexTimer Peripheral of S32K144 MCU: What is FlexTIMER Peripheral? FlexTimer is a peripheral present in NXP S32K1xx MCU’s, which is used for input capture, output capture, generation of PWM signals and time delays. We are going to focus on PWM signals part and usecase of FTM Peripheral for generating PWM signals. As FTM is a peripheral of MCU, so it has intances and with each instance certain number of MCU pins which are referred as channels. In S32K144 their are 4 instances of FTM and each instance has 8 channels. Instances are abrievted as FTM0, FTM1, FTM2 and FTM3. Each Instance has its own Peripheral registers where the configuration of those instances is done. Their are number of registers, in FTM peripheral through which its configuration for different features is done and we also get status. We are not going to dive into every register, will mention important registers, as in industry register level coding is not implemented but understanding of registers is what is important. Each Instance has 8 channels, which are reffered as CH0-CH7. So naming convection goes like this: Table showing FTM Instance and Then FTM Channels of that sinstance and all MCU pins which can be used for that channel. For PWM, FTM Peripheral has following functnalities and features PWM Signal Type: Center Aligned and Edge Aligned PWM Signals: Combine Mode PWM signals in inverted/duplicate PWM Interrupts: Every channel has interrupt source. Interrupt can be generated on counter match or counter overflow. Detection of rising and failing edges of PWM signals: We can configure interrupt generation when counter matches or overflows based on the polaruty of PWM signal. Hardware-Software Trigger: Generation of PWM signals and variation of PWM parameters at the detection of some hardware specific events. Lets say we want to generate PWM pulse only when some ADC readings are taken. So we can configure PWM signal to generate when ADC hardware conversion si done. Fault control and synchronization points. How FTM peripheral works is, For understanding the ftm peripheral features and functionalities we will understand them via storytelling!!! Story telling in terms of what steps have to be followed to use ftm peripheral and correspondingly covering its different features. We configure the clock values for ftm peripheral, that is whether the ftm peripheral is going to get clock from system clock, fixed clock or external clock and also configures the prescaler values, to divide the ftm clock if needed. FTM CLOCK CONFIGURATION IS IMPORTANT step as based on this only, parameters of pwm signals are calculated. Their are 3 inputs of clocks for FTM peripheral: either system clock, or crystal oscillator clock( that is fixed clock) or some external clock ( connected to some pin of MCU). After that we configure in which mode FTM peripheral has to be used, whether input capture mode, output capture mode. Output capture mode is what we are going to use. Output capture mode means outputings some digital signals. And Input capture mode means inputting some digital signals. After output capture mode, which type of pwm signal. These settings are done by setting the values of highlighted bits according to following table. These bits are part of these registers. Based on the mode of ftm peripheral, ftm peripheral will work. As in this module we are learning and focusing on pwm signals, so we highlighted sections of table is what is going to be of our concern. Edge Aligned Mode Center Aligned Mode Combine Mode(Complementary) Each Instance has 8 channels, so every channel has its own peripheral registers by the name of CnSC. In CnSC register this pwm mode of configuration is done. After that, we configure the values into counters of FTM. As stated Timer peripheral has 3 counters in it. MAX counter, Variable counter and Threshold counter. In FTM peripheral MAX counter is MOD peripheral register. Value put on this register determines the frequency /period of pwm signal. Variable register is COUNT peripheral register. This counter starts incrementing from 0 once ftm peripheral is enabled or triggered. Threshol Counter we will touch in couple of mins after. For each channel their is register CnV. This register act as Threshold counter for pwm signal coming from corresponding channel or we can say pin of mcu. Value put on this register will determine the duty cycle of the signal as when COUNT counter matches the value of this register, pwm signal state changes according to configured polarity. Now polarity of pwm channel will determine, whether pwm signal would have high to low transition or low to high transition on counter match. The polarity configuration is important as this will determine the duty cycle parameter. So there are 2 things in polarity, state of pwm signal before counter match and state of pwm signal after counter match. Based on polarity configuration, rising or failing edges would be generated on counter match and counter overflows. 6) Another important thing is updates of counter registers and pwm polarity. You see, counter registers like MOD, CnV and COUNT very much control the PWM signal parameters and PWM polarity register bits control the logic levels of pwm signal. Ftm peripheral has feature to configure when these register values should be updated, that is either on software trigger means software will write the Data on the registers and it would be loaded into them. Or hardware trigger that on detection of sone external signal, the values of these registers would be changed. This updation of register is also called as Reload point of counter registers and values in FTM peripheral. If we are using interrupts then interrupt configuration is also done for each indiviual channel for different events. By events we mean counter match or counter overfflow. For every channels of FTM Instance their are bits in x register, If we set these bits then interrupt functionaly would be on for those Channels. When Counter match happens then channel interrupt handlers are fired and when counter oveflow happens then overflow interrupt handler is fired. Overflow interrupt handler is comman
PWM Driver of Autosar MCAL Layer
What is PWM Driver? PWM Driver is the library for generating PWM signals via Automotive MCU’s. This Driver is part of Autosar MCAL layer and it is global level RTD standard that is followed by all semiconductor companies to generate the PWM signals using their microcontrollers for automotive applications. This specification describes the API for generating and handling different PWM signals via automotive MCU’s. This software module includes GUI interface for initialization, configuration of PWM channels and peripheral instances. It supports the framework for using advance to basic features which are their with PWM peripherals of different MCU’s through which PWM signals are generated.. Also PWM Driver handles the variation of PWM parameters like Frequency, Duty Cycle, Timer Period and etc. PWM Driver can handles all the advance features like fault control, synchronization points, hardware trigger, softare control values, complementary PWM signals, DMA/Interrupts for PWM signals. . PWM Driver is built over the peripheral IP layer of the Microcontroller and driving functionalities. Main objectives of this monolithic SPI Handler/Driver are to take the best of each microcontroller features and to allow implementation optimization depending on static configuration to fit as much as possible to ECU needs. Hence, this specification defines selectable levels of functionalities and configurable features to allow the design of a high scalable module that exploits the peculiarities of the microcontroller. What are PWM Signals and how are they generated? Types of PWM Signals: Parameters of PWM Signals: To generate the PWM signals via Automotive MCU’s using Autosar MCAL Layer API’s: At first to configure the MCU pins in PWM peripheral mode via PORT Driver: We can generate the PWM Signals from Microcontroller through different peripherals like Timer Peripheral of the MCU or FlexIO peripheral. So at first selection of MCU pin has to be done from which PWM signal has to be genarted and then configuring that MCU pin in corresponding peripheral mode. After that comes the clock selection and configuration via MCU Driver: MCU Driver is responsible for clock configurations and clock settings of Microcontroller. Setting of systems clock, peripehral clocks all these settings are done by MCU Driver. And for generating the PWM Signals, what clock frequency has been input to it is very crucuial so as to calculate its parameters. After this MCL Driver selection is also important: We can generate PWM signals from Microcontroller via different peripherals. Either Timer based peripheral or FlexIO peripheral. By tradation Timer peripheral is recommended and widely used. But as PWM Driver has been designed with global level coverage, it is also dependent on FlexIO peripheral, so FlexIO peripheral concentric files are generated via MCL Driver. So we will just select the MCL Driver, so that dependent files are included in project. In this course, we will focus on PWM signal generation via Timer peripheral. In our case we will be using NXP S32K144 MCU which has FlexTIMER Peripheral. After all above three will be coming our PWM Driver configuration and selection. That is what is the main moto of the course module. We will understand what all configurations are their in PWM Driver. How PWM Driver works and important API;s of it for generating the PWM Signals. Their would also be use of Platform Module, that is responsible for interrupt settings and configuration. We are going to use Interrupts with PWM Signals to detect the rising and failing edges of PWM signals and do some application specific tasks on those edges. Functional concepts of PWM Driver: Now PWM Driver has general/global functional concepts which are applicable to all automotive MCU’s, which are important to understand and know so as to configure the PWM Driver. Selection of PWM hardware channel: Selection of PWM Channel polarity Selection of PWM IDLE Mode Selection of PWM feature enablement: PWM Signal modes: Apart from the above general functional concepts, the PWM peripheral level concepts of the corresponding Micrcocontroller is also important to understand. These peripheral level functional concepts are different from one MCU to another. As their are different peripherals for generating PWM signals in different MCU’s. But the usage of these concepts is used only at the time of PWM GUI configuration. At the time of writing the embedded application, same set of API’s, chronology and parameters is used. In our case we have ElecronicsV3 Board, which has S32K144 MCU and we are using FlexTIMER peripheral of this MCU. Concepts description with respect to Author: Kunal Gupta
FTM PWM Driver API’s of NXP S32K144 MCU
API Name: Ftm_Pwm_Ip_Init() void Ftm_Pwm_Ip_Init(uint8 Instance,const Ftm_Pwm_Ip_UserCfgType * UserCfg) Role: This API initializes the FTM peripheral according to PWM feature. Author: Kunal Gupta
SAR ADC Explained!
Why to learn about SAR ADC? SAR ADC is a standard AUTOSAR opts for. That’s why you see most of the automotive microcontrollers can be observed having SAR ADC and SAR stands for Successive Approximation Register. You can see the below picture which I extracted for verification of this fact. Microcontrollers which are verified: NXP S32K1xx Series NXP MPC5xxx Series STMicroelectronics SPC5 Series Renesas RH850 Series Infineon AURIX TC3xx Series Microchip PIC32 Series Why AUTOSAR likes SAR ADC over others? SAR ADC working is most suitable due to three major factors mentioned below: High Conversion Speed with Accuracy: SAR ADCs are fast to handle conversion like real-time sensor data conversion while holding its precision as it is. This conversion can be like throttle control, battery management, and other critical functions. Power Efficiency: Power consumption is one of the most important factors in any automotive application especially electric vehicles. SAR ADC consumes comparatively less power rather than ADC like FLASH ADC. Scalability: SAR ADCs offer a trade-off between speed, resolution, and area, which is crucial in automotive designs where space and performance both matter. Comparing SAR ADC with Flash and Sigma-Delta ADC Flash ADC: The fastest type of ADC, converting signals in just one clock cycle. This speed comes at the cost of power consumption and size, as it requires one comparator per bit of resolution. Given the complex needs of automotive systems, this increased power draw and large footprint make Flash ADCs impractical for most real-time automotive control systems. Sigma-Delta ADC: Offers exceptional accuracy by oversampling the input signal and using noise-shaping techniques. However, its conversion speed is much slower compared to SAR ADCs. This makes it unsuitable for fast, real-time sensor data processing, though it shines in applications where high precision is needed, such as audio or pressure measurement. SAR ADC stands between these two, offering sufficient speed, accuracy, and power efficiency. This balance makes it the top choice for most automotive microcontroller designs, especially in safety-critical applications like engine control, where both speed and accuracy matter. How SAR ADC Works Sample & Hold (S/H) Block: This block holds the analog input signal steady while the ADC performs the conversion. The process begins by capturing the input voltage and freezing it momentarily to allow precise comparisons during the conversion. Comparator: The comparator checks the DAC’s output against the input signal at every stage of the conversion. It decides whether the next bit in the SAR register should be a ‘1’ or a ‘0’ based on whether the input signal is greater or lesser than the DAC output. SAR Register: This is a shift register that stores the output bit by bit as the conversion proceeds. The SAR register’s value evolves with each step of the approximation process, eventually containing the final digital equivalent of the input analog signal. DAC (Digital-to-Analog Converter): The DAC generates a voltage based on the digital bits already stored in the SAR register. The comparator then compares this DAC output with the input signal. The DAC’s resolution is crucial since it must match the resolution of the SAR ADC. Step-by-Step Example: How SAR ADC Calculates an Input Signal Example Setup: Reference Voltage (Vref): 5V Resolution: 4 bits (for simplicity) Input Voltage (Vin): 2.6V Author: Rohan Singhal
Reading ADC Values via ADC Driver of Autosar MCAL layer using ElecronicsV3 Board( NXP S32K144 MCU)
Author: Kunal Gupta
Kunal Gupta
Author: Kunal Gupta
Author