Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

411 University St, Seattle, USA

engitech@oceanthemes.net

+1 -800-456-478-23

Embedded Basics Miscellaneous Tech

Build Technology in Microcontrollers

Why building the project is required ? so After, we have developed/configured the code and we have got the .c & .h files in our project. Now microcontrollers can’t understand the text which is written in these files. They only understand the Binary language of 0 & 1. So we have to convert these .c & .h files into a single file of binary language which the microcontroller can understand. Now these .c and .h files can be in 1000 numbers in some projects. So you can think of how much processing is done to analyze all files, check them for any errors and then convert them into a single file of binary language. This work is done by compilers and the build process. This technology is truly amazing, and its process is even more interesting. What is building the project in embedded and how is it done? In embedded “building the project” refers to the process of compiling and linking the source code and resources of an embedded software application to create an executable binary file that can be loaded onto the target embedded hardware platform. In Embedded, Build process is the process of converting multiple source files into a single file that can run on a computer. So as to understand this process and the technology behind it, let’s understand the procedure/step involved in doing so. Preprocessing(.i files) Compilation(.s files) Assembly(.o files) Linking(.elf files) Preprocessing(.i files) Preprocessing :-  Before the actual compilation, the C preprocessor comes into play. It handles directives that start with `#`, such as `#include` and `#define`. It performs macro expansion and file inclusion. The preprocessor generates a modified version of your code, often saved with a `.i` extension. Compilation(.s files) In this phase, the preprocessed code (`.i` files) is translated into assembly code. This step is performed by the C compiler (e.g., `gcc` for GNU C Compiler). The compiler checks your code for syntax errors and generates an assembly code file (usually with a `.s` extension). Assembly(.o files) The  code generated by the compiler is not yet in a machine-executable format. It’s a human-readable representation of the code. The assembler takes this assembly code and translates it into machine code, generating an object file (typically with a `.o` or `.obj` extension). Linking(.elf files) Most C programs consist of multiple source files, and each one might produce an object file. The linker (e.g., `ld` for GNU Linker) combines these object files along with any necessary system libraries to create an executable binary file. This is the final output of the compilation process, often with no file extension or a `.exe` (on Windows) or no extension (on Unix-based systems) for executable files. It’s important to note that the compilation process can be controlled through various compiler options, allowing you to customize how your code is compiled, optimize it, and handle various aspects of the process. Building an embedded project is a crucial step in the development process, as it ensures that the software is correctly translated into machine code and can run effectively on the embedded hardware, meeting the project’s functional and performance requirements. After the building process is done then which file is created. After the build process is done then these files are created and then deployed onto the target embedded hardware. Executable Binary (Firmware) : This is the primary output of the build process. It’s a binary file that contains the machine code instructions and data necessary for the embedded system to execute your program. The format of this binary file may depend on the microcontroller or processor used and can include extensions like .bin, .hex, .elf, .s19, etc. Object Files : During compilation, each source file is typically compiled into an object file (with extensions like .o or .obj). These object files contain machine code generated from the corresponding source code and may include debugging information. Debug Information : Debugging information (often in a format like DWARF) can be included in the binary or stored in separate files. This information helps debuggers associate machine code instructions with your original source code, making it easier to debug your program. Hexadecimal Files : In some cases, especially when programming microcontrollers, you might generate hexadecimal files (with extensions like .hex) that specify the memory contents, including both code and data, in a human-readable format. Assembly Listings : Some build systems can generate assembly listings (with extensions like .lst) that show the generated assembly code alongside your source code. This can be useful for understanding how your high-level code translates into machine code. 7. Other Output Files : Depending on your specific development environment and tools, you might encounter other files related to the build process, such as project configuration files, build logs, or build artifacts generated by plugins or extensions. Like the Cmake , SDK files etc. In this IDE when the build process is done the compiler gives us a .elf file that can be loaded onto the target embedded hardware. The exact set of files generated can vary widely based on your development workflow and tools, so it’s important to consult the documentation for your chosen development environment and build system to understand the specifics for your project.( To understand build process and specifies of S32K144 MCU, refer this).   Which tools are used in building the project? When we build an embedded project there are some files and a compiler that is used to build the project.  Makefile Linker script Startup code GNU GCC Compiler Make file :-   A makefile can be considered as a script or a set of commands which help build, compile, link the entire project in order to create an executable. The makefile defines a set of tasks to be executed.A makefile does not have any extension. The makefile has to be specifically named as “makefile”. Linker Script :- A linker script is used to specify how object files should be linked together to create the final executable binary. It defines the memory layout of the

Automotive Cryptography Industries Tech Technologies

Secure Hardware Extension: Cryptography peripheral for automotive chips

