Memory Modules Sensors and Modules SPI Modules

W25Q128JV SPI Flash Memory: Part2

Table of Contents So guys this is the continued blog on my interfacing W25Q128JV SPI flash memory with STM32 and AVR MCU. So in the last blog we have started with W25Q128 overview, its features and pin descriptions. Now in this blog we are going to talk about following topic: SPI standard instructions. Status and Configuration Registers of W25Q128JV SPI Serial Flash memory. Write protection features. About its block diagram of memory mapping & management.  and then going to understand Status and Configuration Registers. Then in next blog we are going to start with its driver implementation on STM32 and AVR MCU. SPI Standard Instructions So as I have mentioned that module which we are going to use has standard SPI pins only on the breakout module( one can buy this module from robu). Remember the pinout of W25Q128 from last blog??? If not kindly refer to that W25Q128JV SPI Flash Memory: Part1 once before going further in this topic. W25Q128JV IO2 and IO1 pins are not available in the modules which we are going to use and buy. We can operate the SPI at mode 0(0,0) or mode 3(1,1),  that is SPI CPHA or CPOL bits would be either 0,0 or 1,1. W25Q128JV would be used as a slave and host MCU would be used as a master. In standard SPI we can run this IC at frequency of 133MHZ for read-write operations. But in our sample codes i would be using the IC at 1 MHZ. Most Significant bit(MSB) is sent first during the SPI communication. Chip select pin(CS) would be used for selecting the slave. When CS is set as low, the slave is selected and when CS is set as HIGH, the slave would not be selected. Serial Data Input( DI) is the MOSI pin and Serial Data Output(DO) is the MISO pin. Serial Clock Input (CLK) pin is used as Serial Clock for SPI communication. During configuring of SPI pins for our host MCU, CS pin of the host MCU would be configured as Output pin. MOSI pin of the host MCU would be configured as OUTPUT pin. SCLK pin of the host MCU would be configured as INPUT pin. MISO pin of the host MCU would be configured as INPUT pin. Dual and Quad SPI are not of our concern, so we are not going to dig deep into those in this blog. though we are going to discuss standard SPI only if anybody has any things to ask related to Dual and Quad SPI they can reach out to me via gettobyte community. Status and Configuration Registers These are very important registers, plays an important role in configuring and using these memory chips. Their are 3 Status registers, SR1,SR2,SR3. Status register provide the status on the availability of the flash memory array, whether the device is write enabled or disabled, the state of the write protection, QUAD SPI settings, Security register lock status, and Erase/Program suspend status, output driver strength, and power up status. Also, status registers are used to configure the device write protection failures, QUAD SPI settings, Security register OTP locks and output driver strength. Each Status register can be read and write by specific commands. For reading the status register we have to issue the Read status register instructions for reading the corresponding Status register. One can read the Status registers of the memory chip when we want to know the status on the availability of the flash memory array, whether the device is write enabled or disabled, the state of the write protection, QUAD SPI settings, Security register lock status, Erase/Program suspend status, output driver strength, and power up status. For writing the status register we have to issue the write status register instructions for the corresponding Status register. One can write on the status registers when we want to configure the chip for the device write protection failures, QUAD SPI settings, Security register OTP locks and output driver strength. Status Register 1 S0: BUSY bit –> BUSY is a read-only bit in the status register (S0) that is set to a 1 state when the device is executing a Page Program(02h), Quad Page Program(32h), Sector Erase(20h), Block Erase(52h), Chip Erase(60h), Write Status Register(01h,31h,11h) or Erase/Program Security Register instruction(44h/42h). During this time the device will ignore further instructions except for the Read Status Register. So in short we can use this bit inside the while loop or if loop to check whether the device is ready for further instructions or not. erase_sector4KB(read_addr1); // device is executing a erase sector instruction if((ReadSR(ReadSR1) & BUSY_BIT) == 0x01) // Busy bit is set when erase sector instruction is send, so checking that { erase_sector4KB(read_addr1); } S1:WEL –> Write enable latch is also a read-only bit that is set to 1 after executing a Write enable instruction and making the chip in write enabled mode. Prior to every Page Program(02h), Quad Page Program(32h), Sector Erase(20h), Block Erase(52h), Chip Erase(60h), Write Status Register(01h,31h,11h) or Erase/Program Security Register instruction(44h/42h) we have to send the Write enable instruction. So after sending the write enable instruction we can read this bit to check whether Write enable Instruction is executed or not.  It is cleared to 0 when the device is written disabled. Write disabled state occurs after the Page Program(02h), Quad Page Program(32h), Sector Erase(20h), Block Erase(52h), Chip Erase(60h), Write Status Register(01h,31h,11h) or Erase/Program Security Register instruction(44h/42h). So in short we can say that the WEL bit is used to check whether Write enable Instruction is executed or not. S2-S3-S4: Block Protect Bits(BP2, BP1, BP0) –> are read/write bits that can be used to protect the memory array from Program or erase instructions. One can protect ALL, NONE, or PORTION of the memory, corresponding configurations can be done for BP2, BP1, and BP0 bits according to the below tables. Also, see the TB and SEC bits for Write protection configurations S5: Top/Bottom BLOCK Protect(TB)–> This bit controls whether the memory protection has to be performed from TOP

Memory Modules Sensors and Modules SPI Modules

W25Q128JV SPI Flash Memory: Part1

Table of Contents W25Q128JV SPI Flash Memory interfacing with STM32 and AVR MCU So hello guys, welcome back to the Gettobyte once again. As I have told you that we are going to start with application codes also, so now in this blog what we are going to do?? We are going to interface the W25Q128JV SPI Serial flash memory module to our STM32 MCU and AVR8 MCU. Now let’s look at how this module looks. This module is very small and packed into small sizes. One can buy it easily from the Amazon Website. This module has 6 pins: VCC, GND, and 4 SPI Communication pins( MOSI, MISO, CE & SCK). But the IC has much more pins, that I will be briefing below. W25Q128JV SPI Flash Memory module Now starting with this Flash memory, In this blog, I will be telling you about its: General description of the IC. Features of this Serial Flash Memory. Pin Description. In the next subsequent blogs will be making the application code on AVR and STM32 MCU using SPI peripheral and peripheral driver. At first, will be making the application code on AVR MCU and then on STM32 MCU. So now moving forward, let’s begin our journey to it. General Description of W25Q SPI flash memory So starting with W25Q128JV. These are the Serial communication-based Flash memories into which we can store data. These can work as RAM memory for memory constraint embedded MCUs. We can transfer data from these memory chips in standard SPI serial communication up to a frequency of 133 MHZ and when used in Dual/Quad SPI Serial communication, data transfer frequency can go up to 236MHZ/532 MHZ. So one can read, write and fetch data from these memory chips at very high frequencies. These have 65536 programmable page lengths and in total there are 256 pages. That means it has 256 pages and on each page, we can write 65536 bytes.  W25Q SPI flash memory depicted as a book On each byte of these pages, we can read and write at a redundancy of 10000 times. Up to 256 bytes can be programmed at a time. We will go into more detail when we will understand its block diagram of memory mapping and management. Features of W25Q SPI Flash Memory It can run on Standard SPI, DUAL SPI, and QUAD SPI. Standard SPI: is traditional SPI Protocol which has CLK,CS,MISO(DO),MOSI(DI) pins.  In this, we have 1 pin(MOSI) for sending data from Master to Slave and another pin (MISO) for sending data from slave to master. It can run at Max speed of 133MHZ for standard SPI. To know more about SPI, refer to this blog  Dual SPI: In DUAL SPI, we have 2 Output/Input pins. Which means at a time we can send data from 2 pins and receive data from 2 pins. Refer the below image, DI becomes IO0 and D0 becomes IO1, so at a time we can send and receive data from both of those pins. As 1 byte has 8 bits and bits 0 and 1 of my one byte are being transmitted or received simultaneously, thus our data transfer becomes 2x then standard SPI, where only 1 bit is commuted at a time. In Dual SPI Max speed it can run at is 266 MHZ.  DUAL SPI QUAD SPI: In QUAD SPI, we have 4 Output/Input pins. Which means at a time we can send data from 4 pins and receive data from 4 pins. IO0,IO1,IO2,IO3 are the 4 pins from which data is commuted between slave and master. In Quad SPI MAX speed it can run at is 532 MHZ.  QUAD SPI One can perform 100k program-erase cycles per sector and it has data retention for more than 20 years. Efficient continuously read for about 8/16/32 byte warp. Byte warp here means that it can read memory continuously in the chunks of 8/16/32 bytes in one single time. Lets say it is reading in 8 byte wrap, so at first read it will read 0-7 bytes, then in next 8-15 bytes, then 16-23 bytes. Then the other important thing is Advance Security features which this IC has. You will be able to understand these features in better way when we will go through the Status and Configuration registers of this IC. On the memory chip, We can lock the certain memory bytes, that is no one can write or read on configured memory bytes or size. We can use the OTP (one time password) to have password based memory protection We can access the memory bytes of the IC, in Blocks(64 KB), sectors(4KB) or single byte. Starting from the Top of memory or from the Bottom of memory. PINOUT of the W25Q128 Flash memory chip So W25Q128 has 8 pins. Depending on the package we have, the number of pins of the IC can increase or decrease. The module which we will be using is packaging WSON.Pin number 1 is CE (Chip Select), used to select the SPI slave by making a LOW signal to this pinPin number 2 is DO (Data Output), that is MISO pin in case of standard SPI and IO1 in case of DUAL/QUAD SPI.Pin number 3 is /WP (Write Protection pin) ( will tell you about it in the below section) and IO2  in case of Dual/Quad SPI.Pin number 4 is GND (Ground).Pin number 5 is DI(Data Input), that is MOSI pin in case of standard SPI and IO0 in case of DUAL/QUAD SPI.Pin number 6 is CLK, the Clock pin of SPI communication.Pin number 7 is /HOLD or /RESET  pin ( will tell you about it in the below section) and IO3 in case of Dual/Quad SPI.Pin number 8 is VCC. Let’s just deep dive into the pin description of this IC Chip Select is held high, that is master has not selected the slave and all my pins would be at High impedance. When the CS pin is held low, the master has selected

Display Screens I2C Modules Sensors and Modules

SSD1306 OLED Display Screen

Display Technolgy mainly consists of two things: Display Devices and Display Driver Integrated Chips(DDIC). Display Devices: are OLED, LCD, LED, CRT, Vacuum Florescent, etc modules. To know in-depth about the different types of display devices refer to this. Display Driver Integrated Chips(DDIC): are semiconductor IC\’s that provide an interface between the control Unit(MPU and MCU) and a particular type of display device. Display driver accepts commands and data using onboard communication protocols like I2C, SPI, CMOS, RS232, etc and generates signals with suitable voltage, current, timing, and demultiplexing to make the display show the desired text or image. Display driver IC\’s may also incorporate RAM, Flash Memory, EEPROM, and/or ROM. Examples of Display Driver IC are SSD1306, HD44780, KS0108, SSD1815, and ST7920. In this blog, we are going to use the OLED Display device and will go in-depth into one of the OLED Display Driver IC\’s: SSD1306 by Solomon Systech. OLED Display Introduction OLED(Organic Light Emitting Diode) displays are the new technology in the display screen industry that are revolutionizing the user interface for users in various devices like TV screens, Virtual Reality headsets, Smart Watches, and many more. LCD Technology is compentator to OLED technology. LCD is a non-emission and older display technology that requires an external light source to work. While OLED technology is modern and considered to be emission display technology, that does not require a backlight that is an external light source. OLED Display technology is pretty exciting and opens lots of possibilities: Curved OLED Display Wearable OLED\’s Flexible and rollable OLED Transparent OLED embedded in Windows and many more we can not imagine today. The focus of this blog will be more on the understanding of OLED Display Driver IC: SSD1306 and its driver development for operating the below OLED Screen Module. To get to know about the OLED display working and its layers, readers can refer to this blog. OLED Driver IC\’s apart from SSD1306 are SSD0323. SSD1306 OLED Driver IC SSd1306 is an integrated chip that is used to drive the OLED display of the dot-matrix graphic display system. These IC\’s comes in Chip on glass or Chip on Film packaging i.e chip die is directly mounted to a piece of the glass display. SSD1306 has a feature to drive up to 128 columns & 64 rows of OLED pixels. It has constant control, display RAM and oscillator inbuilt which reduces the external components and power consumption. SSD1306 IC itself require only 1.65 to 3.3 V that can be provided to it easily from MCU. But as OLED displays does not have backlight as LCD has, so the panel of OLED requires higher voltages of about 7-15 V which is supplied to OLED panel from internal voltage doublers and charge pump circuitry\’s. And on an average OLED display consumes only 20mA current. Now coming to the part that how does these Driver IC display data on these OLED screens.

IoT Modules Sensors and Modules UART Modules

HC-05 Bluetooth Module

Table of Contents In our era, people are more likely to use wireless devices because it makes using them much easier. HC-05 is a Bluetooth module used for wireless communication. It uses Serial communication to communicate. Its work is based on UART. Usually, it is used to connect small devices like a mobile phone or laptop and exchange files over the range of less than 10m. You can also communicate  between two microcontrollers like Arduino through this. However, this module does not transfer multimedia like photos or songs. It can take up to 4-6V of power supply. It supports baud rate of 9600, 19200, 38400, 57600, etc.  Refer to these blogs if you feel stuck. Serial Communication UART HC-05 Default Settings Specifications How to connect HC-05 module HC-05 Module PIN OUT of HC-05 Connection or HC-05 & Arduino Modes of Communication Data Mode: This mode is used to communicate with other Bluetooth devices wirelessly. Command mode: AT Command mode is where we can change the default device settings. Let\’s see an example here for both of the modes, starting with Data Mode. Bluetooth communication between Devices (Data Mode) Here we will connect our module with Arduino and our phone. We will send signals from the phone to the HC-05 module wirelessly which will be displayed on the serial monitor. If we will send 1 it will turn on the LED or If we will send or it will turn off the LED.  Components required: Arduino Uno LED Jumper wires HC-05 Bluetooth An android phone Steps. Follow the steps mentioned above to connect your module. Now follow these steps to make the circuit turn on/off the LED. Connect the long leg of the led with the resistor. The resistor should be connected with any digital pin, let\’s say pin 13. Connect the short leg with the ground. 3. Now we are using the same TX, RX pin for communication. For this, First, we need to remove RX, TX wire. We did this because Arduino Uno has only 1 pair of UART pins and by them, it receives the data from the IDE. We are aware that Arduino uses the UART protocol for communication. If we connect these pins with the HC-05 module while uploading we will get an error as it will clash. Upload the code to the Arduino and reconnect the pins. int ledP=13;int dtime=1000;int readData;void setup() {  // put your setup code here, to run once: pinMode(ledP,OUTPUT); Serial.begin(9600);}void loop() {  // put your main code here, to run repeatedly:while(Serial.available()==0) {} // reading the data from the serial monitorreadData = Serial.parseInt();Serial.println(readData);if(readData==0){  digitalWrite(ledP,LOW);}if(readData==1){  digitalWrite(ledP,HIGH);} To send the signals via phone we need to install an app. I use an Arduino Bluetooth controller. Pair it, add the password which is usually 1234 or 0000. Changing the default settings of HC-05 (Command mode) AT Command mode is where we can change the default device settings. Steps to use AT commands Connect your Arduino Board to the Pc. Upload the bare minimum code to Arduino without any breadboard connection. Unplug the Arduino from the computer. Connect the HC-05 module to the Arduino as below. Press and hold the push-button on the module for 1-2 sec and while holding it connect the Arduino to the PC. Now you’ll see the red light will blink in 1-2 sec intervals which shows AT command mode is active. Now select the baud rate to 38400. We do that because 9600 is slow for high-speed transmission. It can go even higher according to the HC-05 reference. Set the box next to the baud rate from newline to both NL(newline – n) & CR(carriage return – r). Now we will use AT commands. First, type At on the Serial Monitor and send. If you will see an OK then everything is fine. To change the name of the module we use AT+NAME=HC-05Devanshi. To change the Password of the module we use AT+PSWD=\”9876\”   You can refer to this for AT commands. Applications of HC-05 module Robots  Wireless communication between two microcontrollers Communication with Mobile and Laptop

Current/Power Sensors I2C Modules Sensors and Modules

Allegro\’s AC Power monitoring IC ACS71020

In many applications, we want to monitor AC electrical parameters like Solar chargers, motor control, Battery Charging stations, or Smart energy meters. Measurement of AC current and voltage, by the means of the electronics, is a quite tricky part, unlike traditional electromechanical systems. Below is a basic block diagram to know about it. AC voltage and current signals are first steps down to low voltage and current values.One can not feed High AC electrical voltage and Current signals which can range from 0-1000 units and are even larger than that, in some applications(Power systems, AC motors and etc)  to the electronics and digital world.  So at first by the use of one of the below listed three methods AC signals are brought to low values( 0-10V, 0-5A) Use of Current Transformer,  Potential Transformer, or  Rogowski coil. Use of shunt resistors. Use of Hall effect-based principal for current measurement.  The signals which we get after processing from these methods are fed into the Digital System where there are signal conditioning circuits, data acquisition circuits, digital signal processing by the use of Digital and Analog Electronics. The Digital System part is designed to embedded into the Integrated chips(ASIC) which are specially designed with the purpose of Energy Metering application. For the digital computation of key electrical parameters like Power factor, Active power, reactive power, Vrms, Irms and etc. Using these key parameters we can monitor the AC electrical parameters through serial interfaces like SPI/I2C with Host MCU. ACS71020 Energy Metering IC Allegro microsystem\’ AC power monitor module ACS71020 is a Single-phase energy monitoring IC that works on the principle of the HALL effect sensing technique (To know about ways to measure current refer to this blog) to measure the AC current and resistor divider network to measure the input AC voltage. It calculates the key electrical parameters using its  Metrology Engine and digital system from which it sends the data to the host MCU via I2C and SPI interfaces. The Voltage and current reading that we get from AC voltage and Current measurement blocks via the sense amplifiers are analog in nature. The analog signals from respective Voltage and Current blocks are then fed into the internal ADC\’s(Analog to Digital converter). ADC samples the current and voltage channels at high frequency and then digitally converts them by filtering and decimating the output signal from sense amplifiers to avoid large anti-aliasing filters. The digital word from the ADC is 16 bits for both the current and voltage, which is fed to the digital system for further calculation of other electrical parameters. Its Key Features are: Without the need for any Transformer, Rogowski coils, oversized current transformers, or the power loss of shunt resistors one can calculate Vrms and Irms up to 517V and 90A respectively It has an advanced digital system with galvanically isolated current sensing technology which achieves reinforced isolation ratings in a small PCB footprint Apart from the calculation of Electrical Key parameters it also has many extra features too which are essential for monitoring purposes. ACS71020 IC Pinout Diagram and Pins description ACS71020 IC has 16 pins, Starting from Pin 1-8 are current channel pins, out of which pins 1-4(Fused internally) are all IP+ and pins 5-8(fused internally) are all IP-.  Pins 16-15 are Voltage measurement pins  ACS71020 IC Schematic For using ACS71020 for typical applications its schematic is pretty easy and less complicated in oppose to other metering IC\’s(STMP32 & ADE series). ACS71020 can be powered directly from the same supply as the system\’s MCU, through its reinforced isolation technology it does need multiple power supplies to power it up. So Vcc and GND pins are connected directly to MCU Vcc and GND pins. I2C  pins are at a high level(5V or 3v3), before the start of the I2C Serial Communication, thus SDA and SCL lines are connected with a pull-up resistor. When using in I2C mode, pins 9 & 10 act as DIO_1 and DIO_0( Digital Input/Output)  respectively, which are connected directly to MCU Digital Pins( Will get in detail about DIO pins in a later section) For SPI communication, MOSI, MISO, CE pin are at a high level and CLK is at GRND before the start of SPI serial Communication. When using in SPI mode, pins 9 &10 are used as MOSI and CS pins. ACS71020 IC  measures the Current and voltage of the input AC signal to calculate all other key parameters. So for inputting the AC voltage & current signals to the ACS71020 IC we will focus on Voltage channel pins(VINP & VINN) and Current channel pins(IP+ & IP-). One thing to recall is that in a single-phase AC supply there are two terminals: Live Wire (Black/Red) carries electricity from the power supply and takes it to the load. Neutral wire(Blue wire) returns the electricity from the load to the power supply to make the circuit complete. VINN &VINP are terminals from where AC voltage is measured, so resistor network divider of 1mega ohm and shunt resistor is made in b/w the VINP and VINN terminals to fit the input AC voltage within the Range of the differential voltage input buffer of ACS71020( +-275mv) as specified in electrical characteristics of the datasheet. IP+[1:4] & IP-[5-8] pins are terminals for AC current measurement. IP+ terminals are fused internally and are connected to a neutral wire of load and IP- terminals are also fused internally and are connected to a neutral wire of supply to complete the current loop of the current channel. EVE ACS71020 Module For doing the practical demonstration with ACS71020 IC we are going to use the EVE ACS71020 breakout board, which is manufactured by the Evelta. The module is cheap and can be used easily with HOST MCU via I2C or SPI communication. The module has pull-up resistors of 10k ohm placed with SDA and SCL pins( pins 12 & 11) of ACS71020  and no pull-up resistors are connected with MOSI and CS  pins(pins 10 & 9) means we can use these

Stay Updated With Us

Error: Contact form not found.