Blog

Your blog category

Blog

BootLoader EXPLAINED!

What is BootLoader(BL)? The bootloader is a small chunk of code that gets executed when the MCU powers on or resets. Its main function is to manage the initial startup process, including any necessary checks or updates before the main application code runs. How BootLoader(BL) is different from Application Software? Application Software is the function-specific code that you program to perform an MCU-based task(like controlling the motor, displaying information, etc,). But you must be thinking or saying, that your application software also behaves pretty same as bootloader cause everytime you start/reset MCU, it will restart your application code from the beginning, right? But there’s a quite crisp gap between this BootLoader and Application Software which can broaden your understanding of bootloader and application software. Let’s divide this crisp gap into 3 sub-domains: Memory Allocation: If I talk about memory occupied by BL and Application Software. The first thing would be where are these two located and in which memory, answering that, BL is located at the beginning of FLASH memory and it always has some reserved space only which is also write-protected(Thinking why write-protected because to prevent accidental overwriting during normal operation) whereas application software is also stored in FLASH memory only but it’s below the space allocated to BL. Execution Flow: Upon power-on or reset, the microcontroller’s program counter starts executing code from the beginning of the flash memory, where the bootloader is located. After the bootloader completes its tasks (like, checking for updates, and validating the application), it will typically jump to the application’s start address (which is known and fixed in the bootloader code) to begin executing the application. Update Process: A well-developed bootloader can help you even in handling firmware updates. It can receive new application code, erase the old code, and write the new code to memory. The application cannot typically update itself. It relies on the bootloader to manage this process. The application’s major focus is on running the device’s features and does not deal with the update or integrity checks. Let’s understand with a analogy Taking an analogy with our expertise field of automotive embedded systems. Considering ourselves as an OEM, we have been reported a problem. A software bug is discovered in the ECU that controls the braking system. This bug causes the braking system to occasionally misbehave under specific conditions, such as when the vehicle is driving downhill. Diagnosing this issue requires an early solution because the bug needs to be fixed quickly to ensure the safety of the vehicles on the road. During the update of this bug fixing, the vehicle’s battery drains, and the update process is interrupted: With a Bootloader: When power is restored, the bootloader detects that the application firmware is corrupted or incomplete. It can either retry the update automatically or revert to a backup firmware version, ensuring the vehicle remains operational and can be updated again. I agree in this condition driving is not safe, but at least the car can operate so that it can be driven to repair with full caution. Without a Bootloader: The ECU might attempt to boot the corrupted application, resulting in a system crash or malfunction. The vehicle may not start or may exhibit erratic behavior, requiring a technician to manually intervene and repair the ECU, which could be time-consuming and costly. EDIT: Just found another real-life example. As we all know windows push too much of FOTA(Firmware Over-The-Air), out of which some take too much time to restart and some get applied with restart. Now you must have seen this screen will update. This “DON’T TURN OFF YOUR COMPUTER” message is also displayed for the very same reason, how power disruption can lead to the bricking of your laptop. But you must be curious what exactly what will happen if I cut off the power supply, and power up the device again, right? As a bootloader function, this interruption will be acknowledged and the bootloader will roll back to the previous functional update. You might see below mention image on start-up. IMPORTANT: Avoid trying this at home, this maneuver costs us to retrieve the data but unfortunately all core OS files and applications were corrupted and no longer responded for usage, we tried some troubleshooting using the window troubleshooter, but it wasn’t effective. At last, we installed a completely fresh OS from scratch.  I would expect that you have completely understand the “WHY” and “WHAT” of BootLoader. Now, it’s time to understand the “HOW” of bootloader. Important Terminology in BootLoader Memory Management Memory management is quite an interesting concept that can also help in relating to real-world applications. As we understand the chronology of the working of a bootloader, which is firstly a bootloader will get which now will be followed by application software. Now basically there can be different executions of application software, let’s brief all possible ways: Executing Directly from Flash Memory: This specific condition is noticed in most of the embedded MCUs where the bootloader and application software are placed in FLASH memory only. Flash memory is non-volatile, meaning it retains data even when the power is off.  Copying to RAM Before Execution: In some cases, the application code might be copied from flash memory to RAM before execution. This approach is more common in systems where high performance is required or where the flash memory is slower than RAM. The major reason behind using RAM for execution, RAM is typically faster than flash memory. Overlaying: In systems with limited RAM, overlaying is a technique where only a portion of the program is loaded into RAM at any given time, with different parts of the program being loaded and unloaded as needed.  Virtual Memory Techniques: This specific technique is very common nowadays you must see that recent smartphones have this feature called RAM EXTENSION, where a portion of storage is accumulated to RAM for its R/W access. Parts of the application can be swapped in and out of physical RAM as needed. Such strategies