The more realistic you get, the more distinct you become in modern world Gettobyte What is SHE (Security Hardware Extension) Technology? Secure Hardware Extension, short form SHE: is a standard that specifies performing basic cryptography ciphers and managing cryptography keys via automotive Microcontrollers. SHE has been stated as standard in automotive microcontrollers to protect the cryptographic keys from software attacks by hardening them into the memory of the microcontroller and to perform basic symmetric cryptographic ciphers like AES & CMAC for encrypting and decrypting the data. SHE standard is implemented in microcontrollers by having an on-chip extension(peripheral) as a security subsystem which follows, the SHE standard. SHE standard is stated by hersteller-initiative-software (HIS) consortium in April 2009. This consortium was founded in 2004 and consists of members from Audi, BMW, Daimler, Porsche, and Volkswagen to address activities and develop common automotive manufacturing standards. SHE standard states that the peripheral in the Microcontroller should have the following 3 blocks, to implement SHE standard in MCU: Control Logic: Connecting the parts of the CPU to the microcontroller. Storage Area: To keep the cryptographic keys and additional corresponding information. Cryptographic cipher core: a hardware core or module to perform necessary calculations for performing cryptographic ciphers. Automotive Chips, which have SHE peripheral: MPC5646C Freescale MCU’s S32K144 NXP Semiconductor’s MCU Components of SHE Technology SHE Technology  Why SHE Technology? Working principal of SHE Technology? USE cases of SHE Technology? How to use SHE Technology? Add Your Heading Text Here

Getting Started NXP Controllers S32 Automotive Platform Tech

Getting Started with S32 Design Studio Part 3

Objective of This blog Understanding the code: Talk about different views. IDE Properties and Configurations Building & debugging the code: Debug configurations and how to use Understanding the Code Now after code configuration, our code will be generated. We can see the project files/folder in Project Explorer and write/modify/develop the c/cpp code on the code editor. As shown below. Now it’s time to explore the features S32 Design Studio provides for code navigation and development. Now in this section, I am going to talk about different features/views present in S32 Design Studio for Embedded Code navigation/development. Text Editor View Outline View Console Project Explorer Search Text Editor View Text Editor view: This is the main view, onto which programming is done. Double clicking on any file from Project Explorer will open the open in text editor. We can configure the Text Editor by going to Window->Preferences. We can configure Text editor features like Line number, White space characters, Text Editor Colors. It’s good to explore such features to make the development process on S32 DS interesting. Outline View Outline view: This is one of the best and most useful view.  The Outline view displays an outline of a structured C/C++ file that is currently open in the editor area, by listing the structural elements. As you can see, this view makes very easy for navigation in the corresponding .c/.h file. Console Console: Console is the place where we can see the Verbos of the compilation process of our project. During compilation process. all the errors and warnings are listed in console window.  Console view Project Explorer Project Explorer: Project Explorer view is the one where we can see our project, when it is created or opened. One can see the proper folder structure and files which are their in our project. Project Explorer view in S32 DS By left clicking, on the project in Project Explorer, we can configure our project. Project Explorer in S32 DS We can configure the project in terms of New File/Folder Creations in our project, Build Configurations and SDK management of our project.  One of the most important options in this list is Properties, where we can configure Project setting of our project. I leave this section to explore on own, if you face any issue or want to know things mention them in below comment section. Search Search: Often during the course of Embedded Software development, we would be dealing with the large Project’s in which there are 1000’s of lines of code written in single file and 100’s of files are there. So, in that case using the search view makes things easy to locate. IDE Properties and Configurations Window-> Editor Window ->Preferences Help -> S32 DS Extensiona nd Updates Help -> S32 Check for Updates Help -> Install New Software Help -> Help Contents How to Build the Code in S32 Design Studio IDE Step 1 Step 2 Step 1: First go to file and click on the new tab and then click on the type of project you want to build in the IDE ex :- example project, library project, application project, makefile project, c/c++ project etc. Let’s start with the example code. So, firstly go to the menu bar and click on file and then tab the new button on the file and select the first option that is projected, for  example this will show in the below fig. After this a popup will come and choose the controller in our case it is s32k144 then search the controller and choose the project from the predefined code in this case we are opne the hello world example code. This will be shown in the figure below. Choose the project name and then click on the finish tab. After this a popup will come and choose the controller in our case it is s32k144 then search the controller and choose the project from the predefined code in this case we are opne the hello world example code. This will be shown in the figure below. Choose the project name and then click on the finish tab. Now you can clearly see the project in the project explorer window . Step 2:  For building the project you can simply right click on the project name and click on the build project and then your project is start building you can see this in the below fig If the build is successfully done then the output is shown in the fig below. Debugging tools supported in S32 Studio Different types of hardware debuggers in s32 design studio. there are two types of hardware debugger in S32 design studio which is supported by the S32 design studio SEGGER J-LINK debugger SWD based PEMicro debugger SEGGER J-LINK debugger The J-Link Debugger is a popular hardware debugger and programmer developed by SEGGER Microcontroller, a company specializing in embedded systems and software tools. J-Link is widely used in the embedded development industry and provides a range of debugging and programming capabilities for various microcontroller architectures and development environments. GDB PEMicro GDB PEmicro is a debugger interface that allows the GNU Debugger (GDB) to communicate with P&E Microcomputer Systems’ hardware debuggers and programmers. It enables developers to use the GDB debugger, a powerful and widely used open-source debugging tool, in conjunction with P&E Micro hardware to debug and program microcontrollers and embedded systems. Here’s how GDB PEmicro works and its key components: GNU Debugger (GDB): GDB is a widely used and versatile debugger for various programming languages and platforms. It provides features such as setting breakpoints, examining and modifying memory and registers, stepping through code, and more. GDB is commonly used in embedded systems development. P&E Micro Hardware Debuggers: P&E Microcomputer Systems produces a range of hardware debuggers and programmers designed for embedded systems development. These debuggers, such as the Multilink and Multilink FX, are used to connect a host computer to a target microcontroller for debugging and programming purposes. GDB PEmicro Interface: GDB PEmicro is essentially

