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
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
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
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.
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
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
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
Table of Contents Other Processors to know about Overview In my Last Blog We talk about Trace and Debug Features in Firmware development. What role does they play and their importance in Developing Firmware for any project and Product can be of Great Importance. Now If you are an enthusiastic engineer just like me. You might be interested in how Debug and Trace things are working and implemented in our Embedded Controllers. Like Our CPU processors are running at higher frequency of more than 10 MHz (Just to tell Some even run at more then 100-200 MHz). That is, they can perform 1000000 instructions in just a single second!!!! That is fast and insane. As I have mentioned in Previous Blog about the Debugging Features, one can execute the instructions line by line. By that I mean that one can execute 1 instruction at a time. Just imagine how fast it executes 1 instruction and one can control those executions which are happening in ns,ms,us. Doesn’t this excite you; how does that happen???????? Or if We talk about Setting Breakpoint and then halting the processor, like it means when the CPU is executing 10000000 instructions per second. One can stop Our Machine that is running at the speed of MHZ at any Particular Instruction!!!! If talking About Trace Features, it tells about our code Performance and efficiency. So, generating data like How much time does the instructions take, time for their execution, space used by them and the effect of them in our Code and Performance. Does it not excite and make you think that how actually all these things are happening inside our MCU Core Processor. And remember guys all such things are happening at a time delay of ms, ns, us. That is fast and insane. So, telling You Answer for these Questions, As I have mentioned in My previous Blog also that Trace and Debug is just like a Peripheral in our Core Processors. And they have their Own Circuitry, Components, Communication Protocol, Communication Pins, Communication Busses and Own Programmable Registers for configuring Which Debug and tracer features to use and setting them up. In the case of ARM Processors This Peripheral is designed by the name of CoreSight Architecture. Now it has a number of components like ITM, DWT, STM, DAP etc. which collectively provides features of debug, Trace, Timestamp, Prolific Counters and many more. CoreSight Debug Architecture “The ARM Cortex M/R/A processor uses the CoreSight for on-chip Debug and Trace capabilities.” CoreSight Architecture is designed in a very modular way which has Number of Components and Units providing debug and trace solutions with high bandwidth for whole systems, including trace and monitor of the system bus. These Components can be categorized in following Sections: Control and Access Components à Configure, access, and control the generation of trace/Debug. They do not generate traces, nor process the trace data. Debug Access Port (DAP) Embedded Cross Trigger (ECT) Trace Sources-> Components which generate trace data. Embedded Trace Macrocell (ETM) Instrumentation Trace Macrocell (ITM) AHB Trace Macrocell (HTM) Flash Patch and Breakpoint unit (FPB) Data Watchpoint and Trace Unit (DWT) Program Trace Macrocell (PTM) System Trace Macrocell (STM) Embedded Logic Analyzer (ELA) Trace Sink -> Sinks are the endpoints for trace data on the SoC. Trace Port Interface Unit (TPIU) Trace Memory Controller (TMC) Serial Wire Output (SWO) Embedded trace Buffer (ETB) Trace Links-> provide Connection, triggering and flow of traced data between Source and Sink. Trace Funnel Trace Replicator ATB Bridge Debug and Trace Buses à The CoreSight systems use the following bus protocols to connect components together, and to enable integration in a SoC. AMBA Trace Bus (ATB). AMBA 3 Advanced Peripheral Bus (AMBA 3 APB). Advanced High-Performance Bus (AHB). AMBA Advanced extensible Interface (AXI) ARM licenses the different Components of CoreSight Architecture to the SoC manufacture vendors.According to the ARM Processor these Components vary like in Cortex -A72, Trace Source components ELA and STM are there whereas in Cortex M3/M4, Trace Source Components ELA and STM are not included in its Architecture.Same way-out Trace Sink Components also vary from ARM Processor to processor.Depending on these Units and Components used by vendors for their Processor design there can be changes in features available for trace and Debug. Debug Access Port (DAP) Enables the Debug Access between SoC and Host Debugger. Debug Ports are used to access External Debugger and Access Ports are used for on chip System Resources. Debug Port (DP) JTAG and SWD (+SWO pin – for trace) are the communication Protocols which can be used for Debug/Trace. Now for Connecting and having communication with MCU core to the host debugger (Stlinkv2), we need special Port (I/O pins) on the MCU as these protocols work at very high bandwidth and are directly in play with the Processor. This port is called Debug Port. There are 3 Debug port modules which are available in all ARM cortex M processors: SWJ-DP (Serial wire JTAG Debug Port) à Supports both Serial Wire and JTAG protocols SW-DP (Serial wire Debug Port) à Supports only Serial Wire Protocol. JTAG-DP (JTAG Debug Port)à Supports only the JTAG Protocol, available in older generations of ARM Processor and almost every Processor. Debug and Trace Buses & Access Port (AP) Access Port is a Port that connects the DP and the Components of the CoreSight Architecture. The CoreSight systems use the following bus protocols to connect components together, and to enable integration in a SoC. AMBA Trace Bus (ATB-AP) AMBA 3 Advanced Peripheral Bus (AMBA 3 APB) Advanced High-Performance Bus (AHB-AP) AMBA Advanced extensible Interface (AXI-AP) ARM Cortex M3/M4 Advanced High-Performance Bus (AHB-AP) is used for internal debug bus protocol to connect different Debug Components together. Embedded Cross Trigger The ECT is a modular component that supports the interaction and synchronization of multiple triggering events within a SoC. There are
Table of Contents Definition of ARM CoreSight \”CoreSight is the Debug Architecture from ARM for Debugging and Trace Solutions in Complex SoC designs (Single core and Multi core)\” CoreSight Provides all the Infrastructure that is required to Debug, Trace, Monitor, and optimize the performance of a Complete System on Chip (SoC)Design. The Debug and Trace Features of the ARM Cortex M processors (M3/M4/M33/M7/M0, etc.) are designed based on the CoreSight Debug Architecture. This Architecture Covers a Wide Area Including Debug Interface protocols, on chip bus for debug access, Control of debug components, security features, trace data interface and more. Debug and Trace in Embedded Systems By now one obvious question to beginners or newbies that must have come in their mind is what is Debug and Trace. What are these features for which we have a whole complete Architecture called CoreSight? Why do we need Debug and Trace solutions in our Processors/Embedded Controllers? Is it not? For those readers They can check out this blog, providing you clarity and understanding of all such questions. One can Understand Debug and Trace Feature/Functionality as one of the Block/Unit of the Processor. Just like We have UART, SPI, I2C, etc. peripherals for our Microcontrollers for which we have separate Block, Architecture, Peripheral Memory Registers for accessing them and Communication Protocol pins in our Microcontroller. Same Way-out Debug/Trace is one of the peripherals which is present in our Processor for which it has its whole architecture and above Marked things. ARM Processor has CoreSight Architecture. MIPS Processor has EJTAG Architecture. IBM PowerPC processor has COP. (Units/Block of the Processor are not called peripherals, I have used the above term just to make u understand the analogy) What are Debug Features?? Features are used to observe or modify the state of parts of the design. This is also Called Invasive Debugging Execute instructions line by line function i.e., halting the processor after execution of each line of code(single stepping). Execute Instructions Function by function i.e., halting the processor after execution of each functions (Step Over) Return from the Function (Step Return/Step Out) Stop the processor (halting) Stop the Processor at a particular à line of code (called Breakpoint) àmemory address (Called Watchpoint) à coded condition of a variable or memory address is achieved (Conditional Breakpoint/Watchpoint) On can control the program execution (By points 1-5)so as to examine(Both read or Write) the change in value of bits of the MCU Peripheral registers and Core Processor Registers (like examining the contents of UART peripheral Registers to mark at which line of code data is received or transmitted by seeing the UART Status registers which has corresponding bits to indicate the event of receiving and transmit data). Debug frequently involves halting execution once a failure has been observed and collecting state information retrospectively to investigate the problem. There are 2 Communication Protocols For using Debug Features: SWD & JTAG JTAG is an industry Standard protocol (IEEE 1149.1) which is used for debugging and boundary scan testing. It is the de facto Serial Protocol which is present in almost every Processor Family other than ARM also like AVR 8 core, MIPS, PowerPC, etc. To be noted down: JTAG Requires 4 pins: TCK, TDI, TMS, TDO; the recent signal TRST is optional. ARM CoreSight Technology introduced the 2 wire Protocol SWD (Serial Wire Debug): SWCK and SWDIO which is used for Debugging all the ARM based Processors. The Serial Wire debug(SWD) protocol provides the same debug access features and supports parity error detection, which enables better reliability in systems with higher electrical noise. Therefore, the Serial Wire debug protocol is more favorable then JTAG Interface. Also, SWD and JTAG debug protocols share the same Connections: TCK and SWCL use the same pin, TMS and STDIO use the same pin. The SWD port alone does not allow real-time tracing. What are Trace Features?? Trace refers to the process of capturing data that shows information about how the components in a design of a firmware are operating, executing, and performing. This is also Called Non-invasive Debugging. It is real-time (with a small timing delay) and can provide a lot of useful information without stopping the processor. Information like: Amount of execution time for each function(Statistical Profiling) Call hierarchy and execution time sequence of functions Event Execution timing(Timestamp) Clock cycles taken for execution of a particular Instruction. Examine or change the contents of the memory or peripherals at any time, even when the processor is running. This feature is often called on-the-fly memory access. Data Trace(Monitoring the Variable or Memory address in Real Time execution of Code and Plotting their graph). Instruction Trace(information about Instruction execution of a Core)ETM & PTM). Instrumentation Trace (Printf () Statement via ITM). System trace Trace is an advanced version of Debugging as it analyzes the performance of our firmware code and how efficient it is in terms of memory and efficiency by capturing the various kinds of data when the CPU is running. For Trace features there are 2 Modes: 1 Serial-Pin model called Serial Wire Viewer à Using Serial Wire Output (SWO) with Serial Wire Debug (SWD) interface. The Serial Wire Output (SWO) pin can be used in combination with SWD. It is used by the processor to emit real-time trace data, thus extending the two SWD pins with a third pin. The combination of the two SWD pins and SWO pin enables Serial Wire Viewer (SWV) real-time tracing in compatible Arm® processors. The Serial Wire Viewer (SWV) is a real-time trace technology that uses the Serial Wire Debug (SWD) port and the Serial Wire Output (SWO) pin. The Serial Wire Viewer provides advanced system analysis and real-time tracing without the need to halt the processor to extract the debug information. 2 Multi-pin Trace Port interface (4 data pins + 1 clock pin). For Capturing the Data There must be à Source for generating the Trace data àSinks are the endpoints of trace data à Links provide Connection, triggering and flow of traced data between
The basic premise of search engine reputation management is to use the following three strategies to accomplish the goal of creating a completely positive first page of search engine results for a specific term…