Electronics Miscellaneous

HOW TO START WITH PCB DESIGNING?

Hello Friends, I’m Taral Mehta. I\’m an Electronics Engineer, This is the first blog of the series to discuss and learn the basics of PCB designing. In this blog, we will discuss, Introduction of PCB and its designing techniques. As well as we will discuss various software that are used for designing the PCB. Table of Contents Starting with Basics of ELectricity Before going to start with PCB designing, we will understand the basic components required: Current – Current is the rate of flow of electric charge. at all points in a series circuit, the current has the same value. If a circuit has a branch, the current flowing into the junction must equal the current flowing out of it.   Voltage – Voltage is also known as potential difference.In a circuit loop, the sum of the voltages across the power supplies is always equal to the sum of the voltages across the rest of the components. RESISTOR – Resistance is a measure of the opposition to current flow in an electrical circuit. Resistance is measured in ohms CAPACITOR – A capacitor is an electronic component that stores and releases electricity in a circuit. It also passes alternating current without passing direct current. Introduction to PCB (Printed Circuit Board) As an Engineer, whether is Mechanical Engineer, Computer Engineer, or IT Engineer, now and then everybody comes across one of the vital parts of the respective industry i.e. Electronic Circuit. This electronic circuit is made or created on a special type of board, which is called PCB (Printed Circuit Board). As you can see in the above image, PCB has electronic components which are connected through conductive pathways, which are usually called Tracks. A PCB is a thin board made of Fiberglass, composite epoxy or other laminate material. Tracks are etched or printed onto a board, which connects different components on PCB, such as Diode, Resistors, Capacitors and Integrated Circuits (IC). These blue and red lines going criss-cross are the Tracks, which form electrical connections between components. And these Yellow and grey objects are actually footprints or pads of components. I Know that tracks, via and Pads are new parameters for you but don’t worry I will give you a simple answer for your understanding. Traces or Tracks: A trace is a piece of copper, think of a wire, that makes an electrical connection between 2 or more points on a pcb. Traces carry current between these two points on the printed circuit board. You can see an image where RED and BLUE are tracked. Pads: Pads are small areas of copper in predetermined shapes normally used to make a connection to a component pin. Vias: A via is a physical piece of metal that makes electrical connections between layers on the printed circuit board. Vias can carry signals or power between layers using plated through holes. Using this technology a via is formed by drilling a hole through the layers to be connected and then plating the inner surface of the drilled hole. Vias should be sized according to the traces connecting between layers and ultimately how much power it must carry. I think You got a basic idea about what exactly a PCB is… correct? So let’s move further and discuss, What are the designing tools of PCB? PCB Designing Software 1) Eagle 2) OrCAD 3) Proteus 4) KiCad 5) Altium Designer 6) EasyEDA These are some of the famous EDA software presently available in the market. One can use any one of the above lists as per their convenience of use. These are some of the famous EDA software presently available in the market. One can use any one of the above lists as per their convenience of use.EagleorCadProteusKiCadAltium DesignerEasyEDA Previous Next Application: Medical and Healthcare Industry Illumination and Lighting Industry Consumer Electronics Industry Industrial Equipment Industry Aerospace Industry Automotive Industry Safety and Security Equipment Industry Telecommunications Industry Military and Defense Summary To summarize, in this blog first, we did an introduction of PCB. Then we discussed the basics of Electronics. We introduce the Basic Concepts of PCB like Schematic, PCB layers, etc. We discuss some of the PCB designing software and applications currently used in the market. References 1.http://www.pic-control.com/pcb-design-service/ 2.https://qualityinspection.org/electronics-videos-basics-pcb-pcba-smt-process/ 3.https://kitflix.com/how-to-study-pcb-design-getting-started-with-printed-circuit-boards/ 4.https://usa.pcbpower.com/application-and-use-of-pcbs.html  5.https://www.goldphoenixpcb.com/html/Support_Resource/arc_177.html

Embedded MCU's Getting Started and Peripheral Coding STM32 MCU's STM32F1

STM32F103 & ADC: Single Channel Conversion