Getting Started NXP Controllers S32 Automotive Platform Tech

Getting Started with S32 Design Studio Part 2

Table of Contents Overview So, hello guys, welcome to Gettobyte website. This blog is part of the Microcontroller coding series on NXP Semiconductors S32K144 MCU. Objective of this series is to learn Microcontroller technology by getting knowledge on how to do microcontroller coding. And for doing so we would be proceeding with NXP Semiconductors S32K144 Microcontroller. To know about this Microcontroller and reasons for selecting this MCU, it would be nice to have a look onto this blog. In the previous blog we had Started with S32 Design Studio, installed the IDE and installed S32K1 SDK and Development package. S32Design Studio Part 1 Objective of this Blog Now in This blog we are going to explore the Code Configuration Tool of S32 Design Studio and see how to use it. Code configuration/Generation: About S32 CDT and how to use it. About Code Configuration Tool In S32 Design Studio there is code configuration tool for S32 controllers, by the name of S32 Configuration Tools. S32 Configuration Tool is a set of tools that helps one do initial configuration and evaluation of the Embedded Software for the corresponding S32 Microcontroller without actually writing any code and just by playing on the GUI of tools we can do all basic development. So, for doing so we need to have some basic familiarity with the corresponding Microcontroller and its peripherals. In our case we are using S32K144 MCU, so to get knowledge of MCU best place is from its reference manual and user guide. But i guess most of the people find it very tiering and boring to read docs, so in subsequent blogs of S32K144 MCU. I have explained about each peripheral of MCU, in detail also. You can refer some blogs from here: GPIO Peripheral in S32K144 MCUClick HereUART Peripheral in S32K144 MCUClick HereI2C Peripheral in S32K144Click HereSPI Peripheral in S32K144 MCUClick HereClock Peripheral in S32K144Click HereCAN Peripheral in S32K144Click HerePort Peripheral in S32K144 MCUClick HereElectronicsV3: Automotive Development Board based on S32K144 MCUClick HereAutoBoardV1: Automotive System on ModuleClick Here Previous slide Next slide Coming back to our topic, of S32 Code Configuration Tool’s lets first see how to open Code Configuration tool. Opening S32 Code Configuration Tool (CCT) To Open the S32 CCT, make sure that you have installed the required MCU development package and SDK files. Make sure to read the previous blog and completed the section of Software Installation from it. S32 CCT would only be opened, if you have opened the Some project on the Project Explorer, either from Demo Example or by creating a project from scratch or opening already S32K1 MCU developed code. To know how to open/create a project in S32 Design Studio, make sure to read the previous blog and completed the Project Creation section from it. Step 1 Step 2 Step 1 Once you have opened some Project of the Corresponding MCU on the Project Explorer Window of the S32 Design Studio, then you can see an icon like this above it: S32 Code Configuration Tool Icon in S32 Design Studio Step 2 Clicking on the small blue rectangular icon, we will be able to open the S32 Code Configuration Tools. Also, alongside the blue icon, you can see there is a drop-down, clicking on it will show you the menu of Code Configuration Tool. S32 Code Configuration Tool Menu Option in S32 Design Studio If you see window like this when clicking on blue icon: S32 CCT tool cant open Then just check if you have properly installed the SDK files and development package of the corresponding MCU. Now let’s move ahead with First option, as that will open Home/Default view of the S32 CCT, as shown below: Home View of S32 Code Configuration Tool So that’s how you open S32 Code Configuration Tool for corresponding MCU in S32 Design Studio Understanding S32 Code Configuration Tool Icons Icon 1 Icon 2 Icon 1 The first 4 icons from the left, are basic icons. As you hover from them, you will what they do. Create new project, Save, Save All and build all. Icon 2 Next Icon is for selecting the project. Project which you have opened in Project Explorer can be selected from their and corresponding to the S32 MCU which is used in the project, CDT tool will show things. Selecting Project in S32 Config tool Now as we open the S32 Code Configuration Tool, there are many icons and windows we can see on the window. It might be confusing or overwhelming at first but don’t worry, we will go step by step. Let’s first understand, the menu bar of the S32 CDT tool. The first 4 icons from the left, are basic icons. As you hover from them, you will what they do. Create new project, Save, Save All and build all. Next Icon is for selecting the project. Project which you have opened in Project Explorer can be selected from their and corresponding to the S32 MCU which is used in the project, CDT tool will show things.   Next icon is S32 Config Tools, clicking on it will open the window in which it shows ALL the config tools which can be used for the project that you have selected in last step. One can see in bottom left of this image, it is written some tools are there for the selected project, that because selected project is using S32K144 MCU and S32K144 MCU don’t have QSPI peripheral, IVT features. There are number of tools in S32 CCT, but depending on MCU of the project avaiblity of tools can vary. As tools are dependent on the S32 MCU, if corresponding MCU don’t have some features, so tool corresponding to that feature would also not be there. So, in S32K144 broadly there would Pins, clock and peripheral Config tools would be used. Clicking on these tools, from here will open that corresponding tool. Also in last step, you can see details of the project. Like Project path, Which SDK is