Blog

PDB Explained

Prerequisites for PDB of ADC What is the PDB? The PDB is a powerful peripheral in microcontroller’s designed to provide controllable delays and trigger events based on specific conditions for ADC peripheral. Those control delays and trigger events allows us to get ADC Data, making it valuable for applications requiring accurate timing or synchronization. // In this elaborate following things: Point to be learned: Q: What do we mean by controllable delays?A: Controllable delays refer to the ability to set specific time intervals in a system to control when certain actions or events occur. It provides you with flexibility, configurable time delay, and precision. Q: What do we mean by trigger event?A: A trigger event is a signal(which can be external or internal) that prompts the system to begin a predefined action or series of actions. Q: What and which specific conditions we mean here?A: Configurable delay can be a counter-based delay, timer-based delay, or PWM-based delay. If we talk about PDB, here we use counter-based delay which involves using a hardware counter that increments or decrements based on a clock source. When the counter reaches this value, an event (such as a trigger or interrupt) is generated. And talking about the trigger event can be also classified into internal or external triggers, it is quite self-explanatory that if a trigger is received from a physical pin of the MCU then it is considered an external trigger and if triggers are initiated inside the MCU then it is called software trigger. Why is This Important? Understanding how to use the PDB effectively can greatly enhance your control over ADC operations. Whether you’re working on a high-precision measurement system, synchronizing multiple ADCs, or simply improving the timing accuracy of your applications, the PDB offers the flexibility and precision you need. How does PDB Peripheral works? ///// In this explain the relation of working of PDB peripheral. Q: How does PDB generate delaysA: As explained before, PDB works on a counter-based delay where we can specify the value of the counter. When the counter reaches this value, it will be reset back to zero. This counter register is labeled as “Modulus register (PDB_MOD)”. Let’s see how you can get a perfect modulus value for your desired requirement. Example: Peripheral(PDB) bus clock is 48MHz(this can also be modified in the clock configuration tool) and before moving to modulus calculation you are always asked to set the value of pre-scalar and multiplication factor(these two can be in Status and Control Register (PDB_SC)). Prescalar value is used to divide the peripheral clock and set your desired value of clock for operation and multiplication factor as it defines its name, it is used for multiplying with prescalar division. Now we are considering the MULT(Multiplication factor) as 40 and PRESCALAR(Prescalar Divider) as 64.PDB Period = ( (System Clock) / (Prescaler x Mult factor) )PDB Period = (48 MHz / (64 x 40)) =  18750HzNow, we have a clock value for PDB and you can create multiple MOD values from this clock. If we need a counter value for 1 second, we just multiply the PBD Period with “n” second.1 second = 18750 x 1 = 18750(MOD value)2 second = 18750 x 2 = 37500(MOD value)3 second = 18750 x 3 = 56250(MOD value)NOTE: The maximum value for MOD is 65536(MOD register is 16-bit register), which means with my current setting I cannot create a 4-second counter value(4 seconds = 18750 x 4 = 75000 > 65536). In this case, you need to reconfigure the values of PRESCALAR and MULT. Q: Explain the concept of channels in PDB peripheralA: In the Programmable Delay Block (PDB) peripheral, the concept of channels is central to its functionality. Each channel in the PDB is a separate entity that can be configured to trigger specific actions after a programmable delay. Each PDB channel is typically associated with a specific Analog-to-Digital Converter (ADC) block. For example, PDB0 will be linked to ADC0, and so on. PDB channels can be enabled or disabled independently. The concept of channels in the PDB provides flexibility in timing and synchronization, essential for applications requiring precise control over ADC conversions. Q: Concept of triggering in PDB by explaining terminologies like trigger event, trigger input, trigger sourceA: The concept of triggering in the Programmable Delay Block (PDB) is essential for coordinating and controlling actions such as ADC conversions. Trigger Input: The trigger input is the physical or logical signal that the PDB monitors to detect a trigger event. This input can come from various sources like pulling a pin up or down, triggering through Bit Manipulation of register, and all.Trigger Event:A trigger event refers to the occurrence of a specific condition or signal that initiates an action within the PDB.Trigger Source:The trigger source defines where the trigger input originates. Just mention the concept of the triggering mechanism of ADC peripheral and how is it achieved through PDB Relation of PDB delays with ADC peripheral How does the PDB peripheral control the ADC peripheral The Programmable Delay Block (PDB) includes a counter that compares its output to various preset digital values. When the PDB is enabled, a trigger input event will reset the counter and start counting. A trigger input event can be a rising edge detected on a chosen external trigger source, or it can be initiated by a software trigger. For each channel, a delay determines the time between the assertion of the trigger input event to the time at which changes in the pretrigger output signal are started. Each channel in the Programmable Delay Block (PDB) is linked to a specific ADC block. These pre-trigger outputs are connected to the ADC’s hardware trigger select. The role of the pre-triggers is to prepare the ADC block before the main trigger signal is applied. When the ADC detects a rising edge on the main trigger input, it starts the conversion process based on the settings and conditions established by the pre-triggers. The pre-trigger outputs are used to specify which signal will