In the last post, we have gotten to know about the features of ADC Peripheral that we have in STM32 MCU. Now in this blog with the series of bare Metal Programming for Blue Pill, we will understand different register bytes and bits of ADC Peripheral to be used for using it in different features, configurations, and modes as we get to know about in the Previous Post. In this blog, we will be going through how to use  ADC Peripheral for converting a Single Channel of ADC (only one ADC pin) and see its bare metal code. Single  Channel Conversion  Mode: Only one ADC pin is used, this mode is like when we have say connected only one analog sensor to one of the ADC pins of MCU  like the Potentiometer is connected at PA0 pin. ADC Registers In depth for: Let\’s get into an in-depth understanding of which registers and their bits are used for configuring the ADC peripheral of Blue Pill in Single Channel Configuration. We will focus on bits and will give an explanation of why those bits are used for the 1.   ADC_SR(ADC status Register) –>This register tells the status of ADC channel  Conversion, as it name says. STM32F103 ADC Status Register: 11.12.1 Bit 1[EOC ]: This bit is set by hardware when a single channel of any group (Regular or Injected) is converted successfully. So this bit is used for monitoring when the ADC conversion is completed by using it inside the while loop if interrupts are disabled. 0: ADC Channel Conversion is not completed 1: ADC Channel Conversion is completed When hardware set this bit, we can clear this bit from the firmware end by setting the bit to 0 or by reading ADC_DR(ADC Data Register) Bit 4[STRT]: This bit is set by hardware when regular channel conversion has begun. So when we start the Regular Channel Conversion, we will use this bit inside the while loop to check that whether Regular Channel conversion has started or not. 0: No regular Channel Conversion has started 1: Regular Channel Conversion has started When hardware sets this bit, we can clear this bit from the firmware end by setting the bit to 0. Even if we don\’t clear this bit it will cause no effect during ADC Conversion. But its good practise to clear all bits of Status Register before starting the new conversion 2.            ADC_DR(ADC Data Register) –> This register stores the converted digital data at a 12-bit resolution of the converted ADC channel. STM32F103 ADC Data Register 11.12.14 Bit 15:0 [DATA 15:0]: The ADC_DR is divided into two 16 bits groups. The first 16 bits from 0-15 contain the Converted value of the configured ADC Regular Channel. As our ADC is of 12-bit resolution, so this is left aligned or right aligned to 4 bits so as to get the 12 ADC converted data . Left Aligned or Right alignment of ADC Data Depends on ALIGN bit of ADC_CR2 So we will have following code and algorithm for ADC_SR & ADC_DR register:while(!(ADC1->SR & ADC_SR_STRT)) while(!(ADC1->SR & ADC_SR_EOC)); // wait till a group channel converstion has completed adc_data = ADC1->DR; //clear the EOC bit by reading DR register ADC1->SR &= ~ADC_SR_STRT;      3.      ADC_CR1(ADC Configuration register 1) –> This register is used for the  Configuration of ADC peripheral for Analog Watchdog Discontinuous Mode Interrupt Enable/disable Dual Mode configuration Scan Mode  As we are not using any of these features, so all the bits for these registers will be set to zero, and to know about these features and their bit functions, u can navigate to corresponding blogs for those. STM32F103 ADC Configuration Register 1. 11.12.2 Bits 19:16 [DUALMODE 3:0]:  These bits are used to configure the type of operating mode. In the blue pill, we have two ADC peripherals: ADC1 & ADC2. We can use these  2 ADC peripherals simultaneously by configuring the respective ADC in different modes or in independent modes. We are going to use these ADC in independent mode as will be using only ADC1 peripheral, so DUALMODE[3:0] will be set to 0. Bit 8[SCAN]: This bit is used to enable/disable the SCAN Mode feature in the ADC peripheral of BLUEPILL. Scan Mode is used when we convert more than 1 channel to scan all the configured channels in a Regular Group. As we are using only a single channel, means only one ADC pin is used so SCAN mode is not used and this bit will be set to 0. 0: Scan Mode disabled. 1:Scan Mode Enabled. So we will have following code and algorith for ADC_CR1 register:ADC1->CR1 &= ~(ADC_CR1_SCAN); // SCAN DISABLED, if using scan mode then dma must be enabled ADC1->CR1 &= ~(ADC_CR1_JDISCEN | ADC_CR1_DISCEN); // Discontinous mode disabled for both injected and regular groups ADC1->CR1 &= ~(ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_2 ); // no channels are configured in discontinous way. // if discontinous mode is enabled then number of //conversions to be done by discontinous mode has to be configured // DISNUM bits ADC1->CR1 &= ~(ADC_CR1_DUALMOD_0 | ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_2); // INDEPENDENT MODE SELECTED ADC1->CR1 &= ~(ADC_CR1_AWDEN | ADC_CR1_JAWDEN); // Analog watchdog disabled for both groups: regular and ibnjected 4. ADC_CR2(ADC Configuration Register 2) –> This register is used for the configuration of  ADC Peripheral for:  ADC Conversion enables/disabled for regular and injected groups and ADC peripheral enable/disable. Trigger source configuration for regular and injected groups. ADC Data Alignment, DMA, Continous, temperature sensor setting. STM32F103 ADC Configuration Register 2 11.12.3 Bit 0 [ADON]: ADC Peripheral On/OFF. This bit will be set to 1 to enable the ADC peripheral.  All channel configurations and ADC Peripheral configurations have to be made before setting this bit to 1. 0: Disable ADC Peripheral 1: Enable ADC Peripheral Bit 1 [CONT]: This bit configures between Single Conversion mode and Continous Conversion mode. Continuous Conversion mode is selected when we have more than 1 ADC channel to be converted. As in this blog, we have

Tech

Introduction on PlatformIO

Content Index Table of Contents Complete Beginner’s Guide to Platform IO Introduction Platform IO is a platform that allows core developers to compile the same code with different platforms using only one command i.e. platform io run. It is an extension in VSCode and hence can be used with our favorite code editor. It has many features that allow core developers to have a smooth development experience. Also it allows you to export and edit the same project in windows as well as windows or any other systems without any changes required. Installing Platform IO It is a VSCode extension and can be simply installed by adding Platform IO from the extensions center of VSCode Figure 1 Creating a Project in Platform IO Click on Platform IO Logo in VS Code Figure 2 In PIO Home 🡺 Go to Open 🡺 Home Screen of PlatformIO is visible Select New Project 🡺 Give a name and select board for project 🡺 Select Location 🡺 Done Figure 3 Figure 4 Figure 5 Figure 6 New Project will be created You can write code in main.cpp under the src folder, we can edit the platform under platformio.ini to upload to different boards. Different Folders and files in Platform IO Platform IO consists of many folders to support embedded development on multiple systems and compiling information. Platform IO consists of: .pio: This folder consists of complete debug and compiler information of the project. This folder need not be uploaded and is included in gitignore as well to not upload on Github. <br> We don’t have any work in this folder and we don’t need to edit this folder.  .vscode: This folder consists of JSON files required to run platform io and its services in VS Code editor. This folder also doesn’t need to be touched or edited to do our work. include: This folder is present to allow you to add “.h” header files into the PlatformIO project that are not added as libraries in your project. You can place libraries defined by you with .h extension to use them. Also, this code is not compiled and there is no use of putting a .c/.cpp file in this folder. lib: This folder is used to define complete libraries that are private that are made by you. In include, we only add .h files but this folder can consist of complete details like documentation, examples, source files, JSON, etc. Basically, it contains complete information related to a library. src: This folder consists of main.CPP and will contain the code that we want to write. We can add more files in this folder to integrate into our code. This is the main folder we will be working on. Code will start executing from main.CPP. test: This folder is used to write tests that can be used to automate the testing of the code. These tests can be used to see the efficiency of code and how code behaves on boundary conditions. These are generally useful in bigger projects.  .gitignore: This folder is a part of the git family and consists of the name of the folder that needs to be and will not be uploaded on git while uploading the project. It generally includes the .pio folder and some files of the .vscode folder.  platformio.ini: It is a kind of settings folder where you can decide the platform on which code to be uploaded, add libraries, control monitor speed, select framework, and many more things. Visit the given link to explore multiple options and their application in platform io : https://docs.platformio.org/page/projectconf.html Adding Libraries in PlatformIO project Platform IO provides multiple easy ways for you to add libraries to a project. We are going to discuss one of the easiest and most useful ways of adding libraries in Platform IO: Go to Platform IO symbol in the left pane of extension 🡺 Under PIO Home select Open. In the main window select Libraries 🡺 Search the library you need 🡺 Click on that library 🡺 Click on Add to Project 🡺 Select project in which you want to add library and click add. Now the library is added to your project. There are also other ways to add libraries in Platform IO by editing the platformio.ini folder. See the below link under ‘Project Dependencies’ to explore those methods: https://docs.platformio.org/en/latest/librarymanager/quickstart.html Uploading code to hardware using PlatformIO Platform IO provides a very easy way to upload code on the hardware. The following steps should be followed to upload the code: After writing the code, verify the details and environment in platformio.ini. You can select different hardware by removing the lines that look like the following and adding the setting for the required board. Setting can be googled to find the exact lines: [env:pro16MHzatmega328] platform = Atmel Avr board = pro16MHzatmega328 framework = Arduino You can also select multiple boards at one time using the method mentioned in the following link: https://community.platformio.org/t/changing-destination-boards/4751/2 Click on Platform IO Icon in left sidebar of VS Code Under Project Tasks 🡺 General, you have multiple options and operations that can be done for the project. Build 🡺 Compiles the code to see if any errors  Upload 🡺 Compiles and upload the code to the hardware connected. Monitor 🡺 To open serial monitor in VS Code Upload and Monitor 🡺 Compiles uploads the code and open the serial monitor just after uploading code Clean and Clean All 🡺 Used to remove and delete any dangling pointer or function that is left in the stack and not deleted or removed. ** You can also have few options present in the bottom bar to compile, upload and monitor the code. Conclusion In the end I want to say that platform Io is an amazing platform that is used to develop embedded systems code, and has integrated most capabilities like writing, uploading, and even debugging of code in one place. It is a great platform to work on and will help you guys a lot.

Embedded MCU's Getting Started and Peripheral Coding STM32 MCU's STM32F1

ADC(Analog To Digital Converter) in STM32F103

Home Category Child Category Introduction Imagine that we are building a robot or an interactive art piece. We might be interested in measuring temperature, distance to the nearest object, force, and acceleration, sound pressure level, brightness, or any other physical characteristics. The first step is to convert all these physical quantities into a voltage using a transducer. The world is analog in nature, so every quantity that we need to measure is measured by the transducer in an analog output. But our Computers, MCU, Processors are digital in nature, that is they can Understand only ‘1’ and ‘0’. Thus we need an interface that can convert analog values of the world into digital values so as to process them. Thus here comes the ADC(Analog to Digital converter) “Analog Signals need to be processed correctly before they can be converted into digital form. This processinbg of Analog Signal is done by Signal Conditioning circuits” Important Terms in ADC Resolution of ADC: As said, ADC transforms an analog voltage to a binary number(series of 1’s &0’s) which is then represented as a Digital Number over our screens. The Number of Binary digits (1 &0) that represents the Digital Number determines the ADC Resolution ADC Introduction in STM32 Like every modern family of MCU, STM32 too has inbuilt ADC. Now if we open the datasheet of STM32F103 Bluepill and Navigate to its ADC Section. Now let’s break down this ADC Introduction part to understand the ADC Peripheral in STM32 MCU Successive Approximation: Type of ADC which is used in STM32 MCU.Which is made using OPAMPS, Resistors, Digital & Analog Electronic Circuit. So depending upon the type of circuit their are different types of ADC. 1) Successive Approximation 2) Sigma Delta 3) Voltage to frequency 4)Dual Slope ADC Analog Sensors & Electronics are huge topic, so wont be able to cover everything & would be focusing on STM32 MCU ADC Peripheral Click Here12 Bit ADC : Resolution of the ADC Peripheral in STM32 MCUThis is Resolution of the ADC Peripheral in STM32 MCU.Means Decoded ADC value which we will get will be ranging from [0-4095] = 2^12Click Here18 Multiplexed Channels: Blue Pill we have 18 ADC pinsBasically channels means from which Analog Values of the External world/Transducer will be fed to the MCU. Out of the 18 Pins Blue Pill has 16 external and 2 internal sources. This means that in 1) 16 pins [ADC0-15], we can fed analog values from the external world, like interfacing some analog sensors 2) 2 pins[ADC16:17] have the internal analog sources (Internal temperature Sensor & Internal Reference Voltage) : There is one inbuilt Temperature sensor inside the MCU which Outputs the data in analog value & send it to ADC_Channel 16.Click Here Previous Next So that is for the basic introduction of the ADC peripheral of STM32F103, now let\’s dive into more in-depth to know about the features of ADC peripheral in STM32 MCU. ADC Features in STM32 MCU Regular and Injected groups In STM32 MCU ADC peripheral their is a feature of Regular and Injected Group, we can configure the ADC Channels to be either in Regular Group or Injected Group. Regular Group: ADC Channels which are configured in regular group are converted regularly( when ADC peripheral is started by setting ADC_CR2:ADON bit), just like basic ADC conversion of channels one by one Injected Group: Now Channels which are configured in injected group works on same principal of Regular Group but this group have higher priorty then Regular group. As it names says injected, this group will interrupt the Regular group Conversion Click Here Types of Conversion Modes in STM32 ADCTheir are 4 types of Channel Conversion Modes in STM32. 1) Single Conversion Mode 2) Continuous Conversion Mode 3) Scan Mode 4) Discontinuous ModeClick HereSingle Conversion Mode: As it name says \”Single Conversion\” so when ADC peripheral is configured to be in Single Conversion Mode , only one time conversion of configured ADC channels is done when ADC peripheral is triggered.Click HereContinous Conversion Mode:As it name says \”Continuous Conversion\”, so this is vice versa of single conversion. All the configured ADC channels are continuously converted once the ADC Peripheral is triggered by Software or by external event and converted data is continuously stored in ADC_DRClick HereScan Mode:This is 3rd type of Mode, as its name says\”Scan\”. So when configured in this mode, ADC works like a \”SCAN\”, it is used to scan a regular or injected group channel. In short, we can say if we are using more than 1 ADC channel & doing conversion of all configured ADC channels then we will be using Scan Mode. After the first channel conversion, it will go to the next configured channel for its conversion till the last channel configured Click HereDiscontinous Mode:This is 4th type of mode, in this mode we can convert configured channels of regular and injected group in short sequences of n conversion (n

AVR MCU Embedded MCU's

Getting started with AVR and Arduino

Home Category Child Category Part I – Untangling the wires: On your journey of exploring the different areas of embedded systems and microcontroller programming, you must’ve come across the term ‘AVR’. This blog (or series of blogs) will try to demystify all the terminologies. Prerequisites Before we proceed, this blog assumes that you already have a basic overview and understanding of what microcontrollers are, what their basic functionalities are, and how they differ from microprocessors. Knowledge of the C/CPP programming language would be beneficial. Table of Contents Introduction Arduino vs AVR The family of AVR microcontrollers Keywords Further reading References Introduction The technical definition of what AVR is, is: The AVR microcontroller is a family of mostly 8-bit microcontrollers developed by Atmel (now Microchip), that follow the Harvard RISC architecture. Let\’s try to break all this technical jargon down. Harvard architecture is a type of architecture where the instructions (program code) and data are stored in different parts of memory. This is in contrast to Von Neumann\’s architecture where no such distinction is made. The following illustration might help you understand the concept a little better. Now coming to the other piece of jargon that might’ve thrown you off RISC. It stands for Reduced Instruction Set-Computer. It is a computer architecture philosophy that generally follows the idea of having smaller and atomic instruction sizes when compared to its counterpart CISC (Complex Instruction Set-Computer), which has relatively bigger instructions. We won\’t be diving into this as this is a topic for another day. Arduino vs AVR Before we move any further let\’s clear one big misconception out of the way. People tend to confuse the terms Arduino and AVR quite often. Although it wouldn\’t be fair to compare these two (it would be like comparing an engine to a car), the following table clearly explains what are the differences between the two. In this article when we use the word “Arduino”, we will be referring to the Arduino platform which includes all the hardware and software made by the company.   Arduino   AVR 1. Is hardware and software platform which includes, but is not limited to: the Arduino IDE, Arduino Uno board, and the Arduino programming language 1. Is a family of microcontrollers developed in 1996 by Atmel. It is only a piece of hardware. 2. The Arduino Uno is a board that is built around the ATMega328, which is an AVR microcontroller. Apart from the microcontroller itself, it has other components such as a USB2.0 cable and a PCB on top of which the components such as resistors and capacitors are wired together. 2. Is a microcontroller that requires additional passive and active components (clock, LEDs, etc.) to be wired up by the end-user for it to work. 3. Products are developed and maintained by Arduino (company) 3. Products are developed and maintained by Microchip Technology Inc 4. An Arduino Uno board:Notice the various components such as voltage regulators, connectors, switches, LEDs that are already soldered onto the board.The rectangular black IC (Integrated Circuit)/chip on the bottom right-hand corner of the board is the engine that drives the car (board), ie, the ATmega328, which is an AVR microcontroller 4. The ATmega328P, an AVR microcontroller: It doesn’t come packaged with any components, which have to be attached by the vendor/programmer themselves Difference Between Arduino and AVR The family of AVR microcontrollers Microchip offers a wide selection of microcontrollers to choose from, each meeting a different set of requirements. They can broadly be divided into three categories. Series Package size FlashSize  Operating Frequency Example ATtiny(TinyAVR) 8-32 pins 0.5kB – 32kB 1.6MHz-32Mhz ATtiny85 ATMega(megaAVR) 28-100 pins 4kB – 256kB 1.6MHz-32Mhz ATMega328 ATxmegaXMEGA 44-100pins 16kB – 256kB 1.6MHz-32Mhz ATXmega128 AVR MCU Family Series Differences The above table isn’t exhaustive as there are many other families of microcontrollers such as the 32-bit AVR32 and the newly released AVR Dx series. The family of microcontrollers you end up choosing, totally depends on the scope of your project. Looking for a very small compact and lower power microcontroller which can automate a basic task, like toggling an LED-based on an input switch? Then go for the ATtiny family. Looking to control a servo motor that is connected to an IR sensor? You definitely won\’t go wrong with the ATmega series. Still, looking for more firepower for controlling multiple sensors? The ATxmega series has got your back. In the upcoming blog, we shall deep dive into one of the most widely loved and used microcontrollers – the humble yet mighty ATmega328. Till next time! Ciao! Further Reading http://ce.sharif.edu/~pourmohammadi/AVR%20Microcontroller%20and%20Embedded%20Systems/AVR%20Microcontroller%20and%20Embedded%20Systems.pdf https://en.wikipedia.org/wiki/AVR_microcontrollers http://www.avrbeginners.net/ References https://www.microchip.com/en-us/product/ATmega328P Intro Video on Device Drivers and Application Code for AVR(Arduino Boards) – YouTube

Embedded MCU's Getting Started and Peripheral Coding STM32 MCU's STM32F1

About ARM Processor’s

first View What is a Processor Processor is programmable electronic circuitry that performs operations according to the instructions stored in memory. The processor as of itself does not have the memory and I/O devices. The processor reads the instructions stored in the memory, interprets it, and stores the output in memory or signals the I/Os. Processor Consists of the Processor core which contains circuitry for instruction fetching, decoding, and execution, register banks, and control units. According to the architecture design of the processor, the different processors have different components. For example, ARM cortex-M4 processors have NVIC, MPU, Floating point units, optional debug subsystems. This allows the microcontroller vendors to design differently. A block diagram of the microcontroller. Fig 1.2 – A microcontroller contains Many different blocks How does Processor control the world? Processors become an integral part of our life. We come across many devices which have processors embedded in them. For example: The smartphone on which I am writing this article has ARM cortex-A55 and cortex-A75 as processor,   The Famous Tesla motors FSD Self-driving computer has many ARM processors. To give the idea of how processors are running the world look at these two examples. Upto 2019, Arm partners have shipped more than 160 billion Arm-based chips. Due to the shortage of semiconductor chips(processors) many car manufacturing companies had to reduce the number of cars manufactured. ARM Processor ARM Processor ARM processors are designed by ARM Ltd., ARM does not manufacture processors or sell the chips directly. Instead ARM licenses these designs to other semiconductor companies so that they can make their processor, microcontroller, SOCs as ARM processors are configurable. In the Cortex processor range, the processors are divided into three profiles: 1) The A Profile is designed to handle complex applications such as high-end embedded OSs. 2) The R profile processors are targeted primarily at the high end of the real-time market. These are applications, such as hard drive controllers, automotive systems, etc. 3) The M profile processors target smaller-scale applications such as microcontrollers and mixed-signal design. ARM CortexA1) The A Profile is designed to handle complex applications such as high-end embedded OSs.Click HereARM Cortex RThe R profile processors are targeted primarily at the high end of the real-time market. These are applications, such as hard drive controllers, automotive systems, etc.Click HereARM Cortex MThe M profile processors target smaller-scale applications such as microcontrollers and mixed-signal design.Click Here Previous Next ARM develops new processors, new instructions, and architectural features are added from time to time, as a result, there are different versions of the architecture. For example: ARM7TDMI is based on the architecture version ARMv4T. ARMv5TE architecture was introduced with the ARM9E processor families. With the ARM11 Processor family, the architecture was extended to ARMv6 with memory system features and SIMD instructions included.  Cortex family processors are based on ARMv7 and ARMv6. The cortex-M3 and cortex-M4 processors are based on ARMv7-M architecture. The architecture evolution of the ARM can be seen in the following (Fig 1.4). All the cortex-M processors support Thumb-2 technology(16-bit and 32-bit instructions), with no need to switch the processor between Thumb state and ARM state. Keil MDK-ARMIAR systems(Embedded workbench for ARM Cortex-M) GCC_based IDEs Previous Next For Programming and debugging ARM Processor based MCU’s, we will be using Microcontrollers of different vendors like: STMicroelectronics and NXP Semiconductors. We will be using STM32 Family of STMicroelectronics and S32 Family of NXP Semiconductors. Both of these are based on ARM Processor and have rich set of features and specifications which are ideal for learning embedded systems. Now both the companies provide their own IDE’s for  : STM32CubeIDE and S32 Design IDE for respective family of MCU mentioned above. Or we can also use the Above-mentioned IDE’s which are general IDE’s can be used to program any ARM processor based MCU. But recomended one is to use Vendor specific IDE as it has many extra featutes for programming. CMSIS The Common Microcontroller Software Interface Standard(CMSIS) was developed by ARM to allow microcontroller and software vendors to use a consistent software infrastructure to develop software solutions for cortex microcontrollers. THE AIM OF CMSIS: Software reusability: make it easier to reuse code with different Cortex-M processors, reducing time to market and verification efforts.  Software compatibility: Due to consistent software infrastructure, software from various sources can work together, reducing the risk in integration.  The CMSIS allows easy access to processor core features from the c language.  CMSIS-compliant device drivers can be used with various compilation tools. CMSIS started out as a way to establish consistency in device-driver for the Cortex-M microcontrollers, and this has become CMSIS-Core. Since then, additional CMSIS projects have started: CMSIS-Core  A set of APIs for applications developers to access the features on the Cortex-M processor regardless of microcontroller devices and toolchain used. CMSIS-DSP library This library is intended to allow software developers to create DSP applications on Cortex-M microcontrollers easily. CMSIS-SVD the System View Description in an XMl-based file format to describe peripheral set in microcontroller products. CMSIS-RTOS  the CMSIS-RTOS is an API specification for embedded OS running on Cortex-M Microcontrollers. CMSIS-DAP the CMSIS-DAP(Debug Access Port) is a reference design for a debug interface adaptor, which supports USB to JTAG/Serial protocol conversions. The CMSIS files are integrated into device-driver library packages from the microcontroller vendor. So when you are using CMSIS-compliant device-driver libraries provided by the microcontroller vendors, you are already using CMSIS. We can define the CMSIS into multiple layers: Core peripheral Peripheral Layer Name definitions,address definitions, and helper functions to access core registers and core peripherals. This is processor specific and is provided by ARM. Device Peripheral Access LAyer:  Name definitions, address definitions of peripheral registers etc. This is device specific. Access Functions For Peripherals Access Functions For Peripherals How do I use CMSIS-Core ? Add Source files to the project. This includes: Device specific, toolchain-specific startup code, in the form of assembly or C. Device-specific device initialization code(e.g. System_c). Add header files into the search path of the project: A device-specific header

Embedded Basics Embedded MCU's Miscellaneous

Memory System in Microcontrollers

Table of Contents Memory Controller (MCU)  It is a digital circuit that manages the flow of data going to and from the computer main memory. MCU can be a separate chip or integrated into another chip such as being placed on the same die of a microprocessor. In the latter case it is known as an integrated memory controller. Memory controller is also called a Memory Chip Controller(MCC) or Memory Control Unit.(MCU). Now Main memory can be directly or indirectly connected to the CPU via memory bus. Is the only memory that is directly accessible to CPU The CPU continuously reads instructions stored in Main Memory and executes them as required. Types of Main Memory/Primary Storage are: RAM(Random Access Memory) Processor Registers Processor Cache Processor Registers: are located inside the processors and are the fastest accessible memory by CPU of computers data storage. Processor Cache / cache memory: is intermediate stage b/w Processor registers and RAM. Most actively used information in the RAM is stored in the cache memory. Random Access Memory(RAM): is a main memory which is directly accessible by CPU (though it is slowest of the above mentioned Primary Storage). RAM(Random Access Memory) It is volatile memory that loses content on power off. It is the main memory with the largest size and it stores the working data and machine code.  (Machine Code – is instruction that can be executed directly by CPU. Each instruction tells the CPU to perform a task like load, store, jump or ALU operation on the data of Processor Register or Processor Core) So RAM stores the instructions and the data on which instruction has to be done. When the computer is turned on, it loads data to RAM. Programs that are currently running are stored in RAM. Now, there are 2 main types RAM: SRAM  2) DRAM  As the RAM types used for Primary storage are volatile, a computer containing only such storage would not have a source memory to read instructions from, in order to start the computer. Hence the non – volatile primary storage containing a small start-up program(BIOS) is used to bootstrap the computer.The non-volatile technology used for this purpose is ROM(Read Only Memory). ROM( Read Only Memory) It stores the program that is rarely changed during the life of the system and it contains the data for initialising the system and also user application program. → When Powered on CPU has no software in its main memory (as main memory mainly RAM:  that tells the instructions to CPU, is volatile in nature) → ROM stores the initial program that runs when the computer is powered on. → The computer first executes a relatively small program stored in ROM(Read Only Memory) along with a small amount of data, to access the non-volatile devices. In short ROM contains the program that allows a computer to startup each time it is turned on. ROM also performs large Input/Output tasks and perform programs or software instructions.

Embedded MCU's Getting Started and Peripheral Coding STM32 MCU's

How to Use Trace Features in STM32 with STLINKv2 in CubeIDE – Part 2

This is Follow up video of the previous Blog, In this How to use Trace features in STM32 MCU via SWV are explained using STLINKv2 Programmer and Debugger in STM32CubeIDE. Table of Contents Various Trace Features by SWV, Live Expressions and Using them SWV in STM32CubeIDE provide us with following Trace Features to be used in STM32MCU. Figure 14 SWV Features can only be used in Debug mode, so after creating your project as mentioned in below section, click on Debug Icon on the Menu bar of CubeIDE. Figure 15 If you are debugging your code for first time, debug configuration window will pop up, in which u must select your Debugger and made some Configurations. Main things to select in Debug Configuration window are. Debug Probe -> Select GDB server or OpenOCD. Enable the Serial wire Viewer(SWV) by checking on enable button and select the Core clock of SWV exactly as the Clock frequency that u have configured for your MCU system Clock, SWO clock as 2000 khz Under Misc. Section select the Enable Live Expressions Figure 16 Out of all SWV features I will be showing how to use marked SWV Trace Features from above pic of SWV Show View. SWV ITM Data Console So first Starting the SWV ITM Data Console which is used for printing printf() commands for printing Strings on the ITM terminal screen without using UART. For that We have to include the following code in your main.c file and include Header file Stdio.h in your main.c for printing the printf() commands on your ITM console. And now in your while loop of main.c file just write printf() commands like these. In the following Pic I have also blinked the led at PC13 pin. And then Debug the code by clicking on Debug Icon in Menu bar of CubeIDE. And after entering Debug Mode, click on Window -> Show View -> SWV -> SWV ITM Data console. Now as You open the SWV ITM Data Console, or any SWV window, u will find Following 2 icons in every view.  The first one is the SWV configuration Button, which is very important and configures our SWV. And another one is Start button for Starting the Trace. At first, we must do the SWV configurations, so click on first button. SWV Configuration window will pop out. Now For Using the ITM Data console, just click on the below marked check box for printing Printf() commands on the ITM port 0.and then click on ok.  Now start the trace by clicking on Red Button alongside the Configuration button. And now Resume the Code in Debug Mode only by clicking on the Resume button in menu bar of Cube IDE. Now as You click on Resume Button, U can see your printf() output strings on the ITM Data console. So that is how one can Print the strings using SWV + SWD in STM32 MCU via STLINKv2 without using UART for debugging the firmware. Click on Suspend button to stop the SWV. SWV Data Trace and SWV Data Trace Timeline Graph These two windows can be used to trace up to any Variables/Address locations of our code. Showing their value and other necessary details. For showing their use case, in our main.c I will be creating two variables by a&b. As shown in below pic. Now debug the code and open the SWV Data Trace and SWV Data Trace Timeline Graph windows. From those windows open the SWV configuration window as told in previous Section. And do the following changes, Enable the Comparator 0 and 1: one can data trace only up to 4 variables or address locations as you can see there are 4 Data Trace Comparators in our SWV Configuration window. In Var/Addr sections of Comparator 0&1 write the variables or address locations to be traced. And select ACCESS and GENERATE according to your variable being traced or address location being Traced. Below is the pic, showing my configurations: Click on okay and then start the Trace and Resume the Code in Debug Mode only as specified in Previous Section. Now you will see in SWV Data Trace view, all trace data of configured variables/address locations is being shown under History Section, showing various parameters like Value, Access, Program Counter value, Clock Cycles and Time for the Traced Event. As shown in Figure. Out of Configured Comparator, one can select for which comparator we want to see the history from the Watch section of Data trace, as shown in above Two pics.  Data trace data can be of great value for monitoring Time critical variables and address locations and observing their behavior during Program execution. In SWV Data Trace Timeline Graph, one can see the plotting of value of the configured Comparators in the form of graph and Analyzing Variables that are dependent on each other or Time critical. The Graph is plotted as shown in Pic. There are various options available on TimeLine Graph window, you can experiment those features by your won. SWV Statistical profiling Is used to see in which functions of your code, CPU is spending too much of time when program is running in MCU. To use SWV Statistical Profiling we do not have to write any code, just do as mentioned in Various Trace Features by SWV and Using them section above and enable the PC Sampling in SWV configuration window. Then start the trace and Resume the Code in Debug code as told in above sections. Now For Statistical Profiling wait for x number of secs after resuming your code according to your choice, in that time no data will be shown on Screen. After x amount, suspend the Program Execution and You will see something like this. As you can see, in above pic one can analyse in which functions our code is spending most of the and how much time. Which can be of great help in Very Complex codes which includes multiple I/O

Embedded MCU's Getting Started and Peripheral Coding STM32 MCU's

How to Use Trace Features in STM32 with STLINKv2 in CubeIDE

Table of Contents Overview Okay so hello guys and hope u are doing great; in the last 2 Blogs we get to know about Debug Trace Features in Embedded Systems and about ARM CoreSight Architecture for Debug and Trace in ARM based SoC/MCU. Now, in this Blog we will implement the theoretical knowledge of previous blogs to action and do them practically! We will do so by exploring the Trace Features in STM32MCU practically (STM32F103 Blue pill) using STLINKv2-B ( Official one white one) in STM32CubeIDE.  This Topic has been divided into 2 Blogs. In this Blog Hardware connections between STLINKv2-STM32MCU  and Code Generation is explained. The Video For that is also Uploaded on Gettobyte YouTube channel here. In next Blog How to use Trace Features using SWV is explained. The Video for that too is Uploaded on Gettobyte YouTube Channel here. Intro on STLINKv2 Programmers and Debuggers Now STLINKv2 which you can see in the above image is different from USB based STLINKv2 Programmer and debugger( Chinese clone one). It is different in terms of more features and JTAG support for Debugging the Firmware’s.  Original STLINKv2 can be used for Programming and Debugging Both STM8 and STM32 MCU. For STM8 it uses SWIM Protocol and for STM32 it has SWD, JTAG Communication Protocol and SWO pin for trace features. In USB based STLINKv2 Programmer Chinese cloned one also both STM8 and STM32 MCU can be programmed and debugged. For STM8 it also uses SWI Protocol but for STM32 MCU it has only SWD Protocol and pins available. For using the trace features, In USB based Chinese cloned one STLINKv2 (which is relatively cheaper than above STLINKv2) we must solder the 5V pin of Programmer by one of the pins of the onboard pin of the MCU used in Programmer. And it is a kind of long and Cumbersome Process.  But in Official STLINKv2 which is shown in above pic, we do not have to solder any of the pins for using Trace Features, The Programmer has Pinout and dedicated pins for using Trace feature using (SWD + SWO pins) and it has JTAG Dedicated pins too for Doing Debugging . Now as given u some comparisons between Official and Unofficial STLINKv2 Programmer and Debugger let us dive into some Practical Part. In the rest of the doc,  STLINKv2 programmer and Debugger will signify the Official white in one derivative which is shown in above pic. Hardware Connections for STLINKv2 and MCU The STLINKv2 Programmer comes in with following things as u open its Box. Main STLINKv2 Programmer and Debugger   20 Pin JTAG connector USB 2.0 A to USB 2.0 Mini B 2 x Connecting Cable for STM8 SWIM Now coming to the pain Connections for connecting STM32 MCU with STLINKv2.Programmer has the following pins for connecting it to STM32 MCU(Blue Circle). These Pins have Pinout like these: Right side from the Embarked Area (Orange Color), is pin 1 of the Programmer and then the pinout goes as shown in above pic. Now the Essential Pins out of these 20 pins of the STLINKv2 programmer to Program and Debug STM32 MCU using ARM Proprietary SWD Protocol are only 5 pins. SWIO/TMS(Pin 7) à SWD PIN SWCLK/TCK(Pin 9) à SWD PIN TDO/SWO(Pin 13) à SWO PIN STM32 RESET(Pin 15) à RESET PIN VCC(Pin1&2) à POWER PIN GND(Below Horizontal line’s any pin can be used as GND except 2) à POWER PIN SWD Pins of STM32 MCU will be connected to SWD PIN if we want to only use Debugging features alongside Programming the Microcontroller. Like as shown in PIC.  Now for Using the Trace Features we must connect one additional Pin from the Programmer to OUR Microcontroller and that is SWO Pin (13th pin) of Programmer to the Respective Trace SWO Pin Of our STM32 Microcontroller. In STM32F103 SWO PIN is PB3 as shown in this schematic. So, for Using Trace Features Connections will be like this. To be noted down: Any pin from the below horizontal line except the VCC pin of that line can be taken as GND pin when using SWD/SWD+SWO pins and can be connected to GND pin of our STM32 MCU.  Sometimes or in some Programmers we have to short all the VCC pins by Jumper wire for Proper connections or encase device isn’t able to power up MCU or Program it.  In some cases, VCC pins 1&2 can be wrongly mapped in Some Programmer, and they can be at left hand side of the programmer that is at pins 19 and 20. So in case MCU does not Power up by above connections, then do not panic just change the VCC Pins and it might work out. ( This is in my case, so below pitcher is according to that) Now so after successful Connections between STLINKv2 and STM32 MCU, Connect the USB cable between STLINKv2 and Laptop and LED light on the programmer will lighten up in RED color.          Figure 5 (These are the Final Connections For SWD+SWO) Software Part used Now I will be Showing STM32CubeProgrammer and STM32Cube IDE In this blog in software part. First with STM32CubeProgarmmer: As u connect your STLINKv2 Programmer to your computer, IN STM32CubeProgrammer u will see the Serial Number of Programmer if all goes well. As shown in Pic. Figure 6 Now as u click on Connect Button by selecting STLINK, u will see all the details of Your respective MCU details and showing its memory Content. (In doing so Your programmer will start blinking in red, green color and Screen of STM32CubeProgrammer might take 1-2 secs of time for showing Memory contents and MCU details.) Figure 7 This is just Demonstration of Successful connections of STLINKv2 and MCU for SWO+SWO pins and established Communication between Programmer and Laptop via STM32Cube Programmer. As if now, we have not used the trace features, for using that we must create a project and Upload in MCU by things mentioned in below section. For

Embedded Basics Embedded MCU's ESP SoC

Intro to Hardware and Software tools : esp8266

Table of Contents Introduction Most of the viewers reading this blog must have known the word NodeMCU or esp8266 WiFi chip. For those who don\’t know just for the introduction, it is a WiFi chip that is connected with the embedded products that give u the feature of wireless communication in your device. Now there are many tutorials and resources (getting started with esp8266, how to make and add WiFi functionality on your project using esp8266 and NodeMCU ) which are just one google search with full source codes and circuitry. The content of this blog is not related to any tutorial. The thing which comes to my mind when I first get to know about esp8266  is What is the working and technology behind a device which connects to our WiFi  ( like WiFi is a wireless communication which is more raw language we can say a bunch of electromagnetic waves which are radio waves or radio frequency in wireless communication). We have wifi-connected devices everywhere around us in laptops, phones, watches, etc. How does a small IC( here talking in reference to esp8266) which is about the size of our finger connect to these electromagnetic waves and also decode them ??? What is the basic classification of these chips ???  What are the hardware and software tools which are needed for them???? and many such things that actually the whole hardware and software is set up for programming these chips and using in our embedded device. So this blog will be all about answers to these questions, as an understanding of these things will get u knowledge that how in actual a controller(like Microcontroller, Soc, etc) is interfaced with the outside world. As esp8266 is open source so there are many resources and tutorials given for it but what if we need to integrate a controller or any wireless chip that is not open source ( like in our laptops, smartwatches, smartphones)  and also there are many WiFi chips other than esp8266 which are used in our embedded products and which are not open source. So to have an understanding of the whole hardware and software environment for an embedded developer is important to concern. As understanding, these things will get u knowledge that how in actual a controller( like Microcontroller, Soc, etc) is interfaced with the outside world. Hardware Development Kit / Hardware Setup Esp8266 is a standalone wifi MCU or Wireless SoC that connects to wireless network internet. It is produced by Espressif Systems in Shanghai, China. After reading this definition of esp8266  i got a question that how MCU connects to our wireless communication ( basically  radio waves ) as in most simple words u can say that MCU is a bunch of transistors which are miniaturized in a single IC and transistor is a  device which is used for switching purpose or  amplification . Now these transistors are miniaturized in a small IC using RF-CMOS technology which integrates our radio frequency with the electronic circuits(which are made up of transistors ). This RF-CMOS technology is the reason behind we today have wireless communication like WiFi, Lora, cellular communication. Now this MCU requires some external circuit like reset circuit, crystal oscillator to make this MCU work ( just like we make a circuit for boot-loading the AVR MCU) and that circuit is what we call as WiFi modules e.g. esp01 -12 series of modules (made by third party manufacturer AI thinker labs) and ES Wroom-02 series of modules made by Espressif Systems. Now, these modules are integrated with an external circuit like a voltage regulator, USB to UART interface controller for connecting the host computer for programming the esp8266 chip. This integration of modules with these circuits is development boards. Most common and popular development boards are NodeMCU, Bolt IOT, Adrafruit huzzah esp8266 breakout, etc. Software Tools and Environment Setup Classification In Embedded systems when programming on a controller, there is a need for toolchains, Software Development Kits(SDK), Integrated Development Board for creating the software environment to upload the programs or firmware into it. Tool-chain – Is a set of all programming tools that are used to perform a complex software task or to create a software environment for a controller in embedded systems. These programming tools can be IDE, Compiler, debugger, etc, Software Development Kit (SDK)- This includes the necessary building blocks for developing applications. This includes the framework, libraries, Header files, Compiler, Debuggers, DLL libraries, and other tools to compile source code into the executable program. One can write Source Code in any text editor and build our program using the tools of SDK. Integrated development environment (IDE)- integrates all these SDK features, including the compiler into the GUI interface which makes it easier for the user to access all these features and easy to develop Software. The main concern here is that when we want to write programs for a controller in embedded systems there are many tool-chains available for them and tool-chain forms our software environment. Now in the tool-chain, our IDE comes which is the software application that contains all the tools and files required for programming the controller like the ARDUINO IDE provides a tool-chain to a number of controllers -AVR, SAM, NRF52  , esp8266 MCU and many others. And our IDE contains the SDK and makes them in GUI interface for user friendly. Also  Some Tool-chain use the command-line interface in which commands are written instead of clicking the icons by going to the path directory of the SDK. To be noted down: Now for esp8266 the most common and popular tool-chain is using the Arduino IDE.  Software Environment for esp8266 Now there are many tool-chains for programming the esp8266, we can program esp8266 in python as well as C,C++ language depending upon the tool-chain we chose. like 1) Using Arduino IDE –  A C++-based firmware. With this core, the ESP8266 CPU and its Wi-Fi components can be programmed like any other Arduino device. The ESP8266 Arduino

Stay Updated With Us

Error: Contact form not found.