Display Screens Sensors and Modules Tech

What is OLED Technology?

OVERVIEW Nowadays we see oled display being used everywhere be it the phones , TVs , laptops or PCs , smartwatches . They sure are better than old chunky CRT TV displays that were bulky and didn’t deliver the desired picture quality , with the introduction of the LCD and backlight LEDs the things sure got better with the chunkiness of the display gone but the picture quality still wasn’t what one desired of but with the release of the OLED display all these problems became a thing of past. OLED or organic light emitting diode were invented in 1987 by Ching Tang and Steven Van Slyke from Kodak but it was until 2004 when SONY released a OLED TV. In fact in CES 2019 , there were some innovative inventions that were released in the OLED domain with the companies trying to come up with foldable display and some exceptional picture quality. TYPES OF OLED Passive Matrix Oled (PMOLED) Pmoleds have strips of cathode , anode and organic layer. The anode strips are perpendicular to cathode strips it is their intersection that makes a pixel . External circuitry applies current to the cathode and anode strips to decide which pixel to light up. They are used in MP3 players , cell phones etc. Active Matrix Oled(AMOLED) Amoleds have full layer of anode and cathode and organic molecules . The anode layer overlaps the TFT matrix array . The TFT array is the matrix circuitry that decides which pixel gets turned on form the image. Since they consume less electricity they are used in TV screens , BillBoards, Computer Monitors. Transparent Oled A Transparent Oled has all the components cathode, anode, substrate transparent and when off the display is 85 percent transparent. When switched ON the display allows the transfer of light in both the directions. Top Emitting Oled The Top Emitting Oled is have substrate that is either opaque or transparent . They are best suited for active matrix design . They are used in smartcards                   Foldable Oled They are substrate that made of flexible metallic foil , plastic . They are durable and are easier to replace in case of damage . They are used in smart clothing , GPS receivers , IC computers. White Oled They are made of white light that is more uniform and energy efficient rather than fluorescent lights. They posses true color of incandescent lights BESIDES THESE OLEDS ARE ALSO CATEGORIZED ON THE BASIS OF BASE COLOUR Monochrome Blue Monochrome white Yellow Colour NO OF PINS 3 Pins (supports only I2C) 7 Pins(supports both I2C and SPI) BASED ON INTERFACE ICs    SSD1306     SSD1331 BASED ON SIZE 0.91 inch(128×32) 0.96 inch(128×64) HOW OLEDs WORKS Both the LCD and OLED have similar display mechanism . The difference lies in the fact that OLED has the smallest display unit made of pixels that are usually 0.3mm x 0.3mm . Inside each pixel they are 3 different type of color filters . When the size of the color filter is reduced then human eye losses its ability to view each color individually and sees them as a mixture. Next each pixel is converted into digital form for future reproduction of the image. Earlier the image reproduction was done using backlight white , colour filters, glass , diffuser . When the light would glow each color filter would light up too. Behind the filters a polarizer lcd sheet is used which reproduces the image , the problem with this was the black colour produced wasn’t exactly black due to the back light being ON constantly . This issue was rectified using tiny light sources for each pixel due to which organic led was used . If we apply positive voltage to the anode termina the electrons would combine with the holes in the LUMO layer producing light. Work is also being done to remove the need for light source and add doping material in the emission layer which will release light of the certain color due to the energy difference in the conduction and valence layer corresponding to their wavelengths FIG -1 SIZE OF A SINGLE PIXEL FIG-2 RGB COLOR FILTERS INSIDE A PIXEL FIG -3 CONVERTING EACH COLOR INTO BINARY FIG -4 CROSS SECTION VIEW OF OLED FIG-5 CHANGING THE ORIENTATION OF THE POLARIZER TO GENERATE DIFFERENT COLORS FIG -6 ELECTRON HOLE PAIR COMBINATION TO GENERATE LIGHT FIG – 7 DOPING OF SUBSTRATE TO GENERATE LIGHT OF VARIOUS WAVELENGTH USE CASES OF OLED DISPLAY Raspberry Pi Based SSD1306 OLED Video PlayerThis project uses Raspberry pi and OpenCv to display videos on the Oled display ESP8266 Weather WidgetThis project used ESP8266 and weather API to display real time weather conditions on the 0.96 inch display. Tinyduino gamepadThe project used joystick , push buttons , arduino uno , custom designed PCB , USB module  and ssd display to play games on the tiny 0.96 inch screen Bluetooth SmartwatchThe project uses 0.96 display , bluetooth module , tiny arduino , lipo battery to connect to the phone and display all kinds of medical stats and time Speedometer for bikes The project uses gps module neo6m and ssd1306 display to show speed of the vehicle on the display and raise an alarm in case of overspeeding.                                                                                                 HOW TO CONNECT THE DISPLAY WITH THE MICROCONTROLLER WE WILL BE COVERING THE DETAILS ON HOW TO CREATE AN EMBEDDED DRIVER FOR THE DISPLAY IN THE NEXT BLOG . IN THIS WE’LL BE COVERING A BRIEF OVERVIEW OF THE 2 METHODS THAT CAN BE USED TO COMMUNICATE WITH THE DISPLAY. I2C SPI I2C Using I2C we’ll be communicating with the microcontroller by the help of SCL the clock