Blog

Motor Control

When engineers are faced with the challenge of designing electrical equipment to perform mechanical tasks, they might think about how electrical signals get converted to energy. So actuators and motors are among the devices that convert electrical signals into motion. Motors exchange electrical energy to mechanical energy. To understand Motor terminologies Stator Rotor Armature   Types of Motors       A stepper motor is driven by pulses; it rotates through a specific angle (step) with each pulse. Because the rotation is precisely controlled by the number of pulses received, these motors are widely used to implement positional adjustments. They are often used, for example, to control paper feed in fax machines and printers—since these devices feed paper in fixed steps, which are easily correlated with pulse count. Pausing can also be easily controlled, as motor rotation stops instantly when the pulse signal is interrupted. About DC Motor The speed of a DC motor can be controlled by changing the voltage applied to the armature. Variable resistance in the armature circuit or field circuit allows speed control. Modern DC motors are often controlled by power electronics systems which adjust the voltage by “chopping” the DC current into on and off cycles which have an effective lower voltage. What is Brushless Direct Current Motor(BLDC)

Blog

Tigger MUX Control(TRGMUX) Peripheral in S32K144 MCU

What is TRGMUX peripheral? TRGMUC provides an extremely flexible mechanism for connecting various trigger sources to multiple pins/peripherals. The trigger multiplexer (TRGMUX) module allows software to configure the trigger inputs for various peripherals.   The TRGMUX module allows software to select the trigger source for peripherals.   TRGMUX is a peripheral which provides mechanisms for connecting various trigger sources to multiple pins/peripherals. Each peripheral that accepts external triggers usually has one specific 32-bit trigger control register. Each control register supports upto 4 triggers and each trigger can be selected from available trigger sources.  

Blog

PDB (Programmable Delay Block) Peripheral in automotive microcontroller (NXP S32K144)

What is Programmable Delay Block(PDB) peripheral? PDB provides controllable delays from either an internal or an external trigger, or a programmable interval tick, to the hardware trigger inputs of ADCs. PDB can also provide pulse outputs that are used as the sample window in the CMP block.   The PDB contains a counter whose output is compared to several different digital values. If the PDB is enabled, then a trigger input event will reset the PDB counter and make it start to count. A trigger input event is defined as a rising edge being detected on a selected trigger input source, or if a software trigger is selected and the Software Trigger bit (SC[SWTRIG]) is written with 1

Stay Updated With Us

Error: Contact form not found.