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

How to start with Microcontrollers?

Table of Contents

What is Microcontroller?

Microcontroller is a kind of an integrated circuit, which is used in the development of every electronic device around us. From avionics industry for the development of spacecrafts, missiles, rockets, satellites, to the car industry for the development of automotive cars, luxury cars, Electric vehicles, sports bikes not only this but even in medical industry for development of medical equipment’s like ECG’s, vaccine’s, optical equipment’s and even in music and entertainment industry for the development of speakers, mikes, audio amplifiers, stage lights to shooting camera. Also, microcontrollers you find around in our day-to-day life (white goods) in devices like Refrigerators, Ovens, Electric tandoor, grinders, hair dryers, Fans, AC’s etc. Even in consumer electronics televisions, mobile phones, tabs, smart watches, projectors, printers these are also developed with the help of microcontrollers.

Not only this but even in heavy machines like cranes, JSB, construction vehicles, metros, railways there is need of microcontrollers for their development.

So, you see, if you literally take any electronic/electrical gadget device around you there would be a microcontroller in it in one way or another, from food technology to medical technology to smart homes to smart cities to aircrafts, ships, boats, yachts to electronic meters and list will never end.

Thus, the need of microcontrollers and its knowledge is growing from day by day, as for the development of any embedded device of any kind of industry, there would be a need for microcontrollers.

How do microcontrollers accomplish that?

Microcontroller is an innovative technology that has revolutionize the world and made the electronic items so much feasible for us. Though microcontrollers have been in world since 1960’s. But there are many new inventions and development still going on this field. Well microcontroller is just like a human being.

Just like human beings can do any kind of work same way microcontrollers can be used in any kind of industry to make any kind of gadget.

Analogy of Microcontrollers!

Just like human beings have brain where processing of all data is done microcontrollers have CPU. In the CPU(Central Processing unit), all the processing of data, speed of execution is done. Thus CPU’s are the brain of the microcontrollers.  Often the word CPU is used interchangeably with processor/core.

Just like human beings use some form of language to communicate with outside world like English, Spanish, Hindi and etc. Same way microcontrollers use different communication protocols (UART, I2C, SPI, CAN, LIN, cryptography, I2S, CSI  1-wire, and many other) and digital/analog signals(GPIO, PWM, ADC, DAC, TIMERS) to communicate with the outside world. 

Just like human beings have different body parts to interact with outside world, microcontrollers have different peripherals which are used to interact with outside world. For each Communication Protocol and digital/analog signals that are stated above there is some corresponding peripheral in microcontrollers.

Just like in human being’s brain sends signals to body parts, same way in microcontroller for using peripherals some configurations and programming has to be done to use them, this is called peripheral coding/drivers. That would be explaining in below sections.

Now some sensors and modules are connected to Microcontrollers as an intermediate between the outside world and microcontrollers. And these sensors and modules communicate with specified communication protocols.

  • Just like we human beings have memories of our life, past and things to do, according to which we act and do our daily work. Exactly same way microcontrollers too have memories, difference is just this memory is programmable. According to the program written on these microcontrollers they work. So, it’s like programming the human beings (with Smily emoji). That would be explaining in below sections.

Connecting the analogy of microcontrollers!

Microcontrollers are connected to different sensors and modules according to the industry in which they are being used. Microcontrollers communicate with these sensors and modules by some communication protocol via the peripherals of the MCU. Sensor and modules act as an intermediate between the microcontrollers and world, to get information from the outside world that is input to the microcontrollers(input). Then this data is processed and analyzed by the CPU (brain of MCU), where all these calculations, processing, operations are done. And then information is sent from the microcontrollers(output) to corresponding sensors and modules to show results or control the outside world. And That’s how microcontrollers can be used to make any electronic gadget of any Industry.

Practical usecases of microcontrollers

Having the understanding of communication protocols and peripherals of the microcontrollers one can make electronic gadgets for number of industries.

Decoding the data from the sensors and modules, and then correspondingly what actions has to be taken, according to inputs. This is controlled by the program Witten on these microcontrollers. That is called as Embedded Software/Firmware development. This program is controls the flow of execution, that what to do, when to do and how to do.
There are many software components in this flow, Device drivers for connecting sensors and modules, bootloader to start the MCU, Peripheral drivers for peripherals of MCU, Hardware Abstraction Layer for code portability, RTOSes for real time computing, Stacks for IoT protocols and etc. For programming the microcontrollers there is need of environment called Software Development Kit (SDK). Microcontroller are programmed using C/CPP language. More on Software development Kit would be told below.
Peripherals are made up off an electronic circuit using resistors, capacitors, op-amps, transistors, digital-analog electronics and miniaturized so small using the VLSI-VHDL technology that these circuits are made to fit inside the tiny chips called microcontrollers
For using the microcontrollers there is need of hardware resources called Hardware Development Kit (HDK). More on Hardware Development kit is told in next blog.
HDK

Microcontroller Vendors/Semiconductor Companies​

Microcontrollers are designed and developed by the Semiconductor Companies. These Companies designs the microcontrollers for different industries (listed above), where these microcontrollers are used for product development.

Semiconductor industry is multi-billion-dollar industry, companies are as big as google, amazon & Microsoft (some are even larger than that). 

Name of Semiconductor companies:

Semiconductor companies not only designs and develop the microcontrollers but instead many other electronic/integrated chips (ASICS, memory chips, sensor chips, IoT chips, discreate electronics, development boards and etc.)Apart from just electronic chips, these companies develop the Software packages, Software Tools, Software Applications (ML, AI based), Hardware tools and also do Core RnD on the next upcoming technologies in the fields like of Automotive, IoT, Avionics, Industrial Automation and list will never end.

Designing of microcontrollers is done via VLSI/VHDL technology and then programming on those microcontrollers to build the applications is done via Embedded Software/Firmware Develpment.

To give a practical use case, you guys must have heard of Arduino. Well Arduino is a development, in which there is microcontroller Atmega 328. This microcontroller is designed and developed by Microchop technologies semiconductor company. Another is NodeMCU, which is also a development board, which has ESP8266 IoT MCU which is designed and developed by Espriff Systems. Most of the hobbyist and students are aware of only these 2 controllers, but there are number of other microcontrollers which are designed and developed. Like STM32 Blue Pill, is a development board which has STM32F103 MCU is ARM Core Based Microcontroller developed and designed by STMicroelectronics. Another is Teensy development boards which has I.MX1062 microcontrollers designed and developed by NXP semiconductors.

At the gettobyte, you are going to find content and tutorial series on different microcontrollers of different vendors. explaining how to use those Industrial microcontroller and tutorials on how to use the peripherals of Industrial microcontrollers to come out of Arduino environment. And get industry ready skills and knowledge in microcontroller field’s

Categories in Microcontrollers​

Categories in MCU’s

Now like there are categorization in human beings in terms of color, features, gender kind of same way there are categorization in microcontroller in terms of:

  • Which CPU architecture and CPU core is used (RISC-V, ARM, CISC, Power architecture, 8-bit architectures), every CPU architecture has some features and specs. Every human has unique brain and only 1 bran, but different microcontrollers can have same CPU core.
  • Bit size of microcontroller (8/16/32 bit Microcontrollers), it’s kind of like amount of data that microcontroller can process. 32 bit can process more data and 8 bit would process less data.
  • Then depending on peripherals support microcontroller has, more peripheral support it has a greater number of applications can be built from it by connecting different sensors/modules to it.
  • Microcontroller’s has memory , as in the end we have to write some program to control the microcontroller, that program is written inside the microcontroller memory. So, amount of memory microcontrollers has (Flash Memory, RAM, SRAM and etc.), depending on that too there is categorizations in microcontroller.
  • Support of Software Development Kit and Hardware Development kit for the corresponding microcontroller.

Chronology to start with microcontrollers

Chronology to start with Microcontrollers

Okay, so lot has been talked about Microcontrollers. Now how to get started with it and in what chronology. Well Microcontroller technology is very vast and has many exciting/interesting topics. Best way to start learning about microcontrollers is by doing Embedded Software/Firmware Development.

From the Embedded Software/Firmware developer, below defined is the best way to start with the microcontrollers:

  • First is take any MCU of any specific vendor (let’s say NXP Semiconductors S32K144 MCU) and then get its development board and debugger/programmer of that MCU. You can get development board and hardware debugger of many different MCU’s from gettobyte website. 

For NXP S32K144 MCU, buy this breadboard compatible eval board, it can be programmed via externa JTAG debugger. Get to know about Pinout and pins description of the MCU.

  • And then setup is its SDK. So understand what Software Development Kit is, why is it needed. Software Development Kit comprises of IDE, code configuration tools, peripheral drivers and software debugging tools.

For NXP S32K144 MCU, Install the S32 Design Studio IDE, Freemaster debugging tool and software package of S32K1 for peripheral drivers(Real Time Drivers). Viewers can refer to S32 DS IDE getting starting blog, for getting to know

  • After that understand the microcontroller architecture, the processor architecture of the MCU. Different kind of interrupts and faults in the MCU. 

Reading the S32K144 Reference manual and Datasheet. First 2-3 chapters of both the docs and try to understand terminologies, keywords which are written, features and specs of S32K144.Then S32K144 MCU has ARM Cortex M4 architecture, so understanding, about ARM architecture and various components in it from its technical reference manual.  Refer to this blog for S32K144 MCU understanding

  • After that, understanding the basic peripherals and communication protocols of the MCU so that one can get to know how application build around MCU.  Theoretical understanding of the communication protocol, digital/analog signals and then relating how is that theory being implemented in MCU by understating the peripheral drivers of that MCU. Every MCU vendor provide the peripheral driver for the corresponding MCU by the name of different names: Real Time drivers, Device drivers and etc.

NXP S32K144 MCU has number of peripheral. NXP does provide peripheral drivers for the peripheral of the S32K144 MCU by the name of Real Time Drivers. I have written well formatted blogs on all the peripherals of s32K144 MCU by explaining the demo example of  peripheral drivers, features of corresponding peripheral in MCU. Refer from here. At gettobyte you can find peripheral driver tutorial on number of Industrial controllers.

  • Now connect different sensors & modules to corresponding peripheral and make the sensor/module run via microcontroller. In this we need to understand at first the working principal of that sensor/module and then understand from its datasheet about how to control that sensor/module via microcontroller so as to run it and then writing its device driver. Device driver is a program written to interface difference sensor/module with microcontroller.

Connect different type of sensor and modules to MCU. At gettobyte their are proper tutorial series on how to connect sensor/module with any MCU. Have connected number of different sensor/module to NXP S32K144 MCU.  Refer to sensor and module section to start.

Different Components in the microcontroller

List of blogs to read to start with the journey

Next Blog To Read

Hardware Development Kit(HDK)
Software Development Kit(SDK)

More Blogs to read to get started with MCU's

S32K144 Peripherals
Kunal Gupta

SPI Peripheral in S32K144 MCU

So hello guys, welcome back to NXP Semiconductors S32K144 MCU Tutorial series. In the last 2 blogs we had started with S32K144 MCU GPIO Peripheral & UART Peripheral . Table of Contents In this blog we are going to explore the SPI Peripheral. Going to Start with SPI peripheral. Objective would be to get. familiarity with SPI peripheral for S32K144 MCU. Would be understanding SPI peripheral from Hardware point of view in S32K144 MCU. Going to understand then how to use SPI peripheral via S32K SDK/lpspi driver. Would also be demonstrating the spi_echo_pall sketch. So read along the blog and do tell me its reviews SPI Peripheral Theory Serial Peripjeral interface is a synchronous serial communication interface used in embedded systems, typically to perform short distance communications between microcontrollers and device. Typical applications include interfacing to LCD displays, memory cards, Secure Digital cards and etc.   SPI Peripheral in S32K144 MCU In S32K144 MCU, SPI protocol can be used via 2 peripherals: LPSPI & FlexIO. LPSPI is referred as Low Power Serial Peripheral Interface. LPSPI is on chip peripheral only to do SPI communication protocol. SPI is a serial protocol which is done via SPI supported peripherals in the Microcontrollers. Also, in S32K144 there is FlexIO peripheral through which on-board serial communication protocols like UART, I2C & SPI can be emulated. So through FlexIO peripheral, also SPI peripheral can be implemented. To know about FlexIO peripheral in S32K144, refer to this blog. Features of SPI via LPSPI peripheral in S32K144 MCU: LPSPI module supports efficient interface to an SPI bus, as a master and slave. LPSPI is designed to use little CPU overhead, with DMA support. LPSPI can generate a DMA request. SPI devices communicate in full duplex mode using a master-slave scheme, with a single master at a time.  Single master can control multiple slave devices using individual slave select (SS) lines. If MCU is configured as Master, then it will generate the frame for reading and wiriting and SPI clock which is synchronous. Supports daisychain for controlling multiple slave sharing the same chip select. Configurable clock polarity and clock phase Master operation supporting upto 4 peripheral chip selects at a time Transmit and receive FIFO of 4 words for both master and slave device. Flexible timing parameters in master mode, including SCK frequency and delays between PCS and SCK edges. Support for Full duplex transfers, supporting 1 bit transfers and receive on each clock edge. Support for full-duplex transfers, supporting 1-bit/2-bit/4-bit transfers and receive on each clock edge. How to get started with I2C peripheral in S32K144 MCU SPI Hardware Pinout in S32K144 MCU LPSPI Pinout and Hardware Instances LPSPI peripheral in S32K144 has 3 instances: LPSPI0, LPSPI1, LPSPI2. In S32K MCU, LPSPI peripheral can be used in serial and parallel data transfers. For this blog we are going to focus on serial data transfers. to know about parallel data transfers, refer to this blog. All the LPSPI instances has following pins, for using them. SCK (Serial clock): This pin is used to generate the clock pulses in SPI communication by the Master. SOUT (Serial data out): This pin is MOSI pin. SIN (Serial Data Input): This pin is MISO pin. PCS [0] (Peripheral Chip Select 0): This pin is used to select the slave in SPI communication. Master device will generate a Low Signal on this Pin to select the Slave. And generate High signal to deselect the Slave. PCS [1]: Peripheral Chip select 1. PCS [2]: Peripheral Chip Select 2. PCS [3]:Peripheral Chip Select 3   Each LPSPI instance in S32K144 supports all the above-mentioned pins, with below mentioned pin details. Refer to this blog to know about pins signal description in S32K144 MCU   LPSPI0 LPSPI1 LPSPI2 LPSPI0 In LPSPI0 there are following number of pins: For PCS0 there are 2 pins For PCS1 there is 1 pin. For PCS2 there is 1 pin. For PCS3 there is 1 pin. For SCK there are 3 pins For SIN there are 3 pins. For SOUT there are 3 pins LPSPI0 pins in S32K144 3 pins. LPSPI1 In LPSPI1 there are following number of pins: For PCS0 there are 2 pins For PCS1 there is 1 pin. For PCS2 there is 1 pin. For PCS3 there is 1 pin. For SCK there are 2 pins For SIN there are 2 pins. For SOUT there are 3 pins. LPSPI1 pins in S32K144 LPSPI2 In LPSPI2 there are following number of pins: For PCS0 there are 3 pins For PCS1 there is 1 pin. For PCS2 there is 1 pin. For PCS3 there is 1 pin. For SCK there are 2 pins For SIN there are 2 pins. For SOUT there are 2 pins. LPSPI2 pins in S32K144 MCU How to do LPSPI Pin Configuration In a MCU a single pin can work as multiple function, so we have to configure that which function we need, accordingly pins have to be configured. This configuration of Alternate functions of pins in S32K144 MCU is done by Signal Multiplexing peripheral. One can configure which pin to use for LPI2C, via Signal Multiplexing peripheral, in which there is a register Pin Control Register (PCR) which has Pin Mux Control bits(MUX) for configuring the alternate functions of the pins. For example, we are using LPISPI0. Now in LPISPI0 for using LPSPI0_PCS0, LPSPI0_SCK, LPSPI0_SOUT, LPSPI0_SIN pins one can configure PTB0, PTB2, PTB4, PTE1  pins: You can see SSS column in the excel in that for PTB0 under LPSPI0_PCS has value of 0000_0011. Last 3 bits of this value represents the MUX values to be configured for configuring PTB0 pin as LPSPI0_PCS pin, in PORT_PCRn register. You can see SSS column in the excel in that for PTB2 under LPSPI0_SCK has value of 0000_0011. Last 3 bits of this value represents the MUX values to be configured for configuring PTB2 pin as LPSPI0_SCK pin, in PORT_PCRn register. You can see SSS column in the excel in that for PTB4 under LPSPI0_SOUT has value of 0000_0011. Last 3 bits of this value represents the MUX values to

Read More »

Introduction on embedded c

Embedded C is an extremely popular programming language when we talk about electronic devices. If you wanna go for robotics it would be a good start for you. In our day-to-day life, we use mobile, laptops, and fridges every electronic device we use is made up of using embedded C. Now without wasting any time let\’s dive a bit deep into it by looking into a very basic example Blinking LED using Embedded C. Blinking Led is a hello world for embedded C which means this is the first basic code that takes us into the world of embedded C. #define F_CPU 16000000UL#include <avr/io.h>#include <util/delay.h>int main(void){DDRB|= (0B00100000);while (1){PORTB=0B00100000;_delay_ms(1000);PORTB=0B11011111;_delay_ms(1000);}return(0);} Let’s understand our code from top to bottom. #define F_CPU 16000000UL Let’s break it into 3 parts #define F_CPU Here we are defining the clock speed of the processor. 16000000 Here we are setting the clock speed at 16Mhz as our atmega328p’s default value is 1Mhz hence 16Mhz will make it 16 times slower. UL Here we are doing nothing but declaring the data type of the clock speed. We used unsigned long because clock speed cant is negative. #include <avr/io.h> Whenever we want to use libraries of some function from some other source or even we wanna use our own code we use #include.  #include <avr/io.h>  includes a header file that contains code for using pins, ports, etc. for the Avr microcontroller. #include <util/delay.h> This library is used to put delays in our code. int main(void) The main function is when the AVR starts executing code. While(1) While loops execute the code inside it until the condition inside the parentheses remains true. We all know in C 1 refers to true and 0 refers to false. Here the code inside the while loop will run again and again because 1 can never be false. return(0); If we don\’t write return(0) at the end of the code we will get an error for sure. This happens because our operating system needs confirmation that the code we ran is running properly. This is more of a line of confirmation. You must be wondering what these words DDRB or PORTB are? Well, these are called hardware registers which are extremely important to understand so let\’s get to know what they are and what they do? Hardware Registers In our Atmega series of Avr, we have mainly 3 hardware registers. DDRx PORTx PINx Here x is referred to the bank. We have three of’em B, C, D.Every bank contains 8 pins. Depending on which bank’s pin you are using we chose the bank. DDRx[Data-Direction registers] DDRx configures the pins as output or input. As we are using an 8-bit microcontroller. The default value of the DDR is 0 which means whenever we give power it is not giving any output. If we want to set it for the output we need to set the bit we want to use for sending the output as 1. Output = 1Input    = 0DDRB = 0b00000000       DDRB = 0b00100000 Here 0b is telling us that we are writing the number in binary. We all know 0 refers to the ‘off’ and 1 refers to the ‘on’. Hence the above example is telling us at first all pins were off later on we set pin 5 as 1 for giving output. If you are familiar with Arduino Ide then you can relate DDR with pinMode.      PORTx[Port x data registers] After setting the DDRx bits to the 1(output), The port registers the voltage as HIGH or LOW. When we say the voltage is Low it means the voltage is 0V and if we say voltage is HIGH we consider the voltage as 5V.  HIGH = 1LOW    = 0PORTB = 0b00000000  PORTB = 0b00100000 If we take the example of our code we have seen above we are setting pb5 as output. In the picture you can see above PB5 is connected with pin 13 of Arduino. Now you can see we are turning we Led on which is connected with pin 13 which is connected with PB5 on Atmega 328p. If you are familiar with Arduino Ide then you can relate PORTx with digitalWrite. PINx[port c input data pin address] The pin register addresses are used when we want to read the digital voltage values for each pin we set as input in DDRX. You can relate this pin with digitalRead from Arduino IDE. I believe now it\’s clear what we did in the  above example. In the next blog, we will see how we can write a function and use it for calling. So that we can reduce our writing. Author: Kunal Gupta

Read More »

MFRC522 RFID module interfacing with Host MCU

Table of Contents Many of you may be familiar with the RFID module MFRC522, but I’m willing to bet that most of you have only interfaced this module with an Arduino and the Arduino IDE environment. However, if you need to use the RFID module with other MCUs, you may find yourself at a loss for how to proceed. If this is the case, you’ve come to the right place. In this blog, I will show you how to create a device driver for the RFID Module MFRC522, allowing you to interface it with any Host MCU. If you’re not sure what we mean by interfacing with a Host MCU or why it’s necessary, be sure to check out our blog for more information. Continuing with the MFRC522 RFID reader interfacing to host MCU, Objective would be to interface this module with Host MCU’s like of NXP Semiconductors, STMicroelectronics or other vendors MCU’s. Will make the driver to interface the RFID Reader with any MCU, not unlike just with Arduino and Arduino IDE environment. You just need to change 2-3 low level API’s for running it on different MCU’s, would be telling about it in below sections. In this blog we are going to write the driver in c++ language. Before proceeding further would recommend viewers go through, the following set of blogs and videos to have a better understanding. Prerequite, better to have:  Viewers can refer to this blog to know about RFID technology in detail. or can watch this video which is in animated format to know about RFID technology. RFID Reader MFRC522: Overview and Datasheet Explanation( Highly recommended to go through at first) MIFRAME RFID Tags: Overview and Datasheet Explanation About Serial Communication Protocols To know about What are Microcontrollers and introduction on them Hardware Connection of MFRC522 Reader module MFRC522 Module has 8 pins exposed out, which can be categorised into 3 parts: Communication pins, Power Supply Pins and Additional Pins. As explained below Communication Pins Power Supply Pins Additional Pins Logic Analyzer Communication Pins 4 pins are communication pins, that would be connected to Host MCU either using SPI, I2C, or UART. MFRC522 Communication Pins We would be making the connection using the SPI peripheral. Here I am referencing out hardware connection with 2 microcontrollers: NXP Semiconductors S32K144 MCU and STMicroelectronics STM32F103 MCU. STMicroelectronics STM32F103 would be using SPI-1 Instance and S32K144 would be using LPSPI-0 Instance.  Power Supply Pins 2 pins are for Power Supply Connection, which would be used for powering the RFID reader. One can power the MFRC522 Reader via Host MCU. Connect the VCC and GND pins with the Host MCU Power pins. Make sure, you supply MFRC522 with 3.3 V, don’t power it with 5V. MFRC522 Power supply connections Additional Pins There are 2 additional pins on MFRC522: IRQ and RST pins. IRQ pin is an interrupt pin, that is used for alerting the HOST MCU  when an RFID tag is in the vicinity. Read about the IRQ pin and interrupts in MFRC522 from here. RST pin would be not used for this project. Logic Analyzer These connections are for debugging and understanding purposes. By connecting the logic analyzers, we would be able to see how literally SPI communication and what commands we are sending, and what responses we are getting in bit and byte levels. Would recommend doing this step, as it makes the understanding clear at the root level. It would hardly take a couple of minutes to setup this. For connecting the logic analyzer, connect the Channel1,3,5,7 of the logic analyzer with communication pins. I am using the Salae logic analyzer, which is readily available. viewers can refer to this video on Gettobyte Youtube channel on how to set up logic analyzer connections, hardware, and software. Logic Analyzer MFRC522 Functional Description API’s MFRC522 has a set of functional descriptions, on which the whole of the working of MFRC522 depends. To write the driver of MFRC522, it’s important to have an understanding of those functional blocks. Reading from the datasheet could be tiering, hence viewers can read and understand from here. MFRC522 Host Interfaces MFRC522 FIFO MFRC522 CRC MFRC522 Interrupts MFRC522 Time Unit MFRC522 Command Set MFRC522 Host Interfaces MFRC522 Host Interface API’s We are going to connect MFRC522 via the SPI interface to the host MCU. SPI configurations: MSB is sent first 8 Bits per transfer The clock is Low when inactive(CPOL=0) Data is valid on Clock Leading Edge(CPHA=0) Enable line is Active LOW SPI Address Byte These address bytes are of 6 bits. When sending the address byte, MSB should tell whether we have to perform a read/write operation on that address. LSB is always set to logic 0 when sending the address byte. Thus you would find in the below driver that MFRC522 registers which are defined in GB_MFRC522.h have been left shifted 1 bit so that the MSB bit can be configured whether to perform a Read or write operation on that register address. SPI Read Data To read the data, Host MCU will send the register address at the MOSI line with LSB as 1 and then in MISO, it would get the data. This would be performed via a low-level function, that is reading one single byte from the address GB_reg which is sent in its argument. uint8_t GB_MFRC522_ReadRegister(PCD_Register GB_reg); For e,g we have to read the version of the MFRC522, which can be done via VersionReg(ox37): uint8_t v = GB_MFRC522_ReadRegister(VersionReg); So it would be left shifted first: 0x37<<1 = 0x6E(So that can configure MSB for read and Write operation). And then as we want to perform a read operation at this register, so need to write MSB with 1. We will Or above value with 0x80( See definition of uint8_t GB_MFRC522_ReadRegister(PCD_Register GB_reg): 0x6E | 0x80 = 0xEE. As per the datasheet, reading this register would give either 0x92 or 0x91.(Refer the datasheet for in-depth-description of this register). In logic analyzer reading from the  MFRC522 would look like this: MFRC522 version

Read More »

STM32_IoT_Metering_Eval_Board

Hola Amigos!! Welcome you all to Gettobyte platform. I am firmware developer and when I am learning firmware development by interfacing number of sensors and modules that has to be connected with MCU. It becomes headache when it comes to making connections of all sensors, using jumper wires on breadboard to interface all modules which are required. Thus, development this board which has almost all peripherals of STM32 MCU connected to one or other sensor to make different kind of Firmware’s (via interrupts, DMA or pooling, RTOSes frameworks, Bare-metal or HAL Based and etc.). In short, this board is best for people who wants to learn firmware development and understand all peripherals of the MCU. What is GB_STM32_EVAL_BOARDV_1? GB_STM32_EVAL_BOARDV_1 is a Custom Eval Board which is designed based on the SMART Energy Metering application, which has several on-board sensors and modules concentric to metering applications. GB_STM32_EVAL_BOARDV_1 is also a Custom Eval Board based on STM32F103 MCU, which is designed to get hands on all the basic peripherals of STM32 MCU and learn different frameworks of Firmware Development like RTOS, STM32HAL and Bare Metal Codes. Features of GB_STM32_EVAL_BOARDV_1? The board is based on SMART Energy Metering application, which has a number of on-board sensors and modules concentric to metering applications. The board has following onboard external components directly connected to STM32MCU via its peripherals. AC energy metering IC: HLW8012(Timer Input Capture peripheral): AC energy metering IC with 2.5kV galvanic isolation of signal and power fascinated by onboard isolated switch mode DC-DC converter and optocouplers for isolation of signal Temperature sensor module: DHT11(Timer peripheral) DC energy metering IC: INA219(I2C peripheral) OLED graphical Screen: SSD1306(I2C peripheral) Wifi Transceiver module: ESP8266(UART peripheral) Industrial Communication Protocol Transceiver: RS485( UART peripheral) RF transceiver module: NRF24L01(SPI peripheral) External Flash Memory IC: W25Q32(SPI peripheral) In addition to the above peripherals the board  has LEDS & Pushbuttons, to play with GPIO peripheral.  10k Ohm potentiometer to get hands on ADC peripheral of STM32 MCU’s. The board has breakout pins headed out of all the pins of MCU, for connecting another sensor. This board has 0 ohm resistors which act as jumpers. These can be useful while debugging the PCB and also to utilize the pins of the MCU that have been occupied by onboard peripherals. The board also has Female-header pins exposed out with each Onboard sensor/module, for connecting the Logic Analyzer to test and debug the working of sensor. Module connected to those pins. The board can measure AC Ratings upto, The board can measure DC Ratings upto It has an on-board data logging feature for 128MB of data, that is approximately 60 days of readings. Debugger The board can be programmed and debugged via STLINKV2 debugger externally. The board has SWD and SWO debugger pins both headed out via on board Header pins, P1 which can be connected to external debugger STLINKV2, as shown below.  Power Supply The board has number of On-board power supply options. It can be powered by DC adaptor of 6V-40V DC. It can be powered directly via STLINKV2 also. It can be programmed via UART-FTDO connector too How to get started with the Board? To get started with the board is quite simple, simply connect the STLINKV2 debugger via its Debugger pins. You can now open the STM32CubeIDE and simply create a new project by selecting MCU as STM32F103C8.   That’s all, just configure the project according to your wish. Now you can program the board according to your wish using different frameworks of Firmware as follows: Using Bare Metal Coding, by making device drivers of the peripherals  in register level and then using that for Application development. This way is recommended for beginners who want to learn Embedded Firmware Development from scratch. Using STM32 HAL, by configuring the firmware of the board via STM32CubeMX. And directly focusing on the Smart Metering Application project development. This way, is recommended for those who wants to do R&D and prototyping for Smart Metering Application, by building different kind of Applications on the board Using RTOS, for building of complex applications. The board houses a number of Input/Output sensors and modules. So it is idle to learn RTOSes like FreeRTOS,Mbed RTOS and etc.  You can program it via STM32CubeMX, configure the project according Use Cases of Board Custom Evaluation board on STM32 MCU For accelerating prototyping and development time.Board has on board Metering sensors, Display Screen, Wi-Fi module, RF module, external flash memory, Temperature Sensor, ADC module and RS485 port. So that Development team and engineers can test their Firmware’s directly on EVAL boards for different scenarios and cases, without going on to hustle to mimic the hardware on breadboard and Jumper Wires during POC. Board can also be used as DIY KIT, by hobbyists, students and makers to learn STM32 MCU.Eval board has different sensors and modules interfaced to STM32 MCU touching all peripherals of the MCU. Don’t need to involve in the hustle of interfacing every sensor and module via jumper wires and breadboard. Use of jumper wires and breadboard, makes the circuit too messy and ugly to work on. Thus developed this EVAL board which has quite famous sensors and modules interfaced to STM32 MCU on PCB, to make the different application firmware on different No RTOS or RTOS frameworks. Board is concentric to Metering Industry. In Depth Overview AC Energy metering IC HLW8012: Connected to MCU via TIMER INPUT CAPTURE. HLW8012 has 3 pins: SEL, CF1 and CF. Which are connected as shown below. It has to be powered externally via 5V DC supply. Also, it is isolated from power supply of the board, as this part of circuit will be having high Electrical voltage. Also, there are test point P16, for debugging and testing the signals of HLW8012 via logic Analyzer or Oscilloscope. CF1: PB5(T2C2) CF: PB6(T4C1) SEL: PB7(GPIO) DC Energy metering IC INA219: Connected to MCU via I2C1 of MCU. SCL: PB8 SDA: PB9 W25Q128JV SPI flash memory: Connected to MCU via SPI1. CS:PA4 MISO(DO):PA6 MOSI(DI):PA7 SCK: PA5 NRF24L01 RF Transceiver

Read More »
Kunal Gupta
Author: Kunal Gupta

Author

Kunal Gupta

Leave a comment

Stay Updated With Us

Error: Contact form not found.

      Blog