Display Screens I2C Modules Sensor/Module Interfacing Sensors and Modules Tech

CONFIGURING THE OLED WITH STM32 MCU

In previous blog we covered a brief overview of how the OLED display works in microscopic level and also understood various types of OLED displays available in the market . In this blog we’ll be discussing  how to configure the SSD1306  display with the microcontroller and we’ll be  making the embedded driver as well.128×64 display is a dot matrix display , hence 128×64 =8192 total pixels . It is by turning on/off these pixels we display graphical image of any shape . It is the current provided to each pixel that varies the brightness. HARDWARE DESCRIPTION OLED Display chosen is driven by SSD1306 Driver IC although they are other ICs such as SSD1331 which can be used to drive the display . These ICs  are CMOS OLED Driver controller for dot-matrix system . OLED has 256 brightness steps .Besides 128×64 , 128×32 display resolution is also available. Specification of ssd1306 128×64 OLED Display Type: OLED (Organic Light Emitting Diode) Display Size: 128×64 pixels Display Driver: ssd1306 Display Colors: Monochrome (White), Yellow, and Blue Operating Voltage: 3.3V to 5V Interface: I2C Operating Current: ~20mA Display Structure OLED DISPLAY is mapped using GDDRAM page structure  OF SSD1306 GDDRAM or graphic display ram is a bit mapped static RAM . It holds the bit pattern to be displayed. The GDDRAM having size 128×64 is divided into 8 pages from PAGE 0 TO PAGE 7 which is used for monochrome matrix display . When data bit D0 – D7 is sent the row0 gets filled with D0 and D7 is written into the bottom row.  Display has 64 rows , 128 columns divided into 8 pages . Each page has 128 columns and 8 rows. Display 128 columns known as segments For displaying the graphical data in the first location , page address and column address both are set to 0 with the end address of page and column also being selected End of column and End of the page is 7FH and 07H respectively SSD1306 BLOCK DIAGRAM PIN ARANGEMENT SSD1306 FUNCTIONAL BLOCK DIAGRAM SSD1306 BLOCK DIAGRAM PIN ARANGEMENT SSD1306 FUNCTIONAL BLOCK DIAGRAM ADDRESSING MODE 1. PAGE ADDRESSING MODE 2.Horizontal Addressing Mode 3.Vertical Addressing Mode 1. PAGE ADDRESSING MODE In page addressing mode, after the display RAM is read/written, the column address pointer is increased automatically by 1.                                                                If the column address pointer reaches column end address, the column address pointer is reset to column start address but page address pointer not points to next page. Hence, we need to set the new page and column addresses in order to access the next page RAM content. We need to set lower two bits to ‘1’ and ‘0’ for Page Addressing Mode. In page addressing mode, the following steps are required to define the starting RAM access pointer location: Set the page start address of the target display location by command B0h to B7h. Set the lower start column address of pointer by command 00h~0Fh. Set the upper start column address of pointer by command 10h~1Fh 2.Horizontal Addressing Mode In horizontal addressing mode, after the display RAM is read/written, the column address pointer is increased automatically by 1. If the column address pointer reaches column end address, the column address pointer is reset to column start address and page address pointer is increased by 1. When both column and page address pointers reach the end address, the pointers are reset to column start address and page start address We need to set last two digits to ‘0’ and ’0’ for horizontal addressing mode. 3.Vertical Addressing Mode In vertical addressing mode, after the display RAM is read/written, the page address pointer is increased automatically by 1. If the page address pointer reaches the page end address, the page address pointer is reset to page start address and column address pointer is increased by 1. When both column and page address pointers reach the end address, the pointers are reset to column start address and page start address. We need to set last two digits to ‘0’ and ’1’ for vertical addressing mode. In normal display data RAM read or write and horizontal/vertical addressing mode, the following steps are required to define the RAM access pointer location: Set the column start and end address of the target display location by command 21h. Set the page start and end address of the target display location by command 22h. Hardware Pinout SDAThis pin is used to send data between master and slave with the acknowledgement of the master SCLThis is a clock signal that helps keeps the process in synchronization VCCA power supply of 3.3 V is required . More than 3.3V may damage the module GNDThis ground pin is connected to the ground supply ALGORITHM Select the I2C slave address and specify the operation that will be performed i.e Read 0x79 or Write 0x78. #define SSD1306_I2C_ADDR 0x78 Set the clock divide ratio and oscillator frequency . Bit 3-0 sets the clock divide ratio , Bit 7-4 sets the oscillator frequency SSD1306_WRITECOMMAND(0xD5); //–set display clock divide ratio/oscillator frequency SSD1306_WRITECOMMAND(0xF0); //–set divide ratio Set the multiplex ratio switching to any value ranging from 16-63 SSD1306_WRITECOMMAND(0xA8); //–set multiplex ratio(1 to 64) Display start line addressing in which the starting address of the display ram is determined . In our case this is set to zero and RAM row 0 is mapped to col 0 SSD1306_WRITECOMMAND(0x40); //–set start line address Set memory addressing mode using page addressing mode, horizontal addressing mode, vertical addressing mode. SSD1306_WRITECOMMAND(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid SSD1306_WRITECOMMAND(0xB0); //Set Page Start Address for Page Addressing Mode,0-7 Set column address using a triple byte first specifies the column setting , second column start and third column  end . Do the same for the page SSD1306_WRITECOMMAND(0x00); //—set low column address SSD1306_WRITECOMMAND(0x10); //—set high column address Set pre-charge period and VCOMH deselect level SSD1306_WRITECOMMAND(0xDB); //–set vcomh Entire display is on using A4H and A5H command SSD1306_WRITECOMMAND(0xA4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content The normal functionality of the

NFC/RFID Sensor/Module Interfacing Sensors and Modules Tech

Read and Write to a Rfid Tag

In the previous blogs we discussed how to read uid of different tags . Now as discussed in the applications of the rfid cards , the rfid tags can be used to store employee information so as to access certain restricted area. The rfid tags can also be used by retail stores to store customer information and points earned with each shopping. In this blog we’ll be learning how data reading or writing works by looking at the memory map of MIFARE 1K Tag and how to read and write the data using rc522. UNDERSTANDING THE MEMORY MAP OF MIFARE 1K TAG The memory of the MIFARE 1K Tag is divided into 15 sectors and each sector is divided into 4 blocks , within each block 16 bytes of data is stored Hence 16 Sectors * 4 Blocks * 16 Bytes=1024 Bytes = 1K The 0th Block of Sector 0 is used to store manufacturer data , this is usually 4 Byte UID(MIFARE 1K TAG, MIFARE Mini Tag) certain tags are available such as MIFARE Plus , MIFARE Desfire etc that has 7 Byte UID There are 3 data blocks presents in each sector and the last block in each sector is known as sector trailer.The 3 data blocks are used to store user data and the trailer block is used to deter mine the access conditions for all the blocks of the sector . The access conditions include Read , Write , Increment , Decrement ,Transfer and Restore. Each sector trailer consists of following information:- A mandatory 6 Byte Key A. 4 Bytes for Access Bits. Optional 6 Byte Key B (if not used, data can be stored). MEMORY ORGANIZATION MANUFACTURER BLOCK SECTOR TRAILER ACCESS CONDITIONS MEMORY ORGANIZATION MANUFACTURER BLOCK SECTOR TRAILER ACCESS CONDITIONS FUNCTIONAL DESCRIPTION uint8_t MFRC522_Write(uint8_t blockAddr, uint8_t *writeData) This function takes in 2 arguments the address to which the data has to be written and the array or buffer in which data  is stored lets say this to be writedata array. A 8 bit  array of 18 length is also intialized to store data which will be transferred to the memory block. Intially CRC is checked using CalculateCRC function using which takes in 3 arguments array in ( whose first 2 values are PICC Write and blockAddress ), len and output array that stores 2 values CRCResultRegL , CRCResultRegM . Next MFRC522_ToCard function is called which takes in 5 arguments command (in this case that will be PCD_Transceive), send data , send length , back length, back data according to various commands processing is done and according to switch cases status is sent Finally  MFRC522_ToCard in again called (with  PCD_Transceive) and the data is transferred to the FIFODataReg to return with the correct status and finally the PCD is set to idle uint8_t MFRC522_Read(uint8_t blockAddr, uint8_t *recvData) This function is used to read data from a memory block and and put it into a buffer or array hence the argument recvData Similar to uint8_t MFRC522_Write initially the CRC is calculated and MFRC522_ToCard  is called. In MFRC522_ToCard the command argument is set to PCD_TRANSCEIVE due to which the code enter the for loop in which the data that was in FIFODataReg is populated in the recvData Buffer. Finally  MFRC522_ToCard in again called (with  PCD_Transceive) and the data is transferred to the FIFODataReg to return with the correct status and finally the PCD is set to idle uint8_t MFRC522_ToCard(uint8_t command, uint8_t *sendData, uint8_t sendLen, uint8_t *backData, uint *backLen) This function is used to control the MFRC522 according to the command arguments that can be PCD_AUTHENT PCD_TRANSCEIVE Both these commands have different irqEn ,waitIRq that are written into CommIEnReg block which is then cleared using clear bit mask function After finally setting bit mask the PCD is set to idle state The function writes the data in FIFODataReg to the backData buffer and returns the status which is OK in case of no errors STM32CUBE IDE CONFIGURATION FIG 1- PINOUT CONFIGURATION FIG 2 – CONFIGURING THE SPI1 PERIPHERAL CODE #include “main.h” /* Private includes ———————————————————-*/ /* USER CODE BEGIN Includes */ #include “stdio.h” #include “stm32f1_rc522.h” #include “stdio.h” #include “string.h” #include “fonts.h” #include “ssd1306.h” /* USER CODE END Includes */ /* Private typedef ———————————————————–*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ————————————————————*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro ————————————————————-*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ———————————————————*/ I2C_HandleTypeDef hi2c1; SPI_HandleTypeDef hspi1; UART_HandleTypeDef huart1; /* USER CODE BEGIN PV */ void uprintf(char *str) { HAL_UART_Transmit(&huart1,(uint8_t *)str,strlen(str),100); } //uint8_t i; uint8_t status; uint8_t str[5]; // Max_LEN = 16 uint8_t serNum[5]; uint8_t KEY[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; uint8_t KEY2[]={1,2,3,4,5,6}; uint8_t W[]=”PRATYUSH”;/STEP 1/ uint8_t R[10]=””;/STEP 2/ uint8_t test; /* USER CODE END PV */ /* Private function prototypes ———————————————–*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_SPI1_Init(void); static void MX_USART1_UART_Init(void); static void MX_I2C1_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ———————————————————*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration——————————————————–*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI1_Init(); MX_USART1_UART_Init(); MX_I2C1_Init(); /* USER CODE BEGIN 2 */ MFRC522_Init(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { status = MFRC522_Request(PICC_REQIDL, str); //MFRC522_Request(0x26, str) status = MFRC522_Anticoll(str); memcpy(serNum, str, 5); HAL_Delay(1000); MFRC522_SelectTag(str); test = MFRC522_Auth(PICC_AUTHENT1A,24,KEY,serNum);/STEP 3/ MFRC522_Write((uint8_t)24 , W);/STEP 4/ HAL_Delay(1000); MFRC522_Read(24, R);/STEP 5/ HAL_Delay(1000); if (status == MI_OK) { MFRC522_SelectTag(str); test = MFRC522_Auth(PICC_AUTHENT1A,2,KEY,serNum); /*if((str[0]==0) &&

Getting Started and Peripheral Coding STM32 MCU's STM32F1 Tech

I2C Peripheral in STM32F103

Overview In this blog we will be discussing another special functionality of GPIO pins I2C or Inter-Integrated Circuit or I2c functionality . I2C is a two wire interface or TWI which was developed by the Philips corporation for use in consumer products . It is a bidirectional bus that can be easily implemented in an IC process.I2C combines best features of SPI as well as UART it lets the user control multiple slaves via multiple masters which is useful when logging data to sd cards or displaying on LCD. Just like SPI the output data bits are synchronized to sampling of the clock shared by both the parties involved in the communication . The master always generates the clock.The protocol finds applications in hardware sensors or displays , reading memory ICs , communicating with microcontrollers , ADC or DACs. I2C Theory I2C consists of 2 lines SCL and SDA  1.SCL (Serial Clock ) – For synchronizing data transfer between master and slave   2, SDA (Serial Data ) – The data transmission or receiving line Multiple Master and Slave lines are connected to the SDA and SCL lines and both these lines are pulled up using resistors to Vdd (5v) Operation Modes In I2C  Master Transmitter Master Receiver Slave Transmitter  Slave Receiver  I2C Clock Speed The speed of the I2C bus should be in reference to the one provided in the datasheet The modes of I2C clock speed are as follows:- Standard-mode : 100 KHZ max Fast-mode: 400 KHz max Fast-mode Plus:1MHz High-speed mode: 3.4 MHz I2C duty cycle specifies the ratio between Tlow and Thigh of the I2C SCL line The values being: I2C_DUTYCYCLE_2=2:1 I2C_DUTYCYCLE_16_9= 16:9  The desired clock speed can be achieved using the appropriate duty cycle to prescale How data is transmitted in I2C Protocol Transactions are initiated and completed by master All the messages have an address frame and data frame Data is placed on SDA when SCL goes low and is sampled after SCL goes HIGH All transactions begin with START and are terminated by STOP A START is defined when SDA goes low from high and SCL is still HIGH A STOP is define when SDA goes HIGH from LOW while SCL is still HIGH Both START and STOP conditions are generated by the master itself Both START and STOP conditions are generated by the master itself Any information on the SDA lines should be 8 Bits long. Each byte must be followed by Acknowledge(ACK) bit. Data is transferred with the MSB first The address frame is sent out first  The 7 bit address frame is sent out with the MSB first followed by R/W indicating a read(1) or write(0) operation. The data frame begins transmission after the address frame is sent The SCL will keep on generating clock pulses at regular interval and data will be placed at SDA at regular interval by either master or slave depending it is a write operation or read operation   I2C Features in STM32F103 Parallel-bus/I2C protocol converter   Multimaster capability: the same interface can act as Master or Slave     I 2C Master features:  – Clock generation  – Start and Stop generation   I 2C Slave features:  – Programmable I2C Address detection  – Dual Addressing Capability to acknowledge 2 slave addresses  – Stop bit detection   Generation and detection of 7-bit/10-bit addressing and General Call   Supports different communication speeds:  – Standard Speed (up to 100 kHz)  – Fast Speed (up to 400 kHz)  Analog noise filter   Status flags:  – Transmitter/Receiver mode flag – End-of-Byte transmission flag   Error flags:  – Arbitration lost condition for master mode  – Acknowledgment failure after address/ data transmission  – Detection of misplaced start or stop condition  – Overrun/Underrun if clock stretching is disabled   2 Interrupt vectors:  – 1 Interrupt for successful address/ data communication  – 1 Interrupt for error condition   Optional clock stretching  1-byte buffer with DMA capability   Configurable PEC (packet error checking) generation or verification:  – PEC value can be transmitted as last byte in Tx mode  – PEC error checking for last received byte SMBus 2.0 Compatibility:  – 25 ms clock low timeout delay  – 10 ms master cumulative clock low extend time  – 25 ms slave cumulative clock low extend time  – Hardware PEC generation/verification with ACK control  – Address Resolution Protocol (ARP) supported   PMBus Compatibility I2C Instances in STM32F103 The I2C instances vary from microcontroller to microcontroller i.e the stm32f103c676A has one I2c instance with stm32 f411 RE having I2C1 and I2C2 . The pins for I2C1 are  PB7 – This is used as SDA  PB6 – This is used as SCL The pins for I2C2 are:- PB3 – This is used as SDA PB10 – This is used as SCL I2C configuration Parameters in STM32F103 Clock Speed This parameter defines the clock speed which as mentioned previously can be 100000 in standard mode and 400000 fast mode. Duty cycle This parameter helps in configuring the HIGH and LOW ratio of the clock and has value 2:1 and 16:9 Ownaddress This parameter takes in the address of the first device which can be 7 bit or 10 bit long Addressing mode This parameter suggests the type of the address size being chosen which can be 7 bit or 10 bit Dualaddressing mode This parameter is used to disable or enable the dual addressing mode of I2C Generalcall addressing mode This parameter is used to disable or enable the general call addressing mode. NOstrech mode This parameters checks the nostrech mode Applications of I2C It is used to scan sensors such as – MPU6050 , BMP280 , PCA 9685 PWM controller, TSL2561 luminosity measurements ADXL345 3 axis accelerometer Ssoled display , 16 x 2 led display CAT24C512  EEPROM 64KB SSD1306 OLED Screen with STM32F103 GEsture sensor with STM32F103 Time of Flight Sensor with STM32F103 INA219 DC Current Sensor with STM32F103 How to configure the I2C peripheral in STM32F103 We would be using STM32 HAL and STM32CubeIDE for using the I2C peripheral in STM32F103 in this blog tutorial series. I2C BLOCK DIAGRAM I2C

Stay Updated With Us

Error: Contact form not found.