<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7400379397483727887</id><updated>2026-03-27T06:10:18.428+05:30</updated><category term="CODE"/><category term="1ms delay"/><category term="LED"/><category term="basic programming"/><category term="basic"/><category term="example"/><category term="serial"/><category term="16x2"/><category term="89C51"/><category term="AT89C51"/><category term="ATMEGA16A"/><category term="LCD"/><category term="PIC16F877A"/><category term="arduino"/><category term="beginner"/><category term="blinking"/><category term="c programming"/><category term="FTDI"/><category term="GPIO"/><category term="Microcontroller"/><category term="PWM"/><category term="ST-LINKV2-1"/><category term="STM32F746ZG"/><category term="ascii convert"/><category term="learning"/><category term="relay"/><category term="uno"/><category term="16x4"/><category term="20x2"/><category term="20x4"/><category term="256bit"/><category term="32bit"/><category term="40x2"/><category term="40x4"/><category term="5V"/><category term="ADC0808"/><category term="ARM"/><category term="ATSAM3X8E"/><category term="Arduino Due"/><category term="BC547"/><category term="CGRAM"/><category term="Colors"/><category term="EMI noise"/><category term="IEEE802.15.4"/><category term="JN5148"/><category term="LT1073"/><category term="MMA7361"/><category term="MPLABX"/><category term="NVIC"/><category term="No-IP"/><category term="Nucleo"/><category term="PIR"/><category term="Palettes"/><category term="RGB"/><category term="SAM BA"/><category term="TDM"/><category term="TIM2"/><category term="XC8"/><category term="accelerometer"/><category term="alarm"/><category term="api"/><category term="atmel studio"/><category term="automatic staircase light"/><category term="avr"/><category term="batch file"/><category term="bossac.exe"/><category term="clockgenerator"/><category term="delayms"/><category term="exhaust"/><category term="extended pointer"/><category term="float"/><category term="generic"/><category term="guidance"/><category term="hex"/><category term="hobbyist"/><category term="internet"/><category term="kitchen"/><category term="knock sensor"/><category term="library"/><category term="low power"/><category term="memcpy"/><category term="memset"/><category term="object counter"/><category term="pcb cleaning"/><category term="running display"/><category term="server"/><category term="seven segment display"/><category term="soldering"/><category term="sprintf"/><category term="studio"/><category term="tap sensor"/><category term="touch switch"/><category term="w5100"/><title type='text'>Embedded Life</title><subtitle type='html'>This blog invites you to begin your journey in embedded c programming</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>41</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-1179083418245976434</id><published>2025-03-24T23:00:00.004+05:30</published><updated>2025-03-24T23:00:44.680+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="basic"/><category scheme="http://www.blogger.com/atom/ns#" term="basic programming"/><category scheme="http://www.blogger.com/atom/ns#" term="blinking"/><category scheme="http://www.blogger.com/atom/ns#" term="c programming"/><category scheme="http://www.blogger.com/atom/ns#" term="GPIO"/><title type='text'>Raspberry Pi Pico SDK Installation Guide for Windows PC</title><content type='html'>&lt;p&gt;&amp;nbsp;This post is me writing down step by step process I followed to make a simple code compile in pico SDK.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;What do we need to learn?&lt;/b&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Understanding hardware.&lt;/li&gt;&lt;li&gt;Installation of softwares required.&lt;/li&gt;&lt;li&gt;Installation of pico sdk.&lt;/li&gt;&lt;li&gt;Understanding of important files for project compilation.&lt;/li&gt;&lt;li&gt;Creating your folder for project from above understanding.&lt;/li&gt;&lt;li&gt;Compiling your first successful code using SDK.&lt;/li&gt;&lt;li&gt;Programming the code to the development board.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;What does Raspberry Pi Pico Hardware contains?&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP9Zy3VQTAfACWPC1eVd83XIe0Y1KlH4iHs21V0SOL_rN68tV7KyXXkznP6zHvWUlv9H8FvRgm-3S1AyRiaXeviqEgZOqGvdcBIzY_4YBDPIpYj50MUUJHrqaOkj8RDXB4cz3-WHO_I_Fzc8w-l5k051nJQZcMHADW81Ih6pZYkSZR-XvlF4t3eqLKDb4/s811/hardware%20overview.jpeg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;754&quot; data-original-width=&quot;811&quot; height=&quot;373&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP9Zy3VQTAfACWPC1eVd83XIe0Y1KlH4iHs21V0SOL_rN68tV7KyXXkznP6zHvWUlv9H8FvRgm-3S1AyRiaXeviqEgZOqGvdcBIzY_4YBDPIpYj50MUUJHrqaOkj8RDXB4cz3-WHO_I_Fzc8w-l5k051nJQZcMHADW81Ih6pZYkSZR-XvlF4t3eqLKDb4/w400-h373/hardware%20overview.jpeg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. &lt;b&gt;Micro USB Interface&lt;/b&gt;: Helps you connect to the computer during programming and also behaves like a virtual com port for serial communication.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. &lt;b&gt;Reverse Protection diode:&lt;/b&gt; helps to avoid wrong polarity during connections only if you power the device via VBUS pin and GND. VSYS pin is not going through this diode.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3. &lt;b&gt;Buck Boost Converter 3.3V&lt;/b&gt;: it provides steady 3.3V output with max 800mA current. It gets used when you power the pico via USB, VBUS and VSYS. It does have maximum rating of 5.5V so you must not connect anything above that voltage. A battery input of 3.7V can be connected to this device. As per my understanding this regulator will maintain constant 3.3V for Pico usage up to 1.8V of battery input.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. &lt;b&gt;RP2040 Microcontroller&lt;/b&gt;: Its a Raspberry Pi Pico microcontroller. Where all your code will be executed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5. &lt;b&gt;Flash memory W25Q16&lt;/b&gt;: Its a 16Mbit Flash memory (16Mbit divide by 8bit = 2MBytes). This is where you code will be stored.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6. &lt;b&gt;25MHz crystal&lt;/b&gt;: Its required to run the RP2040 Microcontroller.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7. &lt;b&gt;Boot Switch&lt;/b&gt;: This switch purpose is to press when you plugin the device on USB. RP2040 goes in bootloader mode where it becomes recognized as pendrive on PC. Then you can store output file of your code.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8. &lt;b&gt;Debug LED&lt;/b&gt;: I call it as debug led as this is first thing you need to turn ON to know if your board which you recently purchased is working or no. It is available on gpio25.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Installation of software&#39;s required&lt;/h3&gt;&lt;div&gt;1. &lt;b&gt;Cmake tool&lt;/b&gt;:&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://cmake.org/download/&quot;&gt;https://cmake.org/download/&lt;/a&gt;&amp;nbsp; &amp;nbsp; - required for compilation.&lt;/div&gt;&lt;div&gt;2. &lt;b&gt;Visual studio code&lt;/b&gt;:&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://code.visualstudio.com/download&quot;&gt;https://code.visualstudio.com/download&lt;/a&gt;&amp;nbsp; &amp;nbsp;- required for code writing.&lt;/div&gt;&lt;div&gt;3. &lt;b&gt;Notepad++ &lt;/b&gt;:&amp;nbsp;&lt;a href=&quot;https://notepad-plus-plus.org/downloads/&quot;&gt;https://notepad-plus-plus.org/downloads/&lt;/a&gt;&amp;nbsp; - required because you don&#39;t want to be ancient coder. we use this for slower PC.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Installation of PICO SDK:&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Download the library to your PC.&amp;nbsp; &amp;nbsp;&lt;a href=&quot;https://github.com/raspberrypi/pico-sdk&quot;&gt;https://github.com/raspberrypi/pico-sdk&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNz2bX_Nuxp8jpQOcWmHzEANeZZKUXrvPJD7uM7EttW-Nk2ClRkiI6EVkCngCzbQkPuVhD3pFA8iw5KFiWYoa3DSYlwICVuH84eW32PUHpRsHBHGFurTmjzmgfelywiUmBD4DZCvti_wGq13xz7sKCSPfziTa744Tz3v3mpG2vigM6Hapt5JS9UjyUhec/s1244/download%20git.png&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;766&quot; data-original-width=&quot;1244&quot; height=&quot;246&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNz2bX_Nuxp8jpQOcWmHzEANeZZKUXrvPJD7uM7EttW-Nk2ClRkiI6EVkCngCzbQkPuVhD3pFA8iw5KFiWYoa3DSYlwICVuH84eW32PUHpRsHBHGFurTmjzmgfelywiUmBD4DZCvti_wGq13xz7sKCSPfziTa744Tz3v3mpG2vigM6Hapt5JS9UjyUhec/w400-h246/download%20git.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Download as show in the above picture. And unzip in your project folder. Should look something like this.&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh_4sE6MF3EbIbi6z8blvf936-uWPEfFQM-76SYjvyGEFE6yaf-EcapQj5PHylCImnDNfnXr-ZECWtaE74Qiv3E0AFwLafm0bOqJqovtJQOvmoz5BrpYbDmtoTTbjp2kOJgcCQvjqAA2IcV-TdvGGXVjJyXDmJ_0pIHXcXB9XL2rOxuH7vx-99LM55d7C4&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;594&quot; data-original-width=&quot;638&quot; height=&quot;298&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh_4sE6MF3EbIbi6z8blvf936-uWPEfFQM-76SYjvyGEFE6yaf-EcapQj5PHylCImnDNfnXr-ZECWtaE74Qiv3E0AFwLafm0bOqJqovtJQOvmoz5BrpYbDmtoTTbjp2kOJgcCQvjqAA2IcV-TdvGGXVjJyXDmJ_0pIHXcXB9XL2rOxuH7vx-99LM55d7C4=w320-h298&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;You Need to Copy the SDK Path to the environment variables. Open the environment variable by typing in search&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg1da0dS3IYgmQx2WZz2iDowcu5MkeOZf76eZUxvUAi1IB7lFQiTqFN5CoWGrMcG4cwkkn9hRPtzSNv9xfkJrLSv0WXp17Gb3XFhtpSnYphQX0Q3VcqeX9G6TgZWKfeKxG0AMUWNpf2ymuCFNT4pXMt64Hi1t9fsRPGQr5PFi6drd_kYDm-fPuKQ7S5YTI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;696&quot; data-original-width=&quot;505&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg1da0dS3IYgmQx2WZz2iDowcu5MkeOZf76eZUxvUAi1IB7lFQiTqFN5CoWGrMcG4cwkkn9hRPtzSNv9xfkJrLSv0WXp17Gb3XFhtpSnYphQX0Q3VcqeX9G6TgZWKfeKxG0AMUWNpf2ymuCFNT4pXMt64Hi1t9fsRPGQr5PFi6drd_kYDm-fPuKQ7S5YTI=w290-h400&quot; width=&quot;290&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Follow the steps as shown in image below:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjLS8eFws1pHuAwIp_x6_mtytQIUjiVPuXpGLADDb684YVSW8oLfRnwN_sjFe-sxwf8yMnxY3CMOBVOlJohn5mlwYo-aj3hPzEtUW52XgQMeM6F4HXSgD4RYDVbXVfkxx11K2JErjqd1QAut_-1QcUd3ngE54bMZnyLzZ_ksj2-BrB0qkkcvtasoSR4ygs&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;613&quot; data-original-width=&quot;1755&quot; height=&quot;140&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjLS8eFws1pHuAwIp_x6_mtytQIUjiVPuXpGLADDb684YVSW8oLfRnwN_sjFe-sxwf8yMnxY3CMOBVOlJohn5mlwYo-aj3hPzEtUW52XgQMeM6F4HXSgD4RYDVbXVfkxx11K2JErjqd1QAut_-1QcUd3ngE54bMZnyLzZ_ksj2-BrB0qkkcvtasoSR4ygs=w400-h140&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You&#39;re now ready with setup.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Understanding important files for compilation and folders.&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgCYe9-BX5kFAp1yV0ooWTHk_ZnblDSeMsT4SXANymXk2B9lqhDQtgjsxcKw_z0yqZ6C8dv02nc3SHZl1C5C8KAw5hpl0PcUUpOhcFnxDJScAo_n4GhjnpNNC-QEym6Nt7jBMekqE0_Ak15pYfSaC5ci8CFx3CYPnyG74nQu92Dj-L_v8Ai4lj14DLefdI&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;152&quot; data-original-width=&quot;667&quot; height=&quot;91&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgCYe9-BX5kFAp1yV0ooWTHk_ZnblDSeMsT4SXANymXk2B9lqhDQtgjsxcKw_z0yqZ6C8dv02nc3SHZl1C5C8KAw5hpl0PcUUpOhcFnxDJScAo_n4GhjnpNNC-QEym6Nt7jBMekqE0_Ak15pYfSaC5ci8CFx3CYPnyG74nQu92Dj-L_v8Ai4lj14DLefdI=w400-h91&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are total 4files and one folder which I found necessary to compile a project.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. &lt;b&gt;pico_sdk_import.cmake&lt;/b&gt; - this file is necessary for importing pico sdk in cmake build integration.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. &lt;b&gt;pico_extras_import_optional.cmake&lt;/b&gt; - this file imports optional libraries not done by pi, mostly third party into cmake integration.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3.&lt;b&gt; CMakeLists.txt&lt;/b&gt; - this file contains instructions to build via cmake properly using pico sdk.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. &lt;b&gt;build&lt;/b&gt; - this folder is necessary to get the output files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5. &lt;b&gt;build/uf2 file&lt;/b&gt; - the file inside of build folder after compilation is a output file that you can copy paste into pico during boot mode.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Creating your first project folder. This is how your project should look like.&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj-hh7gk9-lEneVNZ57sURhsXB_cLsO_lITp568RekwxLOV8Fm_fWM4nNIztRIyIJ4V5EGmi6zshdIKV1OzjGahOAtwd2LH4DaK0bZipSNNxv1RyZdzk9OKAIFsAN_vnXoNH5QcXaILnP89O240Zb_I1o1PbgxsplDUzAsMcYY-_Wsa4IWy_yGOGDLTRYk&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;248&quot; data-original-width=&quot;666&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj-hh7gk9-lEneVNZ57sURhsXB_cLsO_lITp568RekwxLOV8Fm_fWM4nNIztRIyIJ4V5EGmi6zshdIKV1OzjGahOAtwd2LH4DaK0bZipSNNxv1RyZdzk9OKAIFsAN_vnXoNH5QcXaILnP89O240Zb_I1o1PbgxsplDUzAsMcYY-_Wsa4IWy_yGOGDLTRYk=w640-h238&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My basic code usually has 2 files.&lt;/div&gt;&lt;div&gt;&lt;b&gt;main.h&lt;/b&gt; and &lt;b&gt;main.c&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;As you keep on coding for many years you kind of catchup on working with same code over and over again so you kind of need to create libraries where all your custom functions are. I call it &lt;b&gt;myfunctions.c&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As I&#39;m no expert in remembering the commands to compile I try to go through lot of codes online to understand what and how it works. So in windows I use something call bash programming its nothing but text you type in cmd prompt.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To build the code you need four commands:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhZvjDueF6mX3kQJVcELRYD7U2ceNuWCSO-ScuMejNbamdYxjoL6HzeGcGLQLxV5B1va367kL_n54hxF64UbquS0ECMXF_sc7_2oEfk1kmAXvx9ridBHnL6nSog3C-d1DhycbBtvzX2YV87lCrBHBV2A-ySk0cmKZ-3bJRgMvOxyLwwo_FDYxID9wbjzMQ&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;292&quot; data-original-width=&quot;970&quot; height=&quot;120&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhZvjDueF6mX3kQJVcELRYD7U2ceNuWCSO-ScuMejNbamdYxjoL6HzeGcGLQLxV5B1va367kL_n54hxF64UbquS0ECMXF_sc7_2oEfk1kmAXvx9ridBHnL6nSog3C-d1DhycbBtvzX2YV87lCrBHBV2A-ySk0cmKZ-3bJRgMvOxyLwwo_FDYxID9wbjzMQ=w400-h120&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above code doesn&#39;t delete object files that are created from previous build so if you want to fully build the files again, you need to follow the below code:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEioO4iUwoNVLq7ZZDomj0Phx_nvKEv5uyI2zv8imhA84dV45BENCXFV6aC-pQBZ_3pmsSXL9nvPBe-Am-XoU4SxSFeoLNhP-PRWmaQjszHs9_BWO3hDPxB0IwEScrukcBtWI1E7raHaxjVNmpkvcZs6lEnWfikXjnAJsWXSo9w_gdMa1wha3kRIZcPU_2g&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;323&quot; data-original-width=&quot;951&quot; height=&quot;136&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEioO4iUwoNVLq7ZZDomj0Phx_nvKEv5uyI2zv8imhA84dV45BENCXFV6aC-pQBZ_3pmsSXL9nvPBe-Am-XoU4SxSFeoLNhP-PRWmaQjszHs9_BWO3hDPxB0IwEScrukcBtWI1E7raHaxjVNmpkvcZs6lEnWfikXjnAJsWXSo9w_gdMa1wha3kRIZcPU_2g=w400-h136&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So the above files are only so that you do not need to remember the command again and again. You can just copy paste it in custom project and use it again and again as long as build folder name and CMakeList.txt file is present along with these files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What CMakeList.txt file contains?&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiqKbLZ4Qkkclur18NQCYL5plDuTJNmYq1JeIeDtcblvu2J1M4fhPTFEbUNh919JaCkCJRC-jI7J0iS1W5nHbcyMC81vr8OuAofacTEUAhJQPK65tGk9ZwQXa79aNYGJng9DC7tGaHPAn7TCRuCyPi2B5shtq6puCnwM2EMaBmSwtqp6S0QKhE4ZklUIw0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;951&quot; data-original-width=&quot;1470&quot; height=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiqKbLZ4Qkkclur18NQCYL5plDuTJNmYq1JeIeDtcblvu2J1M4fhPTFEbUNh919JaCkCJRC-jI7J0iS1W5nHbcyMC81vr8OuAofacTEUAhJQPK65tGk9ZwQXa79aNYGJng9DC7tGaHPAn7TCRuCyPi2B5shtq6puCnwM2EMaBmSwtqp6S0QKhE4ZklUIw0=w400-h259&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;For example you create a file called mygpio.c where you&#39;ve made a custom function to work with gpio&#39;s.&lt;/div&gt;&lt;div&gt;You need to add in line 29 as :&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b00fe;&quot;&gt;add_executable&lt;/span&gt;(blink main.c mygpio.c)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Please note main.h files are not to be added in this CMakeList.txt as its not required but you do need to maintain them.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I&#39;ve already created a sample project for you. So if you&#39;ve downloaded them from gitlab.com&lt;/div&gt;&lt;div&gt;link here: &lt;a href=&quot;https://gitlab.com/embeddedlifehelp/raspberry-pi-pico/sdkguide&quot; target=&quot;_blank&quot;&gt;Click here for repository download&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://gitlab.com/embeddedlifehelp/raspberry-pi-pico/sdkguide/-/tree/main/pico-template?ref_type=heads&quot; target=&quot;_blank&quot;&gt;pico-template&lt;/a&gt; is folder of interest.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets try by clicking &lt;b&gt;Compile-rebuild.bat&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgW3kh525N4cnH46phuMNL7n2Sw8mg99UPlBZVOVC-HVWam0YBnRXxB_mHpRADdX3mtn2YSv6Uv3iTGV_1uPkkAN2sMxZryBD7KK2na2IJ4HZGc2Pg3JFwBjG-uv9Hop0EJMIkJ1RiZHRIkUuGGIoHBycrKYqiYMQ54nMf1UnY1srZIzXWZaMPrGQP9Sh8&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;1036&quot; data-original-width=&quot;996&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgW3kh525N4cnH46phuMNL7n2Sw8mg99UPlBZVOVC-HVWam0YBnRXxB_mHpRADdX3mtn2YSv6Uv3iTGV_1uPkkAN2sMxZryBD7KK2na2IJ4HZGc2Pg3JFwBjG-uv9Hop0EJMIkJ1RiZHRIkUuGGIoHBycrKYqiYMQ54nMf1UnY1srZIzXWZaMPrGQP9Sh8=w385-h400&quot; width=&quot;385&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;NOTE:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;If you get an error saying path doesn&#39;t exists. &lt;b&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Delete everything inside build folder and try again.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Once the build is done. Go to the build folder and you must see the UF2 file if compilation was successful.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjuEHMYYVnwLb7WRJ69NFbVgfK36XOO7B13uIYdkzwyiJLJDGtOuC7ZanHmMdT5Xjia40fSymRrctoZr89M-pPVER2dm4yTSu9_O1lCa-XbjysUHU4bpPjuF4q-2ua9r9xlbVroRh5mEADbPj-_8SC0C3vgG4k6clToyQzmFtSCMT8y7XyRts_uo4mt2vg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;386&quot; data-original-width=&quot;675&quot; height=&quot;183&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjuEHMYYVnwLb7WRJ69NFbVgfK36XOO7B13uIYdkzwyiJLJDGtOuC7ZanHmMdT5Xjia40fSymRrctoZr89M-pPVER2dm4yTSu9_O1lCa-XbjysUHU4bpPjuF4q-2ua9r9xlbVroRh5mEADbPj-_8SC0C3vgG4k6clToyQzmFtSCMT8y7XyRts_uo4mt2vg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;If you do not see any files. Thats probably because there is an error in your code. So compilation failed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;This is why PAUSE is required in scripting so you can look into what error it was. For example there was a syntax error in my code. This was the output during build.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgdNMvUdLtDfbNbBLrepvQgOxaVtccsyQBiz7zOwTTvlz8ijuvIXJKGjHtaSbOuuSQFddS_FTG0YG40U9oicyc_yg2WrUhJ8M48fFivPSzJedbLa9DfEYkvVZuQo2BiCDpIC_h2MyR_cWz7zLiH0KYsj8wWpYMYMeVfXgC5h6dzJAFNJNSv4mPlMGzbdA4&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;631&quot; data-original-width=&quot;990&quot; height=&quot;255&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgdNMvUdLtDfbNbBLrepvQgOxaVtccsyQBiz7zOwTTvlz8ijuvIXJKGjHtaSbOuuSQFddS_FTG0YG40U9oicyc_yg2WrUhJ8M48fFivPSzJedbLa9DfEYkvVZuQo2BiCDpIC_h2MyR_cWz7zLiH0KYsj8wWpYMYMeVfXgC5h6dzJAFNJNSv4mPlMGzbdA4=w400-h255&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;It will tell you exactly where the error is. In this case its in main.c at line 20.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;For a slower PC, notepad++ is recommended. You can see how the syntax looks like below:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiKCetDK7PBnY3FRjTX_8P4-7BxkjYnaXHySG4iYOGuFZJgJr4HCApiHkHrs_2niqhHmAH0kFPTW_qghWwy9tq6Mj9tXrYqje7mv5XXfOAQ3BsnXBs-XAYkSddv4KN30ifiytdD73q1wR4L3Sp3Zdu-vH0XyTlGjzao-_r_3HX1MiBunCf1__my5xAGZ-c&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;728&quot; data-original-width=&quot;857&quot; height=&quot;339&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiKCetDK7PBnY3FRjTX_8P4-7BxkjYnaXHySG4iYOGuFZJgJr4HCApiHkHrs_2niqhHmAH0kFPTW_qghWwy9tq6Mj9tXrYqje7mv5XXfOAQ3BsnXBs-XAYkSddv4KN30ifiytdD73q1wR4L3Sp3Zdu-vH0XyTlGjzao-_r_3HX1MiBunCf1__my5xAGZ-c=w400-h339&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The code doesn&#39;t show if there are any errors in notepad++. Only after compilation you would see error in build log.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets try the same in visual studio. All you need to do is open the directory within visual studio.&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjfOUsVaLeYTcGUdkTGCvG35yHDev3wZ3fOrp0UMHl-0d2yeUUQSdvsSbK152p2zEDD2WdAkY1hbVMq62s-02kVOJKuTksRfjZQwIbGibHzXOxMfM0L5IWuHWSxxEBdPgOBjsD1qfG7Ibyai8oyMxaqXHNJ086RE1xac1ju2mdkxuwQZ_rLCagWMG8pGCA&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;586&quot; data-original-width=&quot;1145&quot; height=&quot;205&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjfOUsVaLeYTcGUdkTGCvG35yHDev3wZ3fOrp0UMHl-0d2yeUUQSdvsSbK152p2zEDD2WdAkY1hbVMq62s-02kVOJKuTksRfjZQwIbGibHzXOxMfM0L5IWuHWSxxEBdPgOBjsD1qfG7Ibyai8oyMxaqXHNJ086RE1xac1ju2mdkxuwQZ_rLCagWMG8pGCA=w400-h205&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here the only difference is that the code has auto completion feature where you type and it will show the function or variable to you which makes coding much simpler for larger projects.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now lets copy paste the generated blink.uf2 file into RPI-RP2 Drive&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjt-i4aR3lwSgzuLRI8y7JHOnj_KnRNd6g094FcA7U4nOMYw5POaJyQEfX8Ok99n-uVJpdm3yg1F0qhdDOu_kff4xWlu_dQO1B9M3ZO_NocNMMXTQG1g6CgpYOWhxS1PTCpjm3jkGV5v7Y4QThynqCfiecVPncWS-BG7zIHZqjmbRjGprQt1JCBsNjnCu4&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;626&quot; data-original-width=&quot;819&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjt-i4aR3lwSgzuLRI8y7JHOnj_KnRNd6g094FcA7U4nOMYw5POaJyQEfX8Ok99n-uVJpdm3yg1F0qhdDOu_kff4xWlu_dQO1B9M3ZO_NocNMMXTQG1g6CgpYOWhxS1PTCpjm3jkGV5v7Y4QThynqCfiecVPncWS-BG7zIHZqjmbRjGprQt1JCBsNjnCu4&quot; width=&quot;314&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once you copy paste the file, you will get a eject sound from your PC and your board must start blinking.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hope you enjoyed this tutorial. I was bursting my head understanding pico for years finding lot of tutorials and resources I could find and very few I found useful. Hope this help you complete your project.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All the best. Please do share me your feedback on above if you found something interesting or you have a better way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsEAlmCvzv7tNnKaypNxt0i4mBUNNKPWDYwEWy5HwVIE24M-tNyv9yXieyJhFb4w9-4OxkamftTtAhApcoFC4KTmsmj7JhoSjfz6jKyCFz1nly__cRQLcvFQXXh-bbmfvURDCTWWsqLSpzqWW9-iMe5KJr4ZHZB_zZ9c7E8ZYAZRyelwogt7EOBy1p5-0/s614/WhatsApp%20Image%202025-03-24%20at%2010.40.47%20PM.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;610&quot; data-original-width=&quot;614&quot; height=&quot;199&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsEAlmCvzv7tNnKaypNxt0i4mBUNNKPWDYwEWy5HwVIE24M-tNyv9yXieyJhFb4w9-4OxkamftTtAhApcoFC4KTmsmj7JhoSjfz6jKyCFz1nly__cRQLcvFQXXh-bbmfvURDCTWWsqLSpzqWW9-iMe5KJr4ZHZB_zZ9c7E8ZYAZRyelwogt7EOBy1p5-0/w200-h199/WhatsApp%20Image%202025-03-24%20at%2010.40.47%20PM.jpeg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/1179083418245976434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/1179083418245976434?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1179083418245976434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1179083418245976434'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2025/03/raspberry-pi-pico-sdk-installation.html' title='Raspberry Pi Pico SDK Installation Guide for Windows PC'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP9Zy3VQTAfACWPC1eVd83XIe0Y1KlH4iHs21V0SOL_rN68tV7KyXXkznP6zHvWUlv9H8FvRgm-3S1AyRiaXeviqEgZOqGvdcBIzY_4YBDPIpYj50MUUJHrqaOkj8RDXB4cz3-WHO_I_Fzc8w-l5k051nJQZcMHADW81Ih6pZYkSZR-XvlF4t3eqLKDb4/s72-w400-h373-c/hardware%20overview.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-7003781880688795301</id><published>2024-04-24T00:02:00.003+05:30</published><updated>2024-04-25T19:24:40.301+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="basic programming"/><title type='text'>ARIES 3.0 Flash Programming Issue with Arduino IDE</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP_vOX36gqdx4ZqREac4v6nFCtEHfxYdgohCA2UoVXZibkom5ppFrtrF99w1c5nlH-spMNAKfMRMTEjMNv9Bd5ibx6IC3Dk2aACjzN_lgxCzp_uuSRN8K9QtAOpV8MO_wtjOXPwH6G9BiuqY5NyHA2_UURipn0kis_WBVRir5Gq_OfvBfGAwfZPjTOGas/s3360/WhatsApp%20Image%202024-04-23%20at%2011.08.23%20PM.jpeg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1872&quot; data-original-width=&quot;3360&quot; height=&quot;277&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP_vOX36gqdx4ZqREac4v6nFCtEHfxYdgohCA2UoVXZibkom5ppFrtrF99w1c5nlH-spMNAKfMRMTEjMNv9Bd5ibx6IC3Dk2aACjzN_lgxCzp_uuSRN8K9QtAOpV8MO_wtjOXPwH6G9BiuqY5NyHA2_UURipn0kis_WBVRir5Gq_OfvBfGAwfZPjTOGas/w498-h277/WhatsApp%20Image%202024-04-23%20at%2011.08.23%20PM.jpeg&quot; width=&quot;498&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This post is a discussion replication done which I discussed with Vega Team and resolved my issues with programming with Vega Processor THEJAS32. Thanks to the team with valuable support throughout the process.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;AIM: &lt;/span&gt;&lt;/b&gt;To Program the ARIES 3.0 Flash memory via Arduino IDE. (&lt;a href=&quot;https://vegaprocessors.in/blog/first-hello-world-project-in-aries-v3-0/&quot; target=&quot;_blank&quot;&gt;View here&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;The issue:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhDzxBjlxiOthwP1B0ZDutIMYFEiT29fJAsGq9a74TQZ5AWxm-lLXw2scEqtnq4x1SK7OEexhjEIfKazJ7uylaetx98CIxYcXLYAYXHYmrs3oTSq5ZHhcZSZUYfpF22eI8Bt6XGMLZuhhHVCS-UQbPI2k8forFq2UaqZeiniuziKe9RB0P1kiJ4I621RIM&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;459&quot; data-original-width=&quot;671&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhDzxBjlxiOthwP1B0ZDutIMYFEiT29fJAsGq9a74TQZ5AWxm-lLXw2scEqtnq4x1SK7OEexhjEIfKazJ7uylaetx98CIxYcXLYAYXHYmrs3oTSq5ZHhcZSZUYfpF22eI8Bt6XGMLZuhhHVCS-UQbPI2k8forFq2UaqZeiniuziKe9RB0P1kiJ4I621RIM=w368-h252&quot; width=&quot;368&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Materials Required:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Board Purchase was done at: &lt;a href=&quot;https://robu.in/product/aries-v30-devlopment-board/&quot; target=&quot;_blank&quot;&gt;Robu.in&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You may also purchase the boards via &lt;a href=&quot;https://vegaprocessors.in/devboards/ariesv3.php&quot; target=&quot;_blank&quot;&gt;vega website&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I followed the procedure mentioned on the blog for programming the board on RAM only. This is to be done via XMODEM mode.&lt;/p&gt;&lt;p&gt;I&#39;ve tried the hello world tutorial from above and it works perfectly on XMODEM mode. This is the screenshot:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjCSwyT0TmYXgFV7Q23x7LV71if1Kt9qI47Zai3iQl2vdb2zNqRaxNBHynOupkZfml-heSKeYPpZbIoermrL9DW8gMk4_WQkLfa6066hw2cnmbMY3X3TlqTrmlgQQTWiwcbRDj969l4QMIum6_37hpzcFfbsLHqWm7bzEOapToRm1sChiEThQcauK_VukM&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;389&quot; data-original-width=&quot;349&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjCSwyT0TmYXgFV7Q23x7LV71if1Kt9qI47Zai3iQl2vdb2zNqRaxNBHynOupkZfml-heSKeYPpZbIoermrL9DW8gMk4_WQkLfa6066hw2cnmbMY3X3TlqTrmlgQQTWiwcbRDj969l4QMIum6_37hpzcFfbsLHqWm7bzEOapToRm1sChiEThQcauK_VukM&quot; width=&quot;215&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;and I&#39;m also getting below message on Arduino once upload is complete. And the code runs fine. This is a best way to write code incase you want to learn writing codes or for a lab experiment.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEijOOBrsv3ICYCK59k52MROHeQFKW9_AEhVkgtVwa-iQiYTHgxEfHIGqetKT-XPWmENWnSDsQgxTnhCZ9vTervLwEuO91CE1QtiGmQieCRe64h-yNplnC1jX739TXyVM_aI5Cj9sNj5kANcGj4KGb8zIB4dLildF_reIAZHetlqazq5MtD_ErUu8J8VMNc&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;220&quot; data-original-width=&quot;690&quot; height=&quot;102&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEijOOBrsv3ICYCK59k52MROHeQFKW9_AEhVkgtVwa-iQiYTHgxEfHIGqetKT-XPWmENWnSDsQgxTnhCZ9vTervLwEuO91CE1QtiGmQieCRe64h-yNplnC1jX739TXyVM_aI5Cj9sNj5kANcGj4KGb8zIB4dLildF_reIAZHetlqazq5MtD_ErUu8J8VMNc&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This is a best way to write code if you are having lot of bugs and want to test out first before writing in flash. As you are aware flash memory read/write cycles are numbered. The current chip used on Aries 3.0 is&amp;nbsp; Adesto Technologies - 25SF161B - SOIC8. &lt;a href=&quot;https://www.micros.com.pl/mediaserver/info-pee25sf161-shd.pdf&quot; target=&quot;_blank&quot;&gt;Datasheet&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA8i3vm74TSOfoI6KQznXloxWT46Gg47IKZZmlSso6chf8AIucUCvdGXzbZJ7twBUi5RQnmNctzmqfJvvwcj-5cbTam9jZd5l_9wMNM2hqaMqmcrXpiWeLffk3JfaWUcDUIkJNYWj9zDVNmqbdZF7A7JASDyxb5r8RZ8BZeIZpWNH5HSTwnS4UQ0zo0sA/s1498/WhatsApp%20Image%202024-04-23%20at%2011.02.40%20PM.jpeg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1168&quot; data-original-width=&quot;1498&quot; height=&quot;145&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA8i3vm74TSOfoI6KQznXloxWT46Gg47IKZZmlSso6chf8AIucUCvdGXzbZJ7twBUi5RQnmNctzmqfJvvwcj-5cbTam9jZd5l_9wMNM2hqaMqmcrXpiWeLffk3JfaWUcDUIkJNYWj9zDVNmqbdZF7A7JASDyxb5r8RZ8BZeIZpWNH5HSTwnS4UQ0zo0sA/w185-h145/WhatsApp%20Image%202024-04-23%20at%2011.02.40%20PM.jpeg&quot; width=&quot;185&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEibdm4yPmg_8DmRdXaCbRLm6ilyJMwn3ZmEig3zKqLtlMZCSAzNxgXzE88JuV02lkl8TQt6MuP0m6k8z6v3FYlWnm4f-xBjteGDfq_WXlEkGxYknMshxKcyRl_1Nwc2HuAZTTPZ7Z8FsBcC_GRBWOKbv8tovsFG8CorxxQbnQgzisei7fWAzRnpQE-iyyg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;206&quot; data-original-width=&quot;886&quot; height=&quot;74&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEibdm4yPmg_8DmRdXaCbRLm6ilyJMwn3ZmEig3zKqLtlMZCSAzNxgXzE88JuV02lkl8TQt6MuP0m6k8z6v3FYlWnm4f-xBjteGDfq_WXlEkGxYknMshxKcyRl_1Nwc2HuAZTTPZ7Z8FsBcC_GRBWOKbv8tovsFG8CorxxQbnQgzisei7fWAzRnpQE-iyyg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Off course this value will not make sense if you are using it for personal use, yes it will matter if same board is used in workshops where lots of students programmed these boards every year.&lt;/p&gt;&lt;p&gt;As I wanted to retain my code in memory and I wanted to use it for in field applications, flash programming was necessary for me.&lt;/p&gt;&lt;p&gt;So I followed the blog, and did my flash programming.&lt;/p&gt;&lt;p&gt;These were the settings I put in arduino IDE:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj2zaIqTYZXZWbCK_kZGgqgLfDYPLC7_OjCt3CS0vzaMfMPiY9_mJFxZyxvi8thifp8HnlYoE4SjjiuRKGGu_9yV2LWa2L57_68f9H6LVj7FK8pATBRS-eDG1fjgXxt_flyMr_dCwk4ympb70D0ZVWgLxel2cjwIyrrlcUAVp6l2NypxxirpuzSwiaQ2i0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;350&quot; data-original-width=&quot;320&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj2zaIqTYZXZWbCK_kZGgqgLfDYPLC7_OjCt3CS0vzaMfMPiY9_mJFxZyxvi8thifp8HnlYoE4SjjiuRKGGu_9yV2LWa2L57_68f9H6LVj7FK8pATBRS-eDG1fjgXxt_flyMr_dCwk4ympb70D0ZVWgLxel2cjwIyrrlcUAVp6l2NypxxirpuzSwiaQ2i0&quot; width=&quot;219&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;As mentioned in the blog, I&#39;ve shorted J12. and was trying this. My process is as follows:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Step 1: Power the board.&lt;/p&gt;&lt;p&gt;Step 2: Add Jumper J12&lt;/p&gt;&lt;p&gt;Step 3: Press Reset. Device must go to flash mode here.&lt;/p&gt;&lt;p&gt;Step 4: Upload with above settings. (&quot;Flash mode enabled, programmer vega flasher&quot;&lt;/p&gt;&lt;p&gt;Step 5: Board was Stuck with below message:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgbO5Jjz6r3cPMhRkBNBlMX4fDPf3n4FnuOIxz4FRiWlviilAQkMRgebLPr7JSTI5E0_w19QYA9hQufGiuHjf8fyL6p8C1JV9BA-jQSm2W3I9GClPBQBQ9f-f23cxbjrmVY4q4P8Zot9u2c0xCM2TrKwKx9g4Qp8qJCs43iI-MKNEt5I7rNNiBlLYDpEvA&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;172&quot; data-original-width=&quot;725&quot; height=&quot;110&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgbO5Jjz6r3cPMhRkBNBlMX4fDPf3n4FnuOIxz4FRiWlviilAQkMRgebLPr7JSTI5E0_w19QYA9hQufGiuHjf8fyL6p8C1JV9BA-jQSm2W3I9GClPBQBQ9f-f23cxbjrmVY4q4P8Zot9u2c0xCM2TrKwKx9g4Qp8qJCs43iI-MKNEt5I7rNNiBlLYDpEvA=w463-h110&quot; width=&quot;463&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Please note that I had never worked with Aries Before and I was clueless whether to &lt;b&gt;press the reset&lt;/b&gt; or let it &lt;b&gt;reset on its own&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;So if I try pressing Reset the screen gets stuck here only:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgbO5Jjz6r3cPMhRkBNBlMX4fDPf3n4FnuOIxz4FRiWlviilAQkMRgebLPr7JSTI5E0_w19QYA9hQufGiuHjf8fyL6p8C1JV9BA-jQSm2W3I9GClPBQBQ9f-f23cxbjrmVY4q4P8Zot9u2c0xCM2TrKwKx9g4Qp8qJCs43iI-MKNEt5I7rNNiBlLYDpEvA&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;172&quot; data-original-width=&quot;725&quot; height=&quot;108&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgbO5Jjz6r3cPMhRkBNBlMX4fDPf3n4FnuOIxz4FRiWlviilAQkMRgebLPr7JSTI5E0_w19QYA9hQufGiuHjf8fyL6p8C1JV9BA-jQSm2W3I9GClPBQBQ9f-f23cxbjrmVY4q4P8Zot9u2c0xCM2TrKwKx9g4Qp8qJCs43iI-MKNEt5I7rNNiBlLYDpEvA=w455-h108&quot; width=&quot;455&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;and If I don&#39;t press reset the screen shows this message after like 30seconds to minute.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhj8DIO-Aj8HA3FO-7y4BvZP9J84BRtOxeHdLHkaNXihhb4a7wAXuIvgct6IgMn4rChJk1SdSYiWeIWw7qN2HI9BX6hPFl7EpmyDZg8RJHPHAFluHIY9EsHL3zsUmBDAp8cjnyGf4W1UtLFmgyfvnexKw2317_C9Mj-Yxu_6ep9AEtHs2Gfjf8u530eCNA&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;459&quot; data-original-width=&quot;671&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhj8DIO-Aj8HA3FO-7y4BvZP9J84BRtOxeHdLHkaNXihhb4a7wAXuIvgct6IgMn4rChJk1SdSYiWeIWw7qN2HI9BX6hPFl7EpmyDZg8RJHPHAFluHIY9EsHL3zsUmBDAp8cjnyGf4W1UtLFmgyfvnexKw2317_C9Mj-Yxu_6ep9AEtHs2Gfjf8u530eCNA=w438-h300&quot; width=&quot;438&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;As for curiosity purposes, I tried checking what&#39;s happening on the Terminal. As the message said expected ACK; got C. I wondered what&#39;s that&#39;s like in terminal via hex view. I was still clueless.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhs5CI5ykGOArnQEQug3Qynywy2b5UDlFz_8Erdpp9J7xfScm77C6UFQsRyOc2lQKx7JfvifAvsw9nOfuo6gJClQdb0_SrwdJuW9gHitVR2HU4zmhU-9G-78ORLJs3KsCC54J9PWrHPQXGYeQ9vryTAJt-vogqaZLJB0lkgt-45ByLoSgwBwFL7urPWqgI&quot; style=&quot;clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;371&quot; data-original-width=&quot;638&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhs5CI5ykGOArnQEQug3Qynywy2b5UDlFz_8Erdpp9J7xfScm77C6UFQsRyOc2lQKx7JfvifAvsw9nOfuo6gJClQdb0_SrwdJuW9gHitVR2HU4zmhU-9G-78ORLJs3KsCC54J9PWrHPQXGYeQ9vryTAJt-vogqaZLJB0lkgt-45ByLoSgwBwFL7urPWqgI&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/p&gt;Then as per discussion with Vega Team, Following steps I took.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step1: Do not short jumper J12, and keep settings as below:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgx_ojwIe8hAFu2mkjG5VstyHfj4_y-TebsUGKvRdqnJJAlQqHlu9wNnnU8L4FigHs-EybK1qIo7APYGMYEed4xlE9nky9vYqlt_ri9iBZpZXm1d-AqEvSmyiAKLdwGYSusdBbtDmdIXJmSqovWsTz2oPyj-kNIO8jkLNM1o-VVuGlSOI0ZdVraRAeTJ8Q&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;347&quot; data-original-width=&quot;316&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgx_ojwIe8hAFu2mkjG5VstyHfj4_y-TebsUGKvRdqnJJAlQqHlu9wNnnU8L4FigHs-EybK1qIo7APYGMYEed4xlE9nky9vYqlt_ri9iBZpZXm1d-AqEvSmyiAKLdwGYSusdBbtDmdIXJmSqovWsTz2oPyj-kNIO8jkLNM1o-VVuGlSOI0ZdVraRAeTJ8Q&quot; width=&quot;219&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 2: Click on Burn Bootloader.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjZdMVz2IBw2m2tHzC2Nt4GVseOOSvJidrgzLiHAk_8pfN1ccFmBK_kRmyJDz-mx6qZDJH2mmL-cLiav4lLlYWXyBMHlCxGziyh3qAZlSENvVtiQw03uBb_LhZS7FAK9LUIx9R7mQmomIJKDLiuLF7SCBXgoxQ-EctGW08Nn7bFOTWI--ngdJmwGTBHKO8&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;199&quot; data-original-width=&quot;318&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjZdMVz2IBw2m2tHzC2Nt4GVseOOSvJidrgzLiHAk_8pfN1ccFmBK_kRmyJDz-mx6qZDJH2mmL-cLiav4lLlYWXyBMHlCxGziyh3qAZlSENvVtiQw03uBb_LhZS7FAK9LUIx9R7mQmomIJKDLiuLF7SCBXgoxQ-EctGW08Nn7bFOTWI--ngdJmwGTBHKO8&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Successfully done, I assume the bootloader is now in RAM? To flash the firmware later? Device is not RESET or power cycled at any time right now as I&#39;m assuming the data is in ram.&lt;/div&gt;&lt;div&gt;Step 3: Now short the jumper J12, and change the settings as below:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiQBvRq7uyClbvAAkC62wtfow4zZ2HpY5dqwgha_E2WgQEcIpfpxEbVmfVIs8ZponGQC7cZNPIRm_jT0w5yJgIVn-Vvh_uoenJhJyhjb55veZUCTrwUCO49eWNR4o9b2M-EIwhC39pW_KWtn3r2im815FPYbt9j9KnWqStHZEXNMbkEUEO7xA2WvCM_Qso&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;352&quot; data-original-width=&quot;317&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiQBvRq7uyClbvAAkC62wtfow4zZ2HpY5dqwgha_E2WgQEcIpfpxEbVmfVIs8ZponGQC7cZNPIRm_jT0w5yJgIVn-Vvh_uoenJhJyhjb55veZUCTrwUCO49eWNR4o9b2M-EIwhC39pW_KWtn3r2im815FPYbt9j9KnWqStHZEXNMbkEUEO7xA2WvCM_Qso&quot; width=&quot;216&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 4: Compile and upload using programmer&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEibkjSUL1EBLj47zW2HjUxpXl_fQCCpChM7lE4VOHQZFHpQf0kbA3MfSEM47HbZl-4d3TaX1dpZRpcv3YFA6mNRg0oZ78qMY_7hn4MgOxcphmyZfUhFsYzKiifYdggI_sJWpeRdUfEEATs9XPMCVE3oF8jAPm3X2siHvIffzRpy9B_clnyZZCWTeVl9n0s&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;223&quot; data-original-width=&quot;287&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEibkjSUL1EBLj47zW2HjUxpXl_fQCCpChM7lE4VOHQZFHpQf0kbA3MfSEM47HbZl-4d3TaX1dpZRpcv3YFA6mNRg0oZ78qMY_7hn4MgOxcphmyZfUhFsYzKiifYdggI_sJWpeRdUfEEATs9XPMCVE3oF8jAPm3X2siHvIffzRpy9B_clnyZZCWTeVl9n0s&quot; width=&quot;309&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;Step 5: Programmer asks for reset&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEicnfef_aBFccM8dbwrFD06gM0oImlqMqEnSv_KSgVSZDRjcRxSG0RA2Vz-lNys896ebzTSZJ2kgb1uOl_-nL_qw9b1uH7MaNRwXD09VNyrF_q1ZxS92MMDOSXctGg7aA49jcwI_LD0jEr2taCD0kyi0K6juvjOLd2AiYwhkmau_7pou6gLh27TV01DBJg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;505&quot; data-original-width=&quot;744&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEicnfef_aBFccM8dbwrFD06gM0oImlqMqEnSv_KSgVSZDRjcRxSG0RA2Vz-lNys896ebzTSZJ2kgb1uOl_-nL_qw9b1uH7MaNRwXD09VNyrF_q1ZxS92MMDOSXctGg7aA49jcwI_LD0jEr2taCD0kyi0K6juvjOLd2AiYwhkmau_7pou6gLh27TV01DBJg=w410-h278&quot; width=&quot;410&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It didn&#39;t work. Wondering if my steps are proper. I sent these to Vega Team regarding this as I was still getting issues.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So they asked me to do following tests, send a screenshot of terminal with &amp;amp; without jumper.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Without Jumper on J12 screenshot:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgPZELWmKmEi64rMBoskukrc4SHjCp4GF59dM0XuEzjF6fDlu6iSbjORo_pM1mrC_wbXcNDPn73LAY9b-kFagMJbloijjE4dS09Vi7pLBaZ_myqsqGbKbWmNON4ZsIkHYMj7oX7daD_UBZBFTANDIDCzHlW0ID0WrX3DthNkmQ2oRawSvcfCoDGQR3dvvo&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;623&quot; data-original-width=&quot;690&quot; height=&quot;417&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgPZELWmKmEi64rMBoskukrc4SHjCp4GF59dM0XuEzjF6fDlu6iSbjORo_pM1mrC_wbXcNDPn73LAY9b-kFagMJbloijjE4dS09Vi7pLBaZ_myqsqGbKbWmNON4ZsIkHYMj7oX7daD_UBZBFTANDIDCzHlW0ID0WrX3DthNkmQ2oRawSvcfCoDGQR3dvvo=w462-h417&quot; width=&quot;462&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;With Jumper on J12 screenshot:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiIINSPhveHwSIrhrl6hl1EG_ZhR99nnOQIwsTMpQ4HbJMvxRv-MddIABJVgQ7fNiI9xUehfrIvq9WLtW86jyuG-nkiBr3ZaBZNEY5K10KmlpzmxekMzOy9IXCS6Bn3VJj8-4N9_xR-QtIoJBHXQgLJ2Jz0XlKsiy9DOZyLZnY0dgR11mFcmNZ5-dDEtDc&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;894&quot; data-original-width=&quot;1372&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiIINSPhveHwSIrhrl6hl1EG_ZhR99nnOQIwsTMpQ4HbJMvxRv-MddIABJVgQ7fNiI9xUehfrIvq9WLtW86jyuG-nkiBr3ZaBZNEY5K10KmlpzmxekMzOy9IXCS6Bn3VJj8-4N9_xR-QtIoJBHXQgLJ2Jz0XlKsiy9DOZyLZnY0dgR11mFcmNZ5-dDEtDc=w496-h324&quot; width=&quot;496&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It seems the Flasher was kind of restarting and no code was present.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Here I also found that in one post it was mentioned that programmer needs to be in flash mode during burning of bootloader. So even though my driver was not updated my procedure was still wrong.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The blog I referred to is here (&lt;a href=&quot;https://vegaprocessors.in/blog/how-to-interface-aries-boards-using-rs485-modbus-protocol/&quot;&gt;check link&lt;/a&gt;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;In this blog the steps were as follows:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 1: remove jumper J12. &amp;amp; Press Reset.&lt;/div&gt;&lt;div&gt;Step 2: Tools -&amp;gt; Flashmode -&amp;gt; Enabled.&lt;/div&gt;&lt;div&gt;Step 3: Tools -&amp;gt; Programmer -&amp;gt; VEGA FLASHER.&lt;/div&gt;&lt;div&gt;Step 4: Tools -&amp;gt; Burn Bootloader.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After discussing with them on call I realized, I &lt;b&gt;must not press the reset button.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;The board must do the reset automatically when programming. so they asked me to update the firmware drivers for CP210x&amp;nbsp; (&lt;a href=&quot;https://www.silabs.com/documents/public/software/CP210x_Universal_Windows_Driver.zip&quot; target=&quot;_blank&quot;&gt;drivers here&lt;/a&gt;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 1: Download Drivers.&lt;/div&gt;&lt;div&gt;Step 2: Unzip driver.&lt;/div&gt;&lt;div&gt;Step 3: Go to Device manager -&amp;gt; Ports - &amp;gt; Update drivers of CP210x&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhqgxg4AXA5QNgIBx5rOmTuzt_z03agT5bln6qI76EGjLtHu1sVHYPzBPOlMLZhZs567q70iq8xTIG8JY1Qgn42bzHbYRURCZwo0VR6ngwDgOeR6iUgFe7a68Wk-mNIx4GmHxRaf5fqHhwXoapnv9gWUCUaSgtZ_Ly-_VoQogP6jWp6L5IfKuSvbOzkMbg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;528&quot; data-original-width=&quot;427&quot; height=&quot;317&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhqgxg4AXA5QNgIBx5rOmTuzt_z03agT5bln6qI76EGjLtHu1sVHYPzBPOlMLZhZs567q70iq8xTIG8JY1Qgn42bzHbYRURCZwo0VR6ngwDgOeR6iUgFe7a68Wk-mNIx4GmHxRaf5fqHhwXoapnv9gWUCUaSgtZ_Ly-_VoQogP6jWp6L5IfKuSvbOzkMbg=w256-h317&quot; width=&quot;256&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 4: Select Driver location manually and click on next.&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgVog17kPx947TGVY1VFdV10WAPDr6xwE2zlRNmFILIMTGax5pltQeBBH088LPU5UT26AbrvpIbn00cCdrgjld7Uc3zlX_9qdr1_T5DG5oawJlBaR6nIO_eEczG4Gj5j6WSx4qhAbt4yZ_1D6fIe-UahoduWsX_4bOWtOl8V0hwPFbdt1rPcJEH9JC0oMQ&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;464&quot; data-original-width=&quot;626&quot; height=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgVog17kPx947TGVY1VFdV10WAPDr6xwE2zlRNmFILIMTGax5pltQeBBH088LPU5UT26AbrvpIbn00cCdrgjld7Uc3zlX_9qdr1_T5DG5oawJlBaR6nIO_eEczG4Gj5j6WSx4qhAbt4yZ_1D6fIe-UahoduWsX_4bOWtOl8V0hwPFbdt1rPcJEH9JC0oMQ&quot; width=&quot;388&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 5: done. Now open Arduino IDE and try again.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;To the Season Finale:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 1: Connect the board and &lt;b&gt;remove Jumper J12&lt;/b&gt;. Press Reset button.&lt;/div&gt;&lt;div&gt;Step 2: Do following settings as mentioned below. (once CP210x driver is updated). Select Flash mode: enabled, and programmer as VEGA FLASHER.&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiijk0uERRyFoI4HEGZrLgQg1snQojCVvwtujrGyG8sO2thSkOJ6i8GQswoLDRQnVB-zHZ85gjPcHxYGnvRNhQW3aEea7cEOKqMD6s6bBDXsvyNuqVe49dx3CDGNwNDPwnc0XTCYJgHguMaZCGLzwl80faH3hfC0P3Xyfk9m6IO3lspF87IdtCtr1Et-4Q&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;414&quot; data-original-width=&quot;473&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiijk0uERRyFoI4HEGZrLgQg1snQojCVvwtujrGyG8sO2thSkOJ6i8GQswoLDRQnVB-zHZ85gjPcHxYGnvRNhQW3aEea7cEOKqMD6s6bBDXsvyNuqVe49dx3CDGNwNDPwnc0XTCYJgHguMaZCGLzwl80faH3hfC0P3Xyfk9m6IO3lspF87IdtCtr1Et-4Q&quot; width=&quot;274&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 3: You must click on burn Bootloader. This is the message you will get.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEipBvsp6J2ZmrAE4bqDxtfL7HFF6zKlp5JXxM4RNRthOOw3f9u8yfBREQn6eEBLyVfbfXr1y7VioNPGkXEjO1seM1yjc6flvCBeQ9j_7HRifI4zFLtARTCFtL3O5gAuu8dw_t6ZQRFzfM480uQeYAXRoyfOnP3JGtYvTOjyzjd9o8-URnZyri_fp9I86qI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;180&quot; data-original-width=&quot;377&quot; height=&quot;153&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEipBvsp6J2ZmrAE4bqDxtfL7HFF6zKlp5JXxM4RNRthOOw3f9u8yfBREQn6eEBLyVfbfXr1y7VioNPGkXEjO1seM1yjc6flvCBeQ9j_7HRifI4zFLtARTCFtL3O5gAuu8dw_t6ZQRFzfM480uQeYAXRoyfOnP3JGtYvTOjyzjd9o8-URnZyri_fp9I86qI&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 4: Now &lt;b&gt;put the Jumper J12&lt;/b&gt;. And do not press reset yet. (This is what I did)&lt;/div&gt;&lt;div&gt;Step 5: compile and upload your code via Programmer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjP35qYnHRLLobouyMWjdMJxyBcXBl2zD61LrIT2DJsdJelM8dFGAPoxvcuo2khwFn22bV_54NPiPeF01ckrKCx2E29SnJbZXDmqsEI6DAQfaT0RQu0Xw-ZK3qqLx0et2YUhefHM9AWS095Abd6ijDVMvGCsEeplr8etNRVhbNiACiXd_iltGskpWDUtYA&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;302&quot; data-original-width=&quot;396&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjP35qYnHRLLobouyMWjdMJxyBcXBl2zD61LrIT2DJsdJelM8dFGAPoxvcuo2khwFn22bV_54NPiPeF01ckrKCx2E29SnJbZXDmqsEI6DAQfaT0RQu0Xw-ZK3qqLx0et2YUhefHM9AWS095Abd6ijDVMvGCsEeplr8etNRVhbNiACiXd_iltGskpWDUtYA&quot; width=&quot;315&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 6: See if this message appears. This message must appear within few seconds and you must not press RESET here like I did in past:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjxbISr1sZLONumhGDS0RXzHkDFdlzSznXD-qk6PHjX30gJpQVennZ7Gxp_BskpPAFBPGJIlmV4x0LU2NaVFCYOsUPE-jCfr6YzkqcUlMiFF5nYzP-wFoYwrANkgsjnqi90myJyVm5nlsEyye-0qlMwoCrPRCqXpDs873virabmuksEeJe-Jq1wEkwggZw&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;326&quot; data-original-width=&quot;701&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjxbISr1sZLONumhGDS0RXzHkDFdlzSznXD-qk6PHjX30gJpQVennZ7Gxp_BskpPAFBPGJIlmV4x0LU2NaVFCYOsUPE-jCfr6YzkqcUlMiFF5nYzP-wFoYwrANkgsjnqi90myJyVm5nlsEyye-0qlMwoCrPRCqXpDs873virabmuksEeJe-Jq1wEkwggZw=w443-h206&quot; width=&quot;443&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 7: Check if your code works by pressing reset. This time keep the jumper on J12 still ON.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8CcNbZ9eJbJL1mZYC8urRS5APDo5VUq_yCP7VEEktxT3Itr99N7uojoh5c4e5g7IyY1ZfcIO7SOIPIofDON0tCdVIM5yQFoI1V_3GaQsihSM9FUc6v6pyOOOIAS6u3FPaZVdP4BECc_-M7QPDvjeWf1p_RHbkfBlKnaMapPn5LVWO5ViZlKu8DPhY-wo/s2792/WhatsApp%20Image%202024-04-23%20at%2011.50.12%20PM.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1548&quot; data-original-width=&quot;2792&quot; height=&quot;261&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8CcNbZ9eJbJL1mZYC8urRS5APDo5VUq_yCP7VEEktxT3Itr99N7uojoh5c4e5g7IyY1ZfcIO7SOIPIofDON0tCdVIM5yQFoI1V_3GaQsihSM9FUc6v6pyOOOIAS6u3FPaZVdP4BECc_-M7QPDvjeWf1p_RHbkfBlKnaMapPn5LVWO5ViZlKu8DPhY-wo/w472-h261/WhatsApp%20Image%202024-04-23%20at%2011.50.12%20PM.jpeg&quot; width=&quot;472&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This time the code didn&#39;t get erased and It worked brilliantly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 8: From Now on, you must only use &lt;b&gt;Sketch -&amp;gt; upload using programmer&lt;/b&gt;. The bootloader process is to be done only at startup.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To use back the RAM Version you can also follow the steps mentioned in first blog that I mentioned (&lt;a href=&quot;https://vegaprocessors.in/blog/first-hello-world-project-in-aries-v3-0/&quot; target=&quot;_blank&quot;&gt;View here&lt;/a&gt;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;If it really helped you, please do comment your feedback and share it with your friends and colleagues.&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;And thank you VEGA TEAM once again for all the support. #vegaprocessors #riscv&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiuMGJX3Syf0NFpBzVu0wLV-t21DtZKR4eStHBTGT-cz5QSOddjfyxS7h1S9A_fqnRmCSfSZl_RhGvfYTNfRMPrBiIWoPkPqx6UvmAhiYmEUo8icP60XpQ6Ut7SUgonA78ety4irCQ7zpFSWzsWYaee999X2qozDNIEocEv7ezkwbEFUtJOTfkzZOHeyyc&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;194&quot; data-original-width=&quot;204&quot; height=&quot;157&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiuMGJX3Syf0NFpBzVu0wLV-t21DtZKR4eStHBTGT-cz5QSOddjfyxS7h1S9A_fqnRmCSfSZl_RhGvfYTNfRMPrBiIWoPkPqx6UvmAhiYmEUo8icP60XpQ6Ut7SUgonA78ety4irCQ7zpFSWzsWYaee999X2qozDNIEocEv7ezkwbEFUtJOTfkzZOHeyyc=w165-h157&quot; width=&quot;165&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/7003781880688795301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/7003781880688795301?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/7003781880688795301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/7003781880688795301'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2024/04/aries-30-flash-programming-issue-with.html' title='ARIES 3.0 Flash Programming Issue with Arduino IDE'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP_vOX36gqdx4ZqREac4v6nFCtEHfxYdgohCA2UoVXZibkom5ppFrtrF99w1c5nlH-spMNAKfMRMTEjMNv9Bd5ibx6IC3Dk2aACjzN_lgxCzp_uuSRN8K9QtAOpV8MO_wtjOXPwH6G9BiuqY5NyHA2_UURipn0kis_WBVRir5Gq_OfvBfGAwfZPjTOGas/s72-w498-h277-c/WhatsApp%20Image%202024-04-23%20at%2011.08.23%20PM.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-2776571397688781586</id><published>2020-11-19T22:33:00.009+05:30</published><updated>2020-11-26T23:13:48.067+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="1ms delay"/><category scheme="http://www.blogger.com/atom/ns#" term="basic"/><category scheme="http://www.blogger.com/atom/ns#" term="basic programming"/><category scheme="http://www.blogger.com/atom/ns#" term="clockgenerator"/><category scheme="http://www.blogger.com/atom/ns#" term="delayms"/><category scheme="http://www.blogger.com/atom/ns#" term="GPIO"/><category scheme="http://www.blogger.com/atom/ns#" term="Nucleo"/><category scheme="http://www.blogger.com/atom/ns#" term="NVIC"/><category scheme="http://www.blogger.com/atom/ns#" term="PWM"/><category scheme="http://www.blogger.com/atom/ns#" term="ST-LINKV2-1"/><category scheme="http://www.blogger.com/atom/ns#" term="STM32F746ZG"/><category scheme="http://www.blogger.com/atom/ns#" term="TIM2"/><title type='text'>Precision delay function for Nucleo STM32F746ZG</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: red; font-size: medium;&quot;&gt;&lt;b&gt;AIM: To teach you how to create a delay function using timer from STM32F746ZG.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;/span&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinEdaUJiXMLv_uO1VV13bhuRQR5pL3o1nVC47b7ZhcQn36wP6Ot6ZXmdjpn4T-apz2Io7LX1oqGMatjVAZ2uuASFrcO7qHM5myYWIXCl2DtZ1mn6PUiONwnuVdoihitEaLOQW8R9gz2Dc/s1270/cover.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;952&quot; data-original-width=&quot;1270&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinEdaUJiXMLv_uO1VV13bhuRQR5pL3o1nVC47b7ZhcQn36wP6Ot6ZXmdjpn4T-apz2Io7LX1oqGMatjVAZ2uuASFrcO7qHM5myYWIXCl2DtZ1mn6PUiONwnuVdoihitEaLOQW8R9gz2Dc/w640-h480/cover.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Why we need to learn this topic?&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Creating precision delays for projects.&lt;/li&gt;&lt;li&gt;Interfacing slow peripherals&amp;nbsp; on i2c bus and RS485 bus. Specially in bit banging data to other IC&#39;s.&lt;/li&gt;&lt;li&gt;Blinking LED patterns and preventing switch de-bouncing.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Things required:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Nucleo F746ZG development board or STM32F746ZG microcontroller board.&lt;/li&gt;&lt;li&gt;ST-LINKV2 programmer. (Already present in this development board)&lt;/li&gt;&lt;li&gt;Inbuilt LED, or any LED you have spare on GPIO. (General purpose Input/Output)&lt;/li&gt;&lt;li&gt;Micro USB Cable to power up the development board.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Software&amp;nbsp;required:&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://atollic.com/truestudio/&quot; target=&quot;_blank&quot;&gt;Atollic True Studio for ARM 6.0.0 and above&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Drivers for STLINKV2 (Gets auto downloaded upon connecting nucleo/ while installing atollic studio)&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Documents required:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;STM32F74xx Reference Manual (&lt;a href=&quot;https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf&quot; target=&quot;_blank&quot;&gt;RM0385&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.st.com/resource/en/datasheet/stm32f746zg.pdf&quot; target=&quot;_blank&quot;&gt;STM32F746ZG datasheet&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.st.com/resource/en/user_manual/dm00244518-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf&quot; target=&quot;_blank&quot;&gt;Nucleo F746ZG manual&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
To create a precision delay we need to know few steps below so we can focus more on that section.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Finding clock frequency of the STM32F.&lt;/li&gt;&lt;li&gt;Finding the right timer and understanding to calculate reload value.&lt;/li&gt;&lt;li&gt;To create a universal delay function for our programs.&lt;/li&gt;&lt;li&gt;To select a GPIO pin and test LED blinking properly for delay function accuracy.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Flow chart for initializing timer 2:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw3v8uAsL5kNv5pVPhRZF7meZ7MKwpZk4PqNZunuwwp4FN8CwAfzklMlyGiZwSy7j0jAM__4QU-Q1EamAvf7nTYMbiCHga3drQvQx3hW-qXaVWQWIc6Dr7aOhFGVcXrH7LtGRUyRFZPvE/s1593/STM32Timer+Setup1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1593&quot; data-original-width=&quot;979&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw3v8uAsL5kNv5pVPhRZF7meZ7MKwpZk4PqNZunuwwp4FN8CwAfzklMlyGiZwSy7j0jAM__4QU-Q1EamAvf7nTYMbiCHga3drQvQx3hW-qXaVWQWIc6Dr7aOhFGVcXrH7LtGRUyRFZPvE/w394-h640/STM32Timer+Setup1.png&quot; width=&quot;394&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt;Flow chart for interrupt service routine:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAibG5ucMSD17qRqbg3GUMMYLMe3Fc3-Rx_RSEEzbvpbT3mQJzF0qYOmWIRG2_5xqpvGYukHR80jcnEZLOmfy6LfsX130alsMAEYEsmlsaLZiEvDHG5h55bbQugN5esWWLR74ZWLKPiWU/s1331/STM32Timer+Setup.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1331&quot; data-original-width=&quot;799&quot; height=&quot;532&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAibG5ucMSD17qRqbg3GUMMYLMe3Fc3-Rx_RSEEzbvpbT3mQJzF0qYOmWIRG2_5xqpvGYukHR80jcnEZLOmfy6LfsX130alsMAEYEsmlsaLZiEvDHG5h55bbQugN5esWWLR74ZWLKPiWU/w319-h532/STM32Timer+Setup.png&quot; width=&quot;319&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;STEP1: Finding out default clock frequency.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;b&gt;To begin with timer, first you always need to know what is the clock frequency of the microcontroller. This exercise below is to find out what is the default clock frequency set in atollic studio template and how to initialize in main function.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Atollic studio embedded c template creates a default system clock function for you so lets try that shall we.&lt;/div&gt;&lt;div&gt;Lets create a new project by clicking on File - New - C project as shown below&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ7AfWK3U8mDF6tW-aYJ_eienyqmz9bPS70pMEn0DKt3cCKrgG7XgDU-6q_KE64SLuHZxtQRWMM_NO1fkLiTPnoQBFOLdiEZxV7ro2-kc4Tt8MCwnsieK5JTa_RjfRehk0F-sDrbyC5DY/s803/step1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;571&quot; data-original-width=&quot;803&quot; height=&quot;454&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ7AfWK3U8mDF6tW-aYJ_eienyqmz9bPS70pMEn0DKt3cCKrgG7XgDU-6q_KE64SLuHZxtQRWMM_NO1fkLiTPnoQBFOLdiEZxV7ro2-kc4Tt8MCwnsieK5JTa_RjfRehk0F-sDrbyC5DY/w640-h454/step1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Lets name this project as delaymstest. Select embedded c project and click next.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL7khfdJxObTcZZp4_bVP3Xr4dT74DXJ3FPgOSa_Qt8nqFY_Ra1TW_hbBLF2jH1_TWx58w_qjI3HMfn40XotbhQt8ysnvxdZr7VJsnGJmat4fPMhSi0M4BDR7cVVS0VioSEoXY7bkouB8/s582/step2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;582&quot; data-original-width=&quot;518&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL7khfdJxObTcZZp4_bVP3Xr4dT74DXJ3FPgOSa_Qt8nqFY_Ra1TW_hbBLF2jH1_TWx58w_qjI3HMfn40XotbhQt8ysnvxdZr7VJsnGJmat4fPMhSi0M4BDR7cVVS0VioSEoXY7bkouB8/w570-h640/step2.png&quot; width=&quot;570&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Now we need to chose STM32F746ZG by going to STM32F7 device category, then MCU sub category and then STM32F746ZG as show below. Once done click on next.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgyI38wmCXh7EpEH_noUYHpHdx7SBNLLBf9lOYgRttCe7wUR3ce9fxweVqbjv4_FA98kLD_GdcYKJUMpE0P3Gl-6sp8GdYwjGuuq08arKjy94dTb0t8cgNNVPXITYZOjVjk42OFqw1d0w/s769/step3.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;769&quot; data-original-width=&quot;533&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgyI38wmCXh7EpEH_noUYHpHdx7SBNLLBf9lOYgRttCe7wUR3ce9fxweVqbjv4_FA98kLD_GdcYKJUMpE0P3Gl-6sp8GdYwjGuuq08arKjy94dTb0t8cgNNVPXITYZOjVjk42OFqw1d0w/w444-h640/step3.png&quot; width=&quot;444&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This MCU has huge space so lets not select nano-lib, lets consider standard library and click next.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN_jrd4I5g9TP6IG-PhiFrXf0dO61Fsmz7L0VjRingLJEOUARR9Zr5ZFM9ZCYadwaTlJoxa1DvakL78jiWSgnsYm2t3G0tjwPXZYwZ1VhRHdu7vJyPjlOZfxIiVeiVlWDHjnxymuod9gE/s766/step4.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;766&quot; data-original-width=&quot;531&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN_jrd4I5g9TP6IG-PhiFrXf0dO61Fsmz7L0VjRingLJEOUARR9Zr5ZFM9ZCYadwaTlJoxa1DvakL78jiWSgnsYm2t3G0tjwPXZYwZ1VhRHdu7vJyPjlOZfxIiVeiVlWDHjnxymuod9gE/w444-h640/step4.png&quot; width=&quot;444&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Since there is a STLINKV2 programmer on nucleo board, lets choose STLINK as debug port and click finish.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwnsybgraiUOJnw6hKqXk2wq6aFK1rP4SyUqNISm-Ko0Y1SBdCss4ss0QtoPKiPl5B2asSNZHhxYAT_rVBlR2x9J6XBf5JFu9ezh4MC0ag_jwdUsPlTaL1PBa5E0amTI4zcHTQGPkF90g/s759/step5.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;759&quot; data-original-width=&quot;526&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwnsybgraiUOJnw6hKqXk2wq6aFK1rP4SyUqNISm-Ko0Y1SBdCss4ss0QtoPKiPl5B2asSNZHhxYAT_rVBlR2x9J6XBf5JFu9ezh4MC0ag_jwdUsPlTaL1PBa5E0amTI4zcHTQGPkF90g/w444-h640/step5.png&quot; width=&quot;444&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Now lets check out&amp;nbsp;&lt;b&gt;system_stm32f7xx.c &lt;/b&gt;file to see what default clock frequency has been provided by atollic default template.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5BlVhGnNes5Cc_hPO746bLEbsuZNPrTCoa6jQb6GvnzLM7lVg8a4KP3sbXqe9eKgcohEnpuMfnTjQCNQn3JydTQrTmhixMKvOxSlgU0Uecu-3oVGJ1asbdNT4_vKIP-wExZ5AevwniOE/s322/step6.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;322&quot; data-original-width=&quot;271&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5BlVhGnNes5Cc_hPO746bLEbsuZNPrTCoa6jQb6GvnzLM7lVg8a4KP3sbXqe9eKgcohEnpuMfnTjQCNQn3JydTQrTmhixMKvOxSlgU0Uecu-3oVGJ1asbdNT4_vKIP-wExZ5AevwniOE/w336-h400/step6.png&quot; width=&quot;336&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The frequency can be found at&amp;nbsp;&lt;b&gt;SystemCoreClock&lt;/b&gt; variable which is 16MHz.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix956_lzOO82bt_WgF9YOGnMcCt5O9-kp_jWdZBbClPh1I9JNMfTAcePEphKvHG4HEm0pnMyvgjspPoPTYYcRrlvHb7bUmNsJ00_Nq3zKaW5yNmmfTVu4_EgHYvAmLxFdgmrQlybgDbhI/s716/step7.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;329&quot; data-original-width=&quot;716&quot; height=&quot;294&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix956_lzOO82bt_WgF9YOGnMcCt5O9-kp_jWdZBbClPh1I9JNMfTAcePEphKvHG4HEm0pnMyvgjspPoPTYYcRrlvHb7bUmNsJ00_Nq3zKaW5yNmmfTVu4_EgHYvAmLxFdgmrQlybgDbhI/w640-h294/step7.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Lets add &lt;b&gt;SystemInit()&lt;/b&gt; function to initialize 16MHz clock in our code directly for now. I will not be explaining how to create different clock frequencies since its another whole topic to be discussed.&lt;/div&gt;&lt;div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHcrolwvYCuod7ra4nDrCxzRHm1HrmDOumQjyU55r5xsq1cHuKQYZfByTV-FTNd2_oC8hAx7nzOgCJXjopLrW_Lb6jdArZERqqMr-y_jiCRFdEyK1J6JcKcz1TSvzsUni3doYtSzs2x5U/s722/step8.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;560&quot; data-original-width=&quot;722&quot; height=&quot;496&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHcrolwvYCuod7ra4nDrCxzRHm1HrmDOumQjyU55r5xsq1cHuKQYZfByTV-FTNd2_oC8hAx7nzOgCJXjopLrW_Lb6jdArZERqqMr-y_jiCRFdEyK1J6JcKcz1TSvzsUni3doYtSzs2x5U/w640-h496/step8.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Lets clean up the code and add above SystemInit() function to main as below:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9eNZlTuCuXX8bUt_pSBH2AASHxRxW_6ITZOcdYr6sJPNLYr_chy9vPdnGvj_BO5GeN5km8907zunF-L59hO2cv_CgLOKTD8n0o1REzUZIPkbCEB3SLPaV8XAfel09rShNtntu0_JGy4Y/s275/step9.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;209&quot; data-original-width=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9eNZlTuCuXX8bUt_pSBH2AASHxRxW_6ITZOcdYr6sJPNLYr_chy9vPdnGvj_BO5GeN5km8907zunF-L59hO2cv_CgLOKTD8n0o1REzUZIPkbCEB3SLPaV8XAfel09rShNtntu0_JGy4Y/s0/step9.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now at this stage our clock is finally set. So lets move to step 2.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;STEP2: Understanding Timer block diagram.&lt;/b&gt; In our case we have to use general purpose timer 2.&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;Main aim here is to understand how timer block works and what are they key Internal registers to be programmed for making timer work. We need to set/clear certain registers or individual bits inside register for configuring timer.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGWSAD47MdtV7JxWqGtHW-WAwRRNPflPw0OucizxiuJo2PfqmFp7ON3ZH-dc6_PPa-15Epjkbp9CfyNVFXnmNyTSJwryba0o6CHSvDkU4byKXk-ljjbGAMPch_STOxo6cgebk5vWxdYew/s1019/timer+block.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;829&quot; data-original-width=&quot;1019&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGWSAD47MdtV7JxWqGtHW-WAwRRNPflPw0OucizxiuJo2PfqmFp7ON3ZH-dc6_PPa-15Epjkbp9CfyNVFXnmNyTSJwryba0o6CHSvDkU4byKXk-ljjbGAMPch_STOxo6cgebk5vWxdYew/s16000/timer+block.png&quot; title=&quot;page 744 of RM0385 reference manual&quot; /&gt;&lt;/a&gt;&lt;/div&gt;In ARM controller timer peripheral is OFF by default and needs to be turned ON. This is done by enabling clock using the &lt;b&gt;RCC register&lt;/b&gt;.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;To enable Clock for timer 2. We set &lt;b&gt;TIM2EN&lt;/b&gt; bit from &lt;b&gt;APB1ENR&lt;/b&gt; register of &lt;b&gt;RCC registers&lt;/b&gt;.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;Timer will not start without giving clock to its block. To enable clock for timer 2, we need to set last bit of APB1ENR. APB1ENR is a peripheral clock enable register.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEino0bNX4FRk1D7L4dGfudLFH3u5MthkOh63uo1dzSfHafM1RRapM7dn4OHFN2XDjelP3LFVYW_3qTE39teLimeBxguoOP1o_qOVOa1JvBHKwuEJbo1pAqmxV7o_MIMxuoNkyrAl_ItUww/s847/apb1enr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;693&quot; data-original-width=&quot;847&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEino0bNX4FRk1D7L4dGfudLFH3u5MthkOh63uo1dzSfHafM1RRapM7dn4OHFN2XDjelP3LFVYW_3qTE39teLimeBxguoOP1o_qOVOa1JvBHKwuEJbo1pAqmxV7o_MIMxuoNkyrAl_ItUww/s16000/apb1enr.png&quot; title=&quot;Location of TIM2EN bit in APB1ENR register (Page 166 of RM0385)&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;RCC-&amp;gt;APB1ENR = RCC-&amp;gt;APBENR | 1;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;or&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;RCC-&amp;gt; APB1ENR| = 1;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;(Very imp: We have to do binary OR for APBENR since it also enables other peripherals.)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;RCC-APB1ENR = 1; // unacceptable&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Now 16MHz clock is now connected to timer block and it will start consuming little extra current then usual. Lets initialize Timer 2 block parameters.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Now to only perform delay operation we only need to focus on few registers of timer 2. Lets not study all.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Important registers are mentioned below:&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;CR1&lt;/b&gt; - Timer 2 control register 1&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;CR2&lt;/b&gt; - Timer 2 control register 2&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;CNT&lt;/b&gt; - Timer 2 counter register&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;PSC &lt;/b&gt;- Timer 2 pre-scalar&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;ARR&lt;/b&gt; - Timer 2 auto reload register&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;DIER&lt;/b&gt; - Timer 2 DMA/ Interrupt enable register&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;SR&lt;/b&gt; - Timer 2 status register&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;First we reset both control registers to disable timer operation. This helps to reset previous settings incase you want to re-initialize the timer.&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;We always have to reset the count register because it has to start from 0 at first time to get correct delay.&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Then we reduce the clock further to even lesser frequency. This is because CPU is meant for Fast processing and clock has to be fast. But peripherals cannot be fast, they interact with outside world directly or indirectly.&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Most peripherals work at 1/2 the rate of CPU clock frequency. For example purposes I&#39;ve selected 255 as pre-scalar. You can choose anyone.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;CR1 = 0;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;CR2 = 0;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Then we reset the counter value so it starts counting from 0 on startup.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;CNT=0;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Now the important part. The counting frequency is adjusted using pre-scalar. Pre-scalar is a 16bit number that is from &lt;b&gt;0 ~ 65535&lt;/b&gt; or &lt;b&gt;0x0000 ~ 0xFFFF&lt;/b&gt;.&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The formula for calculating counting frequency is given below:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrLNjxrj8Xuqksi8LCdnC56XrIvYa4anS15OMS57m84kvGKTPfJU4Btv-GAdCUYpzoqa6WPhCJqEOeiRCgGds-t7tZmpH_YsZx32kY4mJnU1XTMMEuL4jY1tQ_OpdbzO3jxRdvpObvOSQ/s166/prescalar.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;64&quot; data-original-width=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrLNjxrj8Xuqksi8LCdnC56XrIvYa4anS15OMS57m84kvGKTPfJU4Btv-GAdCUYpzoqa6WPhCJqEOeiRCgGds-t7tZmpH_YsZx32kY4mJnU1XTMMEuL4jY1tQ_OpdbzO3jxRdvpObvOSQ/s16000/prescalar.png&quot; title=&quot;page 805 of RM0385&quot; /&gt;&lt;/a&gt;&lt;/div&gt;To select right frequency depends on what kind of timer you are building, if its very long delay timer the pre-scalar will be bigger number, in our case we are designing a standard milli second timer so lets choose randomly pre-scalar to 255 which is 0xFF in hex format. Any format is acceptable.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;TIM2-&amp;gt;PSC=0xFF;&lt;/b&gt; //Acceptable&lt;/div&gt;&lt;div&gt;&lt;b&gt;TIM2-&amp;gt;PSC=255;&lt;/b&gt; //Acceptable&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;(Please note you can choose any number you want for test, the count match interrupt will only happen if we match ARR register to get certain time in milli seconds or in seconds.)&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;Once pre-scalar is chosen we can easily calculate frequency at which timer will operate with above formula. Once we find out clock frequency of timer, we multiply it with minimum delay we prefer, in this case 1 milli seconds which is 0.001 second. Multiplying my least count which is 0.001 second to timer clock frequency we get reload value which we need to put inside ARR which is Auto Reload Register.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;So Fclk = 16Mhz i.e. 16000000&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;pre-scalar = 255&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;then &lt;b&gt;Fc = 16000000/(255+1) = 62500Hz&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;Tc = 1/62500 = 16 micro seconds.&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;That means for every 16 micro seconds timer count will go up by one.&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If we want to make a 1milli second delay then our reload value will be???&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;reload value = FC x delay in sec.&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If we want 1milli second as delay then&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;reload value = 62500 x 0.001 = 62.5&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Since reload value can only be integer and not float rounding up will give us 63. Therefore&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;reload value (ARR) = 63&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;ARR = 63; &lt;/b&gt;//acceptable&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;ARR = 0x3F; &lt;/b&gt;//acceptable&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;We want to create an event or an interrupt whenever timer counter CNT reaches value equal to ARR register value which is 63 in this case. And to do this there are 2 steps.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;Step 1 is to set UIE bit in DIER register, which will enable flag whenever timer counter reaches reload value.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;b&gt;Step 2 is to enable nested vector interrupt for timer 2 in NVIC (Nested Vector Interrupt Controller) which manages all interrupts of peripherals and CPU in priority order.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;So our timer values are in place, lets work on interrupt side of things. To create an interrupt on match we need to enable update interrupt in DIER register.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvS2HLlauxXoS-BBC-E9wpbTetUJdQsOOhd_-UMvj_oS3TcRBayLXuqJKhnSzzmciT7pykSdKDr06gZqQCm9BlR6d2goE5TH1IsEDa41sdbD3TBxjHEfCEAAEC1aLUREDcyeULiNdKtGU/s1161/DIER.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;291&quot; data-original-width=&quot;1161&quot; height=&quot;160&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvS2HLlauxXoS-BBC-E9wpbTetUJdQsOOhd_-UMvj_oS3TcRBayLXuqJKhnSzzmciT7pykSdKDr06gZqQCm9BlR6d2goE5TH1IsEDa41sdbD3TBxjHEfCEAAEC1aLUREDcyeULiNdKtGU/w640-h160/DIER.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;TIM2-&amp;gt;DIER=0x0001;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;But again enabling interrupt isn&#39;t sufficient in ARM controller as the interrupt controller for timer 2 is OFF. to enable this we need to go into NVIC (Nested Vector Interrupt Controller). In NVIC, there is SET and RESET registers to enable and disable interrupts.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;NVIC-&amp;gt;ISER&lt;/b&gt; - Enables vector interrupts (array of 32bit number)&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;NVIC-&amp;gt;ICER&lt;/b&gt; - Disables vector interrupts (array of 32bit number)&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;To set interrupt we need to find position of timer 2 interrupt w.r.t. acronym. Please check below:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWujIAHjHbD5mgiUzV6kg_mlTIi_8zvQwLx4lrH57Mfxrya3NJner_xrIQio4Qnr0gjLfOqsQ6X9rkCDXTjmbYTbM327cLCuoUtmuD1xyS46FVVBsl-aLHXjF2ZfXaJb4n3REQZnRDWbw/s1221/nvictable.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;576&quot; data-original-width=&quot;1221&quot; height=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWujIAHjHbD5mgiUzV6kg_mlTIi_8zvQwLx4lrH57Mfxrya3NJner_xrIQio4Qnr0gjLfOqsQ6X9rkCDXTjmbYTbM327cLCuoUtmuD1xyS46FVVBsl-aLHXjF2ZfXaJb4n3REQZnRDWbw/w640-h302/nvictable.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;Since TIM2 interrupt is on position 28, it means its in array location 0 i.e. ISER[0]. Any number after 31 will be in ISER[1]. (!!!VERY IMPORTANT!!!)&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicgcmInYrllBM8y1prHvDOxqVvphREtW46Ni-wBQorKrvKdVHY-CFULrP7p9pGfASFp3sUoPRYhrz_R52lIJ_J1mK-lQGloZ8bJkQZfRNDnqnY5Y5owqrShk_itRXr47hptAYYfbXzAq4/s1166/nvictable2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;780&quot; data-original-width=&quot;1166&quot; height=&quot;428&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicgcmInYrllBM8y1prHvDOxqVvphREtW46Ni-wBQorKrvKdVHY-CFULrP7p9pGfASFp3sUoPRYhrz_R52lIJ_J1mK-lQGloZ8bJkQZfRNDnqnY5Y5owqrShk_itRXr47hptAYYfbXzAq4/w640-h428/nvictable2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;So we set&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;NVIC-&amp;gt;ISER[0] = NVIC-&amp;gt;ISER[0] | (1&amp;lt;&amp;lt;28);&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;or&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;NVIC-&amp;gt;ISER[0]|=(1&amp;lt;&amp;lt;28);&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;We need to binary OR NVIC-ISER[0] with new value because we do not want to disturb other set bits in this register.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;NVIC-&amp;gt;ISER[0]=(1&amp;lt;&amp;lt;28);&amp;nbsp; &amp;nbsp; &amp;nbsp;// Un-acceptable&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;So now our timer is ready for operation so lets turn ON the timer.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib-Jw6G1g4urjE4qEARQxC7d3x9bapxySi3YteJttb7P0xT9s9rVgY0wB_5qypqy0cuHvufzIqUVenxehraX3d-4N3f4srVdQtd5i-pG5iXolCVwkhMGLDVcfR98EPm5vOp27waTM9M7c/s1165/CR1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;272&quot; data-original-width=&quot;1165&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib-Jw6G1g4urjE4qEARQxC7d3x9bapxySi3YteJttb7P0xT9s9rVgY0wB_5qypqy0cuHvufzIqUVenxehraX3d-4N3f4srVdQtd5i-pG5iXolCVwkhMGLDVcfR98EPm5vOp27waTM9M7c/w640-h150/CR1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Once all above registers are set we only need to set control register CR1 last bit to turn on the actual timer functionality. Once you set this bit in CR1 , the interrupts will start happening every 1 milli second.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div&gt;So timer 2 control register 1 becomes&lt;/div&gt;&lt;div&gt;&lt;b&gt;TIM2 -&amp;gt;CR1 = 1;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To sum up, the code will look like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;RCC-&amp;gt;AHB1ENR|=1; //Enable timer 2&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;CR1=0;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//reset control register 1 to 0&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;CR2=0;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//reset control register 2 to 0&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;CNT=0; //set counter to 0&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;PSC=0xff;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//prescalar f/256 = 62500hz&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;ARR=63; //1ms&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;DIER=0x1;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//Update Interrupt Enabled&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;NVIC-&amp;gt;ISER[0]|=(1&amp;lt;&amp;lt;28); //T2 interrupt enable&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;TIM2-&amp;gt;CR1=1;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//enable timer2&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;STEP3: Creating universal delay function&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Now when timer interrupt happens, the ARM controller will call for interrupt service routine function. This is already predefined with vector functions which were created. Check below to find one:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzESY346og7hGsyKDC2NzvMp510dT_OFOM_cWHHdkmtlOkKw1N02-hVLJmT55dNNSW8obRwVUdXZJFgQ_HsD2_HKo7zDdm36dGd9_rYYdwUcuKGfV4mHzkHqXtfw0O-JoFN1nuHWw7ibE/s917/isr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;338&quot; data-original-width=&quot;917&quot; height=&quot;236&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzESY346og7hGsyKDC2NzvMp510dT_OFOM_cWHHdkmtlOkKw1N02-hVLJmT55dNNSW8obRwVUdXZJFgQ_HsD2_HKo7zDdm36dGd9_rYYdwUcuKGfV4mHzkHqXtfw0O-JoFN1nuHWw7ibE/w640-h236/isr.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;startup_stm32f746xx.s &lt;/b&gt;contains all vector handlers for other peripherals too which you can explore here.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;When interrupt happens for timer 2, it will jump to TIM2_IRQHandler function. Whenever timer interrupt happens UIF (Update Interrupt Flag ) in SR (Status Register of Timer 2) becomes 1. &lt;/span&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;The next timer interrupt will happen immediately&amp;nbsp;even before 1 milli second if you do not clear the UIF Flag inside IRQHandler function. &lt;/span&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;The UIF flag needs to be cleared every time the timer interrupt happens.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need to use the below function in our main c file for timer 2 interrupt handling.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;void TIM2_IRQHandler(void)&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;{&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;&lt;/b&gt; //this function is called every 1ms&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; //your code here&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; //clear timer flag here&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;}&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Timer update interrupt flag becomes 1 when interrupt occurs indicating there was an interrupt. But when it sets to one, it needs to be cleared else the interrupt will occur continuously and the system will get hanged. This flag is available in SR (&lt;b&gt;Status Register&lt;/b&gt;) which you can see below:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFjKTu-UJnuK-vti6dMUmAZ8azARxOCg7EhevuGVp8dmRxLDUmmN9ejKwT_mi1ksGjpt2MCtGsZmHdcyh3KuobmxwSYU0wIaSfy6RlSZZvhcHcX16GlLs05oHqEgqeMVf5rsnYNoGaywY/s940/status+register.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;220&quot; data-original-width=&quot;940&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFjKTu-UJnuK-vti6dMUmAZ8azARxOCg7EhevuGVp8dmRxLDUmmN9ejKwT_mi1ksGjpt2MCtGsZmHdcyh3KuobmxwSYU0wIaSfy6RlSZZvhcHcX16GlLs05oHqEgqeMVf5rsnYNoGaywY/w640-h150/status+register.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;If you are not using any other features of this timer then you can directly set as below:&lt;/div&gt;&lt;div&gt;&lt;b&gt;TIM2-&amp;gt;SR =0;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;If you are using other features then you need to clear only UIF as show below.&lt;/div&gt;&lt;div&gt;&lt;b&gt;TIM2-&amp;gt;SR&amp;amp;= ~(1);&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need to reset only the last bit of SR register. This is possible by using AND logic and Negating the buffer. Negating 1 gives 0xFFFE and if we AND with TIM2-&amp;gt;SR it will keep all other bits unchanged accept bit 0 to 0. And the simplest way to write that is above.&lt;/div&gt;&lt;div&gt;So our timer ISR routine will look as below:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;void TIM2_IRQHandler(void){&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;span style=&quot;color: #990000;&quot;&gt; &amp;nbsp;//This function is called every 1ms&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; //your code here&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;TIM2-&amp;gt;SR&amp;amp;=~(1);&lt;/b&gt; // clear update interrupt&amp;nbsp;flag&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;But our task isn&#39;t over yet. We need to create delay function.&lt;/div&gt;&lt;div&gt;We know that this ISR will be called every 1 milli second. So now instead of creating &lt;span style=&quot;color: #0b5394;&quot;&gt;for loop&lt;/span&gt; delays we need to work with while logic and decrement the delay value using the ISR routine.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets create a variable called &lt;b&gt;delay&lt;/b&gt;. Lets initialize it with size of 32bit.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;uint32_t delay=0;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s define a function which will set this delay variable independently. Example&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void delayms( uint32_t n){&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;delay=n;&lt;/span&gt;&lt;/b&gt;&lt;span&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt; &amp;nbsp; //we set delay variable here with n value&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;b&gt; &lt;span style=&quot;color: #990000;&quot;&gt;while(delay);&lt;/span&gt;&lt;/b&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp;&lt;/span&gt; &amp;nbsp; //we wait till delay becomes zero to exit while loop.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The concept of old for loops and while delay is similar accept here the decrementing happens outside the function independently and precisely.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets modify the ISR to decrement &lt;b&gt;delayms &lt;/b&gt;variable to 0. But once it goes to 0, we don&#39;t want to decrement further and that goes like this below:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;void TIM2_IRQHandler(void){&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp;&amp;nbsp;//This function is called every 1ms&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; if(delay &amp;gt; 0){&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//decrements only if number is greater then 0&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; delay--;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//decrements every 1 milli second&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;b&gt;TIM2-&amp;gt;SR&amp;amp;=~(1);&lt;/b&gt;&amp;nbsp;// clear update interrupt&amp;nbsp;flag&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;So this function concludes step 4. Its time for next step that is testing. How do we test if the timer is proper? For this lets do step 5.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;STEP5: Initializing GPIO for LED blinking and testing our delay function.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My previous tutorial explains wonderfully how GPIO can be programmed for digital output. Please do visit.&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://embeddedlifehelp.blogspot.com/2016/11/nucleo-f746zg-basic-programming-using.html&quot;&gt;Basic programming with Nucleo&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Our target LED is LD2 which is on nucleo F746ZG board. If you check user manual for nucleo board there is schematic given on page 75 of nucleo 144 manual.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghysYSjkE0dyOeChZeQlqwSFkeL0st3N8pQGR8mGg-ER6eKmifFuKlqxDbBnFFsgN6KERre3T3GOIMX-mE7qWHbTsdbc-BhXYoeThz7W2i9OXZVpv47lWbtEXKJEaS43V112Q6xjto0Dg/s999/ledpin.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;601&quot; data-original-width=&quot;999&quot; height=&quot;386&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghysYSjkE0dyOeChZeQlqwSFkeL0st3N8pQGR8mGg-ER6eKmifFuKlqxDbBnFFsgN6KERre3T3GOIMX-mE7qWHbTsdbc-BhXYoeThz7W2i9OXZVpv47lWbtEXKJEaS43V112Q6xjto0Dg/w640-h386/ledpin.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The schematic shows LD2 LED which is blue in color is connected to GPIO PB7.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;To initialize GPIO we do the process below:&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;b style=&quot;color: #b45f06;&quot;&gt;RCC-&amp;gt;AHB1ENR=0x00000002; &lt;/b&gt;//Enable peripheral clock to GPIOB Port&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;b style=&quot;color: #b45f06;&quot;&gt;GPIOB-&amp;gt;MODER=0x00004000; &lt;/b&gt;//Set PB7 pin as output. LED (LD2 is on PB7)&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;b style=&quot;color: #b45f06;&quot;&gt;GPIOB-&amp;gt;OTYPER=0x00000000; &lt;/b&gt;//Set output pin as push pull type&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: #b45f06; font-weight: bold;&quot;&gt;GPIOB-&amp;gt;OSPEEDR=0x00004000; &lt;/span&gt;//set output speed as medium speed&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now lets write the code as a whole.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&quot;stm32f7xx.h&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;volatile&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt; uint32_t &lt;/span&gt;delay=0;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt; &lt;b&gt;delay_init&lt;/b&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;void&lt;/span&gt; &lt;/b&gt;&lt;b&gt;delayms&lt;/b&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;uint32_t &lt;/span&gt;n);&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;int&lt;/span&gt; &lt;/b&gt;&lt;b&gt;main&lt;/b&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;void&lt;/span&gt;){&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;SystemInit();&lt;span style=&quot;color: #38761d;&quot;&gt; //SystemInit initializes clock at 16000000Hz&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;RCC-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;AHB1ENR&lt;/span&gt;=0x00000002;&lt;span style=&quot;color: #38761d;&quot;&gt; //Enable peripheral clock to GPIOB Port&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;GPIOB-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;MODER&lt;/span&gt;=0x00004000;&lt;span style=&quot;color: #38761d;&quot;&gt; //Set PB7 pin as output. Blue LED (LD2 is on PB7)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;GPIOB-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;OTYPER&lt;/span&gt;=0x00000000;&lt;span style=&quot;color: #38761d;&quot;&gt; //Set output pin as push pull type&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;GPIOB-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;OSPEEDR&lt;/span&gt;=0x00004000;&lt;span style=&quot;color: #38761d;&quot;&gt; //set output speed as medium speed&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&amp;nbsp;delay_init();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;/* Infinite loop */&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;while&lt;/b&gt; &lt;/span&gt;(1){&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;			&lt;/span&gt;GPIOB-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;ODR&lt;/span&gt;=0x00000080;&lt;span style=&quot;color: #38761d;&quot;&gt; //Set PB7 bit high using ODR register&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;			&lt;/span&gt;delayms(100);&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;			&lt;/span&gt;GPIOB-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;ODR&lt;/span&gt;=0x00000000; &lt;span style=&quot;color: #38761d;&quot;&gt;//Set PB7 bit high using ODR register&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;			&lt;/span&gt;delayms(100);&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;return&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt; &lt;/span&gt;0;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void&lt;/b&gt; &lt;/span&gt;&lt;b&gt;delay_init&lt;/b&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;){&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;RCC-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;APB1ENR&lt;/span&gt;|=1; &lt;span style=&quot;color: #38761d;&quot;&gt;//enable peripheral clock to timer 2&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;CR1&lt;/span&gt;=0;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//reset control register 1 to 0&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;CR2&lt;/span&gt;=0;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//reset control register 2 to 0&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;CNT&lt;/span&gt;=0;&lt;span style=&quot;color: #38761d;&quot;&gt; //set counter to 0&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;PSC&lt;/span&gt;=0xFF;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//prescalar f/256 = 62500hz&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;ARR&lt;/span&gt;=63;&lt;span style=&quot;color: #38761d;&quot;&gt; //1ms&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;DIER&lt;/span&gt;=0x1;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//Update Interrupt Enabled&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;NVIC-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;ISER&lt;/span&gt;[0]|=(1&amp;lt;&amp;lt;28);&lt;span style=&quot;color: #38761d;&quot;&gt; //T2 interrupt enable&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;CR1&lt;/span&gt;=0x01;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//enable timer2&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void&lt;/b&gt; &lt;/span&gt;&lt;b&gt;TIM2_IRQHandler&lt;/b&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;){&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;TIM2-&amp;gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;SR&lt;/span&gt;&amp;amp;=~(1);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;if&lt;/span&gt;&lt;span&gt;(delay&amp;gt;0)delay--;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #38761d; font-weight: 400; white-space: pre;&quot;&gt;&lt;b&gt;	&lt;/b&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d; font-weight: 400;&quot;&gt;//decrement every 1 ms if delay is greater than zero&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;void &lt;/b&gt;&lt;/span&gt;&lt;b&gt;delayms&lt;/b&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt; &lt;/span&gt;n){&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//simple delayms function&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color: #38761d; white-space: pre;&quot;&gt;	&lt;/span&gt;delay=n; &lt;span style=&quot;color: #38761d;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;/&lt;span&gt;we set delay variable here with n value&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;while&lt;/b&gt;&lt;/span&gt;(delay); &lt;span style=&quot;color: #38761d;&quot;&gt;//we wait till delay variable becomes zero , then exit&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Lets compile and upload the same using debug button.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc94YZvzyuHDOa166SaL0qbRyzeOW0DZB5KfuE5C7s6SnK3Uo2QLE8pV2OSLuOvKcCflryOGXWuenS1b8cWqmX-vrI2aXH6B-ODhegtUYAw-L6VaUh6TlKSdyxNvqaSEMnzZmh1VWAtZM/s572/debug.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;501&quot; data-original-width=&quot;572&quot; height=&quot;560&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc94YZvzyuHDOa166SaL0qbRyzeOW0DZB5KfuE5C7s6SnK3Uo2QLE8pV2OSLuOvKcCflryOGXWuenS1b8cWqmX-vrI2aXH6B-ODhegtUYAw-L6VaUh6TlKSdyxNvqaSEMnzZmh1VWAtZM/w640-h560/debug.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;If you do not know how to set a debugger in action. please read this link below:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a href=&quot;https://embeddedlifehelp.blogspot.com/2016/11/nucleo-f746zg-basic-programming-using.html&quot;&gt;Basic programming with Nucleo&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once the debug is enabled, debugger will program the new code into STM32F746ZG and the blinking will happen immediately.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I&#39;ve then used Digital Storage Oscilloscope to see if delay is proper. And here are the results below:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikAQbw8nyIsfYWxTEJzLtj-VGFwYRy0YzyxA5yMOuLVk9cXosbjz1Z8NKEy601nGiT7E_8sz4KyohyphenhyphenwiXYNuJyzqyN1Z_HkhKeFE4oKvRhtITxq8SuKVjFkDqLvoSax8_jIVw_-uUl-YM/s4080/P_20201119_082751.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2518&quot; data-original-width=&quot;4080&quot; height=&quot;394&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikAQbw8nyIsfYWxTEJzLtj-VGFwYRy0YzyxA5yMOuLVk9cXosbjz1Z8NKEy601nGiT7E_8sz4KyohyphenhyphenwiXYNuJyzqyN1Z_HkhKeFE4oKvRhtITxq8SuKVjFkDqLvoSax8_jIVw_-uUl-YM/w640-h394/P_20201119_082751.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;As you can see the delay is perfectly 100ms as expected. But is it?&lt;/b&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;If you notice carefully there is few microseconds delay added up. Why is that? Lets analyze further.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;As per old calculations of Auto Reload register,&lt;/div&gt;&lt;div&gt;&lt;b&gt;(ARR) reload value = 62500 x 0.001 = &lt;span style=&quot;color: red;&quot;&gt;62.5&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1 milli seconds is perfectly achieved at 62.5 but we cannot put float value in ARR. We can only put integer value. Since we chose by rounding up 62.5 to 63. I decided to use Logic analyzer to analyze timing even further.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I modified the code to blink LED 1ms ON and 1ms OFF using delay routine I created and below is the timing plotted by logic analyzer.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjr9Wk0uu5jpziYcAW16_QJvQ0Z8T9dE_6OUV3Ra21CQrMIDNCxvdrKTAL_a8kzriQK7Ey4tdw6ehZm2qN-kM1c9XJGk4L5UbttPkok6mR8FX8l-wUTMOoE0k-XL-FuZVkoo897E09fME/s1920/pulseanalysis1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;580&quot; data-original-width=&quot;1920&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjr9Wk0uu5jpziYcAW16_QJvQ0Z8T9dE_6OUV3Ra21CQrMIDNCxvdrKTAL_a8kzriQK7Ey4tdw6ehZm2qN-kM1c9XJGk4L5UbttPkok6mR8FX8l-wUTMOoE0k-XL-FuZVkoo897E09fME/s16000/pulseanalysis1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;As you can see the timing is showing 2.032ms for blinking period. So 1ms delay is actually now 1.016ms and the reason was round up.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What if we round down??&lt;/div&gt;&lt;div&gt;What if we put ARR = 62. Lets check this with logic analyzer. Lets see if this plot is accurate.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxAS0SofTeykEARl6pzGE7rDhN7_8HBVw1-ntoVu3J6vZmX39Dm8I32cpsl2YTD5Bv7jRHeisHJmQvnS5XDHnsU4CSg_oNsDM07SZL-3TL527ZS_aDysA6cduRfajf39TMhp_m4I6rnic/s1920/pulseanalysis2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;588&quot; data-original-width=&quot;1920&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxAS0SofTeykEARl6pzGE7rDhN7_8HBVw1-ntoVu3J6vZmX39Dm8I32cpsl2YTD5Bv7jRHeisHJmQvnS5XDHnsU4CSg_oNsDM07SZL-3TL527ZS_aDysA6cduRfajf39TMhp_m4I6rnic/s16000/pulseanalysis2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Woooooow!!!!!!! Right?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The period is exactly close to 2.002ms. That means 1ms is now become 1.001ms which is very good compared to which we set before. So deciding which ARR value gives precise 1ms is only possible by doing multiple test via Digital Storage Oscilloscope or Logic Analyzer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;This is a nice example how we should test our delay routines using different methods for accuracy after coding is done.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can make use of this function now to customize the delays for external chip communication via i2c and rs485 bus, bit banging drivers etc.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Congratulations! &lt;/b&gt;You have finally understood how delay function can be implemented for STM32F746ZG Nucleo development board. You can modify the same for implementing in seconds.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The reason I&#39;ve not explained you to create delays in micro and nano seconds is because the interrupts have tendency to disturb other processes. Since this device is working at 16MHz making a micro second delay may cause lags in other parts of the code if you&#39;re implementing this on your project.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It&#39;s better to &lt;b&gt;use for loops for micro and Nano seconds delays&lt;/b&gt; because they wont hang other processes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;1. Successfully created timer.&lt;/div&gt;&lt;div&gt;2. Understanding the method of how to perform research on a microcontroller using help of documentation provided.&lt;/div&gt;&lt;div&gt;3. Reading and implementing on only the required peripherals and not the whole book.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you like my post, &lt;b&gt;please subscribe&lt;/b&gt; so you get the latest updates.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;ALL THE BEST!!!&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiExByjp7r6nLP7eSQKaZ1YSNldlfd2uKIQF7sUqfvmSr4gots14GINhp0zVnRkjwZeVnCIorfF06itBxnw_25hdCUTjT4mfWVkXWIF85FOorgkKQkEXH4O5mdGMRGEbNwzBsJKZnc4an0/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;194&quot; data-original-width=&quot;204&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiExByjp7r6nLP7eSQKaZ1YSNldlfd2uKIQF7sUqfvmSr4gots14GINhp0zVnRkjwZeVnCIorfF06itBxnw_25hdCUTjT4mfWVkXWIF85FOorgkKQkEXH4O5mdGMRGEbNwzBsJKZnc4an0/&quot; width=&quot;252&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/2776571397688781586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/2776571397688781586?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/2776571397688781586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/2776571397688781586'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2019/07/how-to-create-delay-function-on-stm32f.html' title='Precision delay function for Nucleo STM32F746ZG'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinEdaUJiXMLv_uO1VV13bhuRQR5pL3o1nVC47b7ZhcQn36wP6Ot6ZXmdjpn4T-apz2Io7LX1oqGMatjVAZ2uuASFrcO7qHM5myYWIXCl2DtZ1mn6PUiONwnuVdoihitEaLOQW8R9gz2Dc/s72-w640-h480-c/cover.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-1011028370582761057</id><published>2016-11-13T18:09:00.001+05:30</published><updated>2020-11-22T21:01:40.375+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="1ms delay"/><category scheme="http://www.blogger.com/atom/ns#" term="32bit"/><category scheme="http://www.blogger.com/atom/ns#" term="ARM"/><category scheme="http://www.blogger.com/atom/ns#" term="basic programming"/><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="blinking"/><category scheme="http://www.blogger.com/atom/ns#" term="c programming"/><category scheme="http://www.blogger.com/atom/ns#" term="example"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><category scheme="http://www.blogger.com/atom/ns#" term="Microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="ST-LINKV2-1"/><category scheme="http://www.blogger.com/atom/ns#" term="STM32F746ZG"/><title type='text'>Nucleo - F746ZG basic programming using TrueSTUDIO 6.0 for ARM</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;AIM&lt;/span&gt;: To teach you basic programming on Nucleo - F746ZG development board using TrueSTUDIO 6.0 and c programming. Also to write a simple code for LED blinking and test it on the hardware.&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlg8PhIshjfPkHFiR6hb0ep38qLwdbn83hSG-h8p6gtjKZwoZPaEeyqXzQAow-TaKUJuACoHGNwm_fr6Tb0iRcG42uUaX8bYL9VS1leqDr5ExQwAbx3HzRJI7Hn1g2mP4LTBHb3rkftVw/s1600/P_20161112_210232.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlg8PhIshjfPkHFiR6hb0ep38qLwdbn83hSG-h8p6gtjKZwoZPaEeyqXzQAow-TaKUJuACoHGNwm_fr6Tb0iRcG42uUaX8bYL9VS1leqDr5ExQwAbx3HzRJI7Hn1g2mP4LTBHb3rkftVw/s1600/P_20161112_210232.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Things needed:&lt;/h3&gt;
&lt;div&gt;
1. STM32F746 Nucleo - 144 F746ZG development board.&lt;/div&gt;
&lt;div&gt;
2. Micro USB Cable.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Working Summary:&lt;/h3&gt;
&lt;div&gt;
Nucleo - F746ZG development board uses STMicroelectronics ARM Cortex M7 microcontroller STM32F746ZG. This development board contains onboard In - Circuit Debugger (ICD) called ST - LINK V2-1 which is used to program the microcontroller. This ICD section on development board has its own USB connector. The same ICD can be used to program other STM32F series microcontrollers. Connecting micro USB cable we can program the microcontroller with the help of PC Software. We will be using traditional c programming to program the board and turn LED ON/ OFF using IO Port settings. We will use the debugging feature to program the code and test internal registers for data we wrote. That&#39;s one good thing about ICD, yes you can see what has been written in internal registers.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To read more on Nucleo development board check this link below:&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://www.mouser.com/pdfdocs/stmicroelectronics_DM00247910.pdf&quot; target=&quot;_blank&quot;&gt;Nucleo - 144 &amp;nbsp;F746ZG Development board user manual&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLR7OCK5WT0Pug3-IvJQeB3YDdanVYEzB_E3mjdX9JTly-n0Oi5oA-GZ-AeZTkpoHnGn2uxIhiW2FhQdo6jSzi18PeFRsVOcdEpYa0Ihwfm2XP1zpNOgfWOyVaY3dGJ4WzNpnJ5rvFbRM/s1600/NUCLEOmini.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLR7OCK5WT0Pug3-IvJQeB3YDdanVYEzB_E3mjdX9JTly-n0Oi5oA-GZ-AeZTkpoHnGn2uxIhiW2FhQdo6jSzi18PeFRsVOcdEpYa0Ihwfm2XP1zpNOgfWOyVaY3dGJ4WzNpnJ5rvFbRM/s1600/NUCLEOmini.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You will need to download TrueStudio 6.0 Lite. For programming/debugging purposes lite version is good. But for using advanced features of ST-LINK for debugging pro version needs to be purchased.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://atollic.com/truestudio/&quot; target=&quot;_blank&quot;&gt;TrueStudio 6.0&lt;/a&gt;&amp;nbsp;(860MB)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Reference Documents:&lt;/h3&gt;
&lt;div&gt;
&lt;a href=&quot;http://www.st.com/en/microcontrollers/stm32f746zg.html&quot;&gt;STM32F746ZGT6 Documentation&lt;/a&gt;s&lt;br /&gt;
&lt;br /&gt;
From above link you may need to refer these documents to help you write code better.&lt;br /&gt;
&lt;b&gt;1. RM0385 Reference manual (18MB)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2.&amp;nbsp;STM32F746xx Datasheet Production Data (3.2MB)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Step by step Procedure:&lt;/b&gt;&lt;/h3&gt;
&lt;b&gt;1. &lt;/b&gt;When starting Nucleo for the first time. There&#39;s demo code which blinks LED&#39;s with different speed and changing LED based on user Switch. So when you connect micro USB cable to the PC. This code will start executing and USB drivers will be getting installed automatically. If you do not see any LED blinking, check for&lt;b&gt; Power LED&lt;/b&gt; which is &lt;span style=&quot;color: lime;&quot;&gt;&lt;b&gt;Green&lt;/b&gt;&lt;/span&gt;. You do not need to worry about this at all. But if you want to check if the drivers are installed properly you need to go to Device Manager and check for STLINK Virtual COM Port. You can go to Device Manager by clicking on Start button and type in search bar for device manager. Device manager Shown below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiphm5UKeXE-ZcVhaYMkc2a05PT2HHP4NYupZKi5qVEbcfFQAP04kQ9Hru38yWTA1J1x3IHH3bYeHZq7rh5KiLZAc81I3tCcSoiqW29Ut2hWzmx_XqaVh0YpB0MbFx9hxzXXfMrAUgfjEI/s1600/1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiphm5UKeXE-ZcVhaYMkc2a05PT2HHP4NYupZKi5qVEbcfFQAP04kQ9Hru38yWTA1J1x3IHH3bYeHZq7rh5KiLZAc81I3tCcSoiqW29Ut2hWzmx_XqaVh0YpB0MbFx9hxzXXfMrAUgfjEI/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
2. Now open &lt;b&gt;Atollic TrueSTUDIO for ARM 6.0.0. &lt;/b&gt;You may be asked to upgrade to pro but you can continue using lite version after 5seconds.&lt;br /&gt;
After opening TrueSTUDIO it will look like this below. I have marked important buttons and locations for you in blue:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqXgP-Or12aqI2vmNf2D70jBnscqnuwGuYfv9e9dXZihm_z_VD1DnltxjhyhzwP1B53zDSMI2lO8NArzI4bVmpdeKAqNyh2jYCHDGfA7BeuETBvAOdxGFhRuVcBGQPYiW6IHqmqZHHmbY/s1600/2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqXgP-Or12aqI2vmNf2D70jBnscqnuwGuYfv9e9dXZihm_z_VD1DnltxjhyhzwP1B53zDSMI2lO8NArzI4bVmpdeKAqNyh2jYCHDGfA7BeuETBvAOdxGFhRuVcBGQPYiW6IHqmqZHHmbY/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. &lt;/b&gt;In menu, click on File, then new, and select c project. My workspace is in D drive. Select the following items below as you will need these settings to run c code on Nucleo.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGuW_zXJVlAbkJhDgb7aU0et5BmNgwPyssQ661tMLSej4qRT7-aO8KONZddDyPqyXrjJL8nEmlrv5qwJdlg6kf_ReUWk2PF_ZFlgMe2ByNefJcuhNDksJtbxglZmvj5W4v_uEVNnzW9Ac/s1600/3.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGuW_zXJVlAbkJhDgb7aU0et5BmNgwPyssQ661tMLSej4qRT7-aO8KONZddDyPqyXrjJL8nEmlrv5qwJdlg6kf_ReUWk2PF_ZFlgMe2ByNefJcuhNDksJtbxglZmvj5W4v_uEVNnzW9Ac/s1600/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4.&lt;/b&gt; Now after clicking next, you will see hardware settings screen. You need to select you appropriate target microcontroller and evaluation board. In our case, it is STM32F746ZG.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ3gkK7oYEb6NZMHAWLhXmbZEjbPGipSUigdo7xzpyXtfhyphenhyphen6TvG7lXXDcxTvibkKMoUjLmEpLcZRsK19OWwCydTF1q7XDJ77Q6mMxFNBSeQhMhVN-tAxPy5bSU0B5NmeZ1fvDX_0ShJIw/s1600/4.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ3gkK7oYEb6NZMHAWLhXmbZEjbPGipSUigdo7xzpyXtfhyphenhyphen6TvG7lXXDcxTvibkKMoUjLmEpLcZRsK19OWwCydTF1q7XDJ77Q6mMxFNBSeQhMhVN-tAxPy5bSU0B5NmeZ1fvDX_0ShJIw/s1600/4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5&lt;/b&gt;. On clicking next, comes software settings. This is already done for you by software. But these were the settings I was using below:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwgzgGZDp1zXlYCUDtd84iVJEyHUjIaJJbS2Be2EFoCelj8did0X3UvSqDbTpIkFR5X5KBFydK8ns3aFdSsGFuO1m-r3CM8CpzPyV3Tuhhx4oL5dsFjhDGyhVfbCMQl66ORbKKrlz65dQ/s1600/5.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwgzgGZDp1zXlYCUDtd84iVJEyHUjIaJJbS2Be2EFoCelj8did0X3UvSqDbTpIkFR5X5KBFydK8ns3aFdSsGFuO1m-r3CM8CpzPyV3Tuhhx4oL5dsFjhDGyhVfbCMQl66ORbKKrlz65dQ/s1600/5.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;6. &lt;/b&gt;Clicking next comes the debug settings. Here you need to select ST-LINK debugger. And finish the project setup.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWB0dAfupOL2vwkW1oniFYyxRJVLaGQ2srzRPtbk90iO9jPc7kZtCMwm97ohuNuWs0Y6TrQ8L9a28Yo_aWTHroEH4WL2w8ElikwqcFem3ub0zY-XC2i0JreK42fmu6RCRQMXWSmVjiocc/s1600/6.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWB0dAfupOL2vwkW1oniFYyxRJVLaGQ2srzRPtbk90iO9jPc7kZtCMwm97ohuNuWs0Y6TrQ8L9a28Yo_aWTHroEH4WL2w8ElikwqcFem3ub0zY-XC2i0JreK42fmu6RCRQMXWSmVjiocc/s1600/6.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7&lt;/b&gt;. You will now see project opened and main.c opened. Default code will be present inside main.c as default template.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgynZ17-kzsfrgwK_nvm0nrXtB-7DgQqzMyst5haLgG2XF8jEZgCxOtsinW2uk2anwVf5P66u4xshRWwEHrX0vLGFepzqOLlLAD6lFjxG8kk-JCYVHDRNujyegKMI88QVyyKMKgySpj2FE/s1600/7.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgynZ17-kzsfrgwK_nvm0nrXtB-7DgQqzMyst5haLgG2XF8jEZgCxOtsinW2uk2anwVf5P66u4xshRWwEHrX0vLGFepzqOLlLAD6lFjxG8kk-JCYVHDRNujyegKMI88QVyyKMKgySpj2FE/s1600/7.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;8.&lt;/b&gt; So let&#39;s write code to blink LED LD2.&lt;br /&gt;
To turn any GPIO ON/OFF these are following things you should know:&lt;br /&gt;
1. Enable peripheral clock.&lt;br /&gt;
2. Set the GPIO as output.&lt;br /&gt;
3. Set the GPIO as push pull mode.&lt;br /&gt;
4. Rest settings is upto the application.&lt;br /&gt;
For reading more on GPIO of ST32F746ZG. Check page 195 of RM0385 Reference manual.&lt;br /&gt;
&lt;br /&gt;
Check the code below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0X6Ld7MSM0MV_pC2Unbf97RQ2cuCkI_ji4ql1jBh3hXVKnGDjox2kgd3bZDG6Vh4fJJ5Fl0Pe3I2Ka1BxdkvuZUuG8O124qYzM3IGBNo2L8PC8CBeIctlrXia7rVwtdmv6oqAmD3757s/s1600/8.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0X6Ld7MSM0MV_pC2Unbf97RQ2cuCkI_ji4ql1jBh3hXVKnGDjox2kgd3bZDG6Vh4fJJ5Fl0Pe3I2Ka1BxdkvuZUuG8O124qYzM3IGBNo2L8PC8CBeIctlrXia7rVwtdmv6oqAmD3757s/s1600/8.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;9.&lt;/b&gt; After writing code for LED blinking. Rebuild the project by clicking rebuild button in menu.&lt;br /&gt;
If there are errors, check the code again. There should not be any errors. You can also click on console and see build process. If no errors, proceed by clicking on debug.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg60UvFBXDkQrv0_4F6iDaufPJraHJCEOO1-TocecW2xuOYlEiamcWF9zeFIWxr5_iutKClvzZ47Y3uP5ml-UDVnoGo8Zxwt_5vKQXyPHKL-dSoxC-upOLihB_62G_bjmLSYvzGaeSA7m8/s1600/9.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg60UvFBXDkQrv0_4F6iDaufPJraHJCEOO1-TocecW2xuOYlEiamcWF9zeFIWxr5_iutKClvzZ47Y3uP5ml-UDVnoGo8Zxwt_5vKQXyPHKL-dSoxC-upOLihB_62G_bjmLSYvzGaeSA7m8/s1600/9.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;10.&lt;/b&gt; After clicking on debug. For first time you will get debug configuration setting. See if all debug configurations are OK. And then click on debug.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggiZLLVXw5Ey42oiqnLzz1gQnJ8-0dRO7emzM2U63tmiqwuO4THouYoxT4qOyFb7Pmd3VBkg7w19xgD896mAF79GEppvHBthwQERHB7E3MeESa2PM8Id3BcfV9TsJMO7QvDI-eBjF9k9o/s1600/10.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggiZLLVXw5Ey42oiqnLzz1gQnJ8-0dRO7emzM2U63tmiqwuO4THouYoxT4qOyFb7Pmd3VBkg7w19xgD896mAF79GEppvHBthwQERHB7E3MeESa2PM8Id3BcfV9TsJMO7QvDI-eBjF9k9o/s1600/10.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghtoxsIX4vrF_aB-_3_wQVgodNdScoco_W7uuygg-0DOpYqDOER_Zs3EVT0uChjXbUiDnhb9ypWuOLkDXHPGiiDeVIqGMGjsoLh9qrHDPnoMFmAvdYKwp_X54VnZF6bDA_MV5st7k6yHM/s1600/11.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghtoxsIX4vrF_aB-_3_wQVgodNdScoco_W7uuygg-0DOpYqDOER_Zs3EVT0uChjXbUiDnhb9ypWuOLkDXHPGiiDeVIqGMGjsoLh9qrHDPnoMFmAvdYKwp_X54VnZF6bDA_MV5st7k6yHM/s1600/11.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;11.&lt;/b&gt; After clicking on debug, you should get this message on console. Which means STlink connected Successfully.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQFiCafPLpwhcBhFUHsOEeutWtOQNy2PgqVLx2zTrqco9qn31qrUT4NBlSqqC_4sJAIEPl_-KXWk1v3jq_1yhXv8NhPnZHJNGBb8wmnLjAZYPRPXpYkZQYHY3rqAll3xU89MH0rg9pgVc/s1600/12.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQFiCafPLpwhcBhFUHsOEeutWtOQNy2PgqVLx2zTrqco9qn31qrUT4NBlSqqC_4sJAIEPl_-KXWk1v3jq_1yhXv8NhPnZHJNGBb8wmnLjAZYPRPXpYkZQYHY3rqAll3xU89MH0rg9pgVc/s1600/12.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
else&lt;b&gt; if ST-LINK is not getting detected&lt;/b&gt;. You will get message like this.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5hYJmZQyWnGVAuGMooOeQbDGl95H8PJxEwaJNgoFWT51AytIpTCPVzHBKP8nN2apTPTt0BjGHlpLB5WI4aT5KLl5N3cILxuz-E4yZXrjegdaTe7oRBy7_rVQ3gbho47MEZStrkEr5e4I/s1600/13.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5hYJmZQyWnGVAuGMooOeQbDGl95H8PJxEwaJNgoFWT51AytIpTCPVzHBKP8nN2apTPTt0BjGHlpLB5WI4aT5KLl5N3cILxuz-E4yZXrjegdaTe7oRBy7_rVQ3gbho47MEZStrkEr5e4I/s1600/13.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;12.&lt;/b&gt; Debug view is epic in its looks. It has debug menu, shows location of program counter, internal registers that you have set, even shows assembly level language of code you have written.&lt;br /&gt;
Clicking on &lt;b&gt;RUN in debug menu &lt;/b&gt;will run the code directly. Else if you want to do step by step the click on step into button or use F5 function key.&lt;br /&gt;
&lt;br /&gt;
Sometimes you get message in console like System interrupt and code doesn&#39;t run. I was trying to repeat that error but it came only once. I think it means debugger was not ready. In that case, re-launch the debugger and it will work like charm.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNAm37dVQhMlhsHxkNwUgveGjoTVksN1I_yFkNgivSmtdOAbW1FJZQVt6MqzSmF8cW_35V6YveLW3XjFmlUWm27-N96JK3MaKHxIH05JZCnRDdeG_1V0dgknesoEe0o3g_5NpXJLVBP7E/s1600/14.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNAm37dVQhMlhsHxkNwUgveGjoTVksN1I_yFkNgivSmtdOAbW1FJZQVt6MqzSmF8cW_35V6YveLW3XjFmlUWm27-N96JK3MaKHxIH05JZCnRDdeG_1V0dgknesoEe0o3g_5NpXJLVBP7E/s1600/14.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;13. CONGRATULATIONS!!!&lt;/b&gt;&lt;br /&gt;
You have finally mastered the ARM basics. The Blue LED will be blinking now on your board. If you disconnect and turn the board ON using USB charger. Your code should be working. LED should be blinking.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dwW14QbsmL1dTYQPouO6TqVpYe9hrF4Ku5D4VXRxMwiv9IDJHUGu4l5Hwl0nIDy5kMS41qL_lQvi41jM1zg3Q&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;You can download project workspace here below:&lt;/b&gt;&lt;/h3&gt;
&lt;a href=&quot;https://drive.google.com/open?id=0Bzq0D3ZT0_ddZ3JSQUR3c21ENmc&quot;&gt;&lt;button&gt;DOWNLOAD&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Well All the best programming with Nucleo - 144 746ZG development board. It&#39;s become my favorite board out of all development boards I&#39;ve worked with. ARM Cortex M7 is very powerful processor. The features given in STM32F746ZG is capable enough for creating your own video game emulator and much more.&lt;br /&gt;
My main reason for trying this microcontroller out was because it has dedicated TFT driver and camera driver ports which helps a lot when comes to high speed processing.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Thank you Atollic TrueSTUDIO for such an amazing tool.&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Thank you STMicroelectronics for the amazing development board.&amp;nbsp;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;If you like my post, &lt;b&gt;please subscribe&lt;/b&gt; so you get the latest updates.&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
ALL THE BEST!!!&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgkFhOkjgh-pcUjPHltr-1uK8zlOpKB8m6k44eMHlIdxLpj1utR49s3zioCIMXS5n5Lm45p9ZLfUiXn7tGHchyZmCnMrNjxFgIj7-6w0rDUJV6bMZu1y8jGbZl8SFDu24ITEBgI0F6T0/s1600/a.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgkFhOkjgh-pcUjPHltr-1uK8zlOpKB8m6k44eMHlIdxLpj1utR49s3zioCIMXS5n5Lm45p9ZLfUiXn7tGHchyZmCnMrNjxFgIj7-6w0rDUJV6bMZu1y8jGbZl8SFDu24ITEBgI0F6T0/s1600/a.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/1011028370582761057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/1011028370582761057?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1011028370582761057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1011028370582761057'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2016/11/nucleo-f746zg-basic-programming-using.html' title='Nucleo - F746ZG basic programming using TrueSTUDIO 6.0 for ARM'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlg8PhIshjfPkHFiR6hb0ep38qLwdbn83hSG-h8p6gtjKZwoZPaEeyqXzQAow-TaKUJuACoHGNwm_fr6Tb0iRcG42uUaX8bYL9VS1leqDr5ExQwAbx3HzRJI7Hn1g2mP4LTBHb3rkftVw/s72-c/P_20161112_210232.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-4555675646595520598</id><published>2016-10-21T01:41:00.001+05:30</published><updated>2020-11-22T21:02:45.055+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="Arduino Due"/><category scheme="http://www.blogger.com/atom/ns#" term="atmel studio"/><category scheme="http://www.blogger.com/atom/ns#" term="ATSAM3X8E"/><category scheme="http://www.blogger.com/atom/ns#" term="basic"/><category scheme="http://www.blogger.com/atom/ns#" term="batch file"/><category scheme="http://www.blogger.com/atom/ns#" term="blinking"/><category scheme="http://www.blogger.com/atom/ns#" term="bossac.exe"/><category scheme="http://www.blogger.com/atom/ns#" term="c programming"/><category scheme="http://www.blogger.com/atom/ns#" term="CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="example"/><category scheme="http://www.blogger.com/atom/ns#" term="learning"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><category scheme="http://www.blogger.com/atom/ns#" term="SAM BA"/><title type='text'>Arduino Due programming using Atmel Studio 6</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;AIM&lt;/span&gt;: To teach you alternate way programming Arduino Due &amp;nbsp;using
Atmel Studio 6 and c programming. Also to write code for LED blinking and test it on hardware.&lt;/b&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;b&gt;(&lt;span style=&quot;color: red;&quot;&gt;NOTE&lt;/span&gt;: Concept applies for Atmel Studio 7 as well. You can also use c++ as Atmel studio supports both languages)&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisgGWhlqT-K5RWvtUjtCuEHhavOis9FUf-mVykEUpGRQdm4E0BI-mvuoVim70AhDwz8Ufec3CmkpjhliHwbuZJe2yKsHQLWukru4nKeX70p6QOTqWP8cU1zijzrmC2mJFc0MjjVTWwdvo/s1600/P_20161021_010204.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisgGWhlqT-K5RWvtUjtCuEHhavOis9FUf-mVykEUpGRQdm4E0BI-mvuoVim70AhDwz8Ufec3CmkpjhliHwbuZJe2yKsHQLWukru4nKeX70p6QOTqWP8cU1zijzrmC2mJFc0MjjVTWwdvo/s1600/P_20161021_010204.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Things needed:&lt;/b&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. Arduino Due development board.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. Micro USB cable.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Working Summary:&lt;/b&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Arduino Due uses Atmel ARM Cortex M3 microcontroller
ATSAM3X8E which has inbuilt bootloader. &lt;b&gt;Bootloader&lt;/b&gt;
is a program written inside microcontroller which helps in programming the
microcontroller Flash memory without external programmer. The term BOOT means
at startup the code from internal Flash ROM is read and stored to RAM and
executed. This booting code then checks for the programming sequence which I
will explain to you later. After programming sequence detected the device then
goes into programming mode. Once programming mode is achieved, the PC
application can be used to program the microcontroller. If programming sequence
is not given at start up, the bootloader executes code from the Flash memory
(This memory is the one we will program).&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So in Arduino DUE you have two USB ports. One is arduino
programming input atmega16u2 where you can program using arduino IDE. Second
port is native USB Port. Now ATSAM3X8E contains two methods to write program
into it which are:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. Native USB Port.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. UART Port.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;To read more in details check arduino page here:&lt;br /&gt;
&lt;a href=&quot;http://playground.arduino.cc/Bootloader/DueBootloaderExplained&quot;&gt;http://playground.arduino.cc/Bootloader/DueBootloaderExplained&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm_L9d9KjcAW8er9QFwQQi4IpYc3hvb5yMES5YiUAPCD6sCXmf6ydRP3qYszApMdFFcG9vbgBGSWlAkQSAJ9cIK-zyykGNS3jR-FrF42vlEwmVwrYnIBWq0-C2vy0-9f3svLobWPfsA9U/s1600/arduinodue_traditionalc.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm_L9d9KjcAW8er9QFwQQi4IpYc3hvb5yMES5YiUAPCD6sCXmf6ydRP3qYszApMdFFcG9vbgBGSWlAkQSAJ9cIK-zyykGNS3jR-FrF42vlEwmVwrYnIBWq0-C2vy0-9f3svLobWPfsA9U/s1600/arduinodue_traditionalc.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Arduino IDE interacts with ATMEGA16U2 microcontroller which
is preprogrammed to interface with ATSAM3X8E which then communicates with each
other through UART. Therefore the routines are designed in such a way it looks
like you are programming through Arduino IDE. But behind the scene there is
another PC software running called Bossac.exe which is designed to interface
with ATSAM3X8E bootloader code inside the microcontroller.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Since we do not want to interfere with the UART bootloader
part since its already used for booting through Arduino programming port, we
will use Native USB port. Below sections are important and marked which will be
needed for programming purposes.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So before starting all these lets download software tools to
begin with:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. &lt;a href=&quot;http://www.atmel.com/forms/software-download.aspx?target=tcm:26-41305&quot; target=&quot;_blank&quot;&gt;Atmel Studio 6&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. bossac.exe (Can be found in folder where arduino IDE
1.6.3 is installed. It is designed for Arduino Due boards) Do a search in that
folder. I found it in this location below:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;C:\Arduino15\packages\arduino\tools\bossac\1.3a-arduino\bossac.exe&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
3. batch file. (You need to create this using notepad app on
your PC) Explained in details below.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Step by Step Procedure:&lt;/b&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. To start with this tutorial first we need to erase any
program present in the memory. The procedure remains same throughout the
tutorial. That is we keep Reset Switch pressed then Press Erase Switch, then we
release Reset Switch, then we release Erase Switch. This completely erases the
internal flash memory and then goes into bootloader mode which waits for
bossac.exe interaction. Watch small video how it&#39;s done.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dwFc1XPaM76PbdB1GLquH_MU_PeJxvD6lC5AL8_K6XvG9cGpnefUKYCUJGnMEmjtnTBjtLtgy93Y0Det-0J_A&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. Open Atmel Studio 6 IDE Software on PC. Create New
project. Select GCC C Executable Project, Enter project Title and location
address. Click OK.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjubBHa1lc7Itd7pYL8kXBwqfTl9_O4r-XuqAT3xJ_PjDvW4LoM9aUCpO0RWp3WAX3n_G444sS5NLNc6MhFivpmcQJa-SWlCsNyOvkmVbvP7t0Gk0zfRc5nbDq8vGnxxKwX_rm4H3OzC5Y/s1600/1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjubBHa1lc7Itd7pYL8kXBwqfTl9_O4r-XuqAT3xJ_PjDvW4LoM9aUCpO0RWp3WAX3n_G444sS5NLNc6MhFivpmcQJa-SWlCsNyOvkmVbvP7t0Gk0zfRc5nbDq8vGnxxKwX_rm4H3OzC5Y/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
3. Select Device Family as SAM3, 32bit. Select ATSAM3X8E
microcontroller. Click OK.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8asfMGG9E2BBLmHrvYnMtLVO5OjJicJLsbbyewCJC8vcK1S2nJkKCPk5rX33JeRzqB4jivpaBbxPeGaPq0O-2KP26FdVG4sdoGHHaTN7adUXxrnLz_mhDg2TTkVv55Rf82N6ndM33v3Y/s1600/2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8asfMGG9E2BBLmHrvYnMtLVO5OjJicJLsbbyewCJC8vcK1S2nJkKCPk5rX33JeRzqB4jivpaBbxPeGaPq0O-2KP26FdVG4sdoGHHaTN7adUXxrnLz_mhDg2TTkVv55Rf82N6ndM33v3Y/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
4. You will get this screen with default code already written in main file. The main file is &lt;b&gt;duetest_ledblink.c &lt;/b&gt;here.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT8nvm-wQ65ITbK3q5hRt30nWIUEQT5YSEiLQqokYVMOVmORrnVX1w5pFoH5AMiQ_YfRGXAnXNfg_7zgLxkeBdwJJR8DAbc4lH0n9KJM6_92YdTNMXYWi-6GQqpaHiWK14eFW-lX3bHgk/s1600/3.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT8nvm-wQ65ITbK3q5hRt30nWIUEQT5YSEiLQqokYVMOVmORrnVX1w5pFoH5AMiQ_YfRGXAnXNfg_7zgLxkeBdwJJR8DAbc4lH0n9KJM6_92YdTNMXYWi-6GQqpaHiWK14eFW-lX3bHgk/s1600/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
5. &lt;b&gt;SystemInit&lt;/b&gt;()
function is already implemented in one of the arm library which configures
ATSAM3X8E to run at full swing that is &lt;b&gt;84MHz
clock frequency&lt;/b&gt;. To check this function in more details you can go into the
c file by right clicking on function SystemInit() and clicking on &lt;b&gt;goto implementation. &lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
6. To activate bossac programming tool we need to click on Tools, then External tools.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFjyQvLivj-loUJ24w5uujdVrFuBV_wXPDA7Hbb9DjZ02MYv26iml24m03bvXB-qRIO3nmEArIPgriprNhLJhvKLKeJMNbdraKhlATcfMomCIp-v-O1tJAE7yLXs0tPm61dOpxb5Bco4/s1600/4.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFjyQvLivj-loUJ24w5uujdVrFuBV_wXPDA7Hbb9DjZ02MYv26iml24m03bvXB-qRIO3nmEArIPgriprNhLJhvKLKeJMNbdraKhlATcfMomCIp-v-O1tJAE7yLXs0tPm61dOpxb5Bco4/s1600/4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
7. You need to add the following given below in the External
tools window:&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;text-align: justify; text-indent: -0.25in;&quot;&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; text-indent: -0.25in;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Enter programming tool title. I wrote Arduino
Due Programmer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-align: left; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;text-align: left; text-indent: -0.25in;&quot;&gt;Enter the batch file location. My batch file
name is &lt;/span&gt;&lt;b style=&quot;text-align: left; text-indent: -0.25in;&quot;&gt;duelink.bat &lt;/b&gt;&lt;span style=&quot;text-align: left; text-indent: -0.25in;&quot;&gt;and I stored it
into D drive. So address is very short i.e. &lt;/span&gt;&lt;b style=&quot;text-align: left; text-indent: -0.25in;&quot;&gt;D:\duelink.bat&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Apply the settings to show Arduino Due
Programmer in tools menu.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; text-indent: -0.25in;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Click on OK when done.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-align: justify; text-indent: -0.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzDULp-sCHW4EtAsJ1cQVPqc8kcbOztxxJNaV_GOt3JVEK0cOXFSskk2WTGoqF0K1h-SezBstChEZgzrS_jX3wmuxUzbfyoOJ_441Ay_hxTPqcBGz9XIgEVf1twXetKiqtrpYsJSf6Bhk/s1600/5_1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzDULp-sCHW4EtAsJ1cQVPqc8kcbOztxxJNaV_GOt3JVEK0cOXFSskk2WTGoqF0K1h-SezBstChEZgzrS_jX3wmuxUzbfyoOJ_441Ay_hxTPqcBGz9XIgEVf1twXetKiqtrpYsJSf6Bhk/s1600/5_1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-align: justify; text-indent: -0.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
8. Check
if the programmer tool is visible in tools menu.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb12ZxN4A3CXvQtxqx4mlg70ynmjS9ytBY6Ex4nRoEG5IC_c86dwEwofTsGWTqqz9NVyWqZXiiak7McgeVo0KGu4Wx-C17zymcVT1pa17xvY2j_hOMR-tcD5zh882ThF9vXGNbj90NFXM/s1600/6.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb12ZxN4A3CXvQtxqx4mlg70ynmjS9ytBY6Ex4nRoEG5IC_c86dwEwofTsGWTqqz9NVyWqZXiiak7McgeVo0KGu4Wx-C17zymcVT1pa17xvY2j_hOMR-tcD5zh882ThF9vXGNbj90NFXM/s1600/6.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
9. I have
mentioned above about the &lt;b&gt;batch file&lt;/b&gt;? &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;What the hell is that?&lt;/span&gt;&lt;/b&gt; Well batch file contains
set of commands which executes certain instructions given to the computer. We
need create a batch file &lt;b&gt;duelink.bat&lt;/b&gt;
in my case. But you can name it as per your understanding term. As I told
earlier we need to use notepad to create this file. So open notepad and type
this below:&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9QhuzJIft1i88k9dXgF1GhzeH0ub-jPR5Z_khLFYB5A8AC4fxhKFUwvS4p6jqjwz8WIvCoLCgHheyXvMaBdExBjFL_YqZvl2qhV-4yKnBP3aSfxcH-x5KDNqxNguGOiXjgEL3HMMRKXI/s1600/7.PNG&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9QhuzJIft1i88k9dXgF1GhzeH0ub-jPR5Z_khLFYB5A8AC4fxhKFUwvS4p6jqjwz8WIvCoLCgHheyXvMaBdExBjFL_YqZvl2qhV-4yKnBP3aSfxcH-x5KDNqxNguGOiXjgEL3HMMRKXI/s1600/7.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUsL2FLNEFRevojfPT4vvNqYsY_qPAelaXGfF0OsjjvGkrM1_n9RwVCMCMMhlng4-g3pb6FAMONa53m92Pm2A3UudMSAa1Mkg3_94MGbKfHrvqMaeGmVg77ieB2bZ6vinFTetD7mHvV7k/s1600/8.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUsL2FLNEFRevojfPT4vvNqYsY_qPAelaXGfF0OsjjvGkrM1_n9RwVCMCMMhlng4-g3pb6FAMONa53m92Pm2A3UudMSAa1Mkg3_94MGbKfHrvqMaeGmVg77ieB2bZ6vinFTetD7mHvV7k/s1600/8.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Since
this are commands you must be wondering what does these numbers mean. The first
line is the &lt;b&gt;MODE command&lt;/b&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mode
instruction basically sets mode of operation for devices like printers or
monitor or serial port. More detailed information below:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3wlHyiUZ195tkX1iJaL17FXPPb-4GtkwNlW0OWx2BjZE8c8G1ly2zJhNobvrBIEXph88wG0OmUe3RV72T1i1_m4Iel6lgeVrTVbEiFW4A9xPa3QM7Ixj3T0exGxnx1bCoOE7wsmeop3k/s1600/9.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3wlHyiUZ195tkX1iJaL17FXPPb-4GtkwNlW0OWx2BjZE8c8G1ly2zJhNobvrBIEXph88wG0OmUe3RV72T1i1_m4Iel6lgeVrTVbEiFW4A9xPa3QM7Ixj3T0exGxnx1bCoOE7wsmeop3k/s1600/9.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If you are still interested in learning mode here are few links:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.easydos.com/mode.html&quot;&gt;http://www.easydos.com/mode.html&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.robvanderwoude.com/mode.php&quot;&gt;http://www.robvanderwoude.com/mode.php&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The
second line contains instructions given by bossac.exe which needs information
like&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;bossac.exe location&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;which COM port to transfer&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;sequence of programming like erase, write,
verify, reset&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;location of the bin file. (executable file which
is generated after compiling the c code. In this case it is &lt;/span&gt;&lt;b style=&quot;text-indent: -0.25in;&quot;&gt;duetest_ledblink.bin&lt;/b&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: 7pt; font-stretch: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;bossac instructions can be found by using command
prompt and entering command&amp;nbsp;&lt;b style=&quot;text-indent: -0.25in;&quot;&gt;bossac.exe
-help&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
which pops the data below:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhyphenhyphenyDClLOkcl2-_ESyvVDBbaqxQDXhl6UzEFrHo01ZefErz5DWYmCNVVvW1HiitPdLL554rTFjLtk_tbDtNYOBhJ1a8t6WqwuBmw9XvCbiTKC0q3izKAHYybk1eZW05D8Um0DhDsKEndc/s1600/10.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhyphenhyphenyDClLOkcl2-_ESyvVDBbaqxQDXhl6UzEFrHo01ZefErz5DWYmCNVVvW1HiitPdLL554rTFjLtk_tbDtNYOBhJ1a8t6WqwuBmw9XvCbiTKC0q3izKAHYybk1eZW05D8Um0DhDsKEndc/s1600/10.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
As you can
see the example code also is given. We follow the same and create one for
programming Arduino Due. The photo below explains how to write the same:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2iZ6rfqE1S-KgyZh_Ydc9mnmWift_cBCzKh3tG9tqEOUh2jDuv-8AGPIPXHtJcbbbXLAn8Xqj6XHsUg678-vMxjCyAAp62tycQ__-vIZS0fFxdZGdsFLmNTdTo5y3uZ4fWkqJ5hpM8Uo/s1600/11.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2iZ6rfqE1S-KgyZh_Ydc9mnmWift_cBCzKh3tG9tqEOUh2jDuv-8AGPIPXHtJcbbbXLAn8Xqj6XHsUg678-vMxjCyAAp62tycQ__-vIZS0fFxdZGdsFLmNTdTo5y3uZ4fWkqJ5hpM8Uo/s1600/11.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So now you know how to write the batch file. Save this notepad text file with
extension &lt;b&gt;.bat &lt;/b&gt;instead of .txt&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Save
it in the location mentioned in the IDE external tools setup. &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So
when you want to program, first erase the chip as mentioned at beginning of
tutorial. Then click on tools, then click on Arduino Due Programmer. You will
get this details below on output screen:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz_pynXDaaa-epaXcmLIXgu1Lx-5v7cvg1Mpz7e-DGUuH3117fnVV_WqDT2NsngfWysDXYpoMt30C5tnCGyREn5s4JJeeVupCqOFPaYXsAXGw-LSB7S_XMQTv3YhHqLzsGIV-moX1Sjr8/s1600/12.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz_pynXDaaa-epaXcmLIXgu1Lx-5v7cvg1Mpz7e-DGUuH3117fnVV_WqDT2NsngfWysDXYpoMt30C5tnCGyREn5s4JJeeVupCqOFPaYXsAXGw-LSB7S_XMQTv3YhHqLzsGIV-moX1Sjr8/s1600/12.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Remember.
If your project name or the programming location changes, you need to change
the batch file too as per that setup. Also keep the addresses small as possible
because I was facing some issue due to long address.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;NOTE:&lt;/span&gt; &lt;/b&gt;My program gets compiled inside atmelstudio workspace. So I copy the &lt;b&gt;duetest_ledblink.bin&lt;/b&gt; and paste it in D: drive. You need to put the huge address to the batch file which is sometimes problematic. So just copy paste the binary file if the location link is greater than 20 characters.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;margin-left: 0in; text-align: left;&quot;&gt;
Lets write
simple code for LED blinking:&lt;/h3&gt;
&lt;div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Onboard LED of Arduino Due is located on
Port B pin 27&lt;/b&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwPRVW4ZP1nsymxGzZjPGWoFPjKsMLU2I-OBFa6Qhief_QRRz_380niIWPe3NVm94Qcr6hm0_B3WxQp536wKys7cs8QYrN_LIIXodY05nKKcNfpyZmPd8Vm51v2_taZE4Ap7N1kg4uh5g/s1600/13.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwPRVW4ZP1nsymxGzZjPGWoFPjKsMLU2I-OBFa6Qhief_QRRz_380niIWPe3NVm94Qcr6hm0_B3WxQp536wKys7cs8QYrN_LIIXodY05nKKcNfpyZmPd8Vm51v2_taZE4Ap7N1kg4uh5g/s1600/13.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Compile the program.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Put the Arduino Due board in programming mode.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Copy paste the duetest_ledblink.bin to D drive.
(Or location defined in batch file)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Go to tools and click on Arduino Due Programmer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Check on output screen if successful. Do not
interrupt during programming.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Reset the board by pressing Reset.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;The LED will blink.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;·&lt;span style=&quot;font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Congratulations!!! You can start working on
Arduino Due with famous &lt;/span&gt;&lt;b style=&quot;text-indent: -0.25in;&quot;&gt;c programming
language&lt;/b&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin-left: 0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;h3&gt;
You can download entire files
done here below:&lt;/h3&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;https://drive.google.com/open?id=0Bzq0D3ZT0_ddcWI2enlDUG5Vak0&quot;&gt;&lt;button&gt;DOWNLOAD&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Well all the best programming with Arduino Due and our old c programming method. You will realize how powerful ARM ATSAM3X8E actually is. I will be updating more on peripheral interfaces like TFT and SD Card so be in touch.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin: 0in 0in 0.0001pt; text-align: left;&quot;&gt;
&lt;i&gt;&lt;b&gt;Why write this article?&lt;/b&gt;&lt;/i&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;

&lt;/div&gt;
&lt;div style=&quot;margin: 0in 0in 0.0001pt; text-align: left;&quot;&gt;
&lt;i&gt;I&#39;m big fan of c programming. And using
Arduino IDE is kind of complicated since I have no control on some peripherals.
I didn&#39;t know what registers to be set to enable some peripherals and what was
the working. Even students now a day&#39;s who work with arduino straight doesn&#39;t
know the basic of internal working. So for Viva they get blank. Doing code in c
actually helps understanding the basics. I was totally confused how to work
with due. So I researched a lot and found out solution which I share with you
today.&lt;/i&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin: 0in 0in 0.0001pt; text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin: 0in 0in 0.0001pt; text-align: left;&quot;&gt;If you like my post,&amp;nbsp;&lt;b&gt;please subscribe&lt;/b&gt;&amp;nbsp;so you get the latest updates.&lt;/div&gt;
&lt;br /&gt;
ALL THE BEST!!&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgkFhOkjgh-pcUjPHltr-1uK8zlOpKB8m6k44eMHlIdxLpj1utR49s3zioCIMXS5n5Lm45p9ZLfUiXn7tGHchyZmCnMrNjxFgIj7-6w0rDUJV6bMZu1y8jGbZl8SFDu24ITEBgI0F6T0/s1600/a.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgkFhOkjgh-pcUjPHltr-1uK8zlOpKB8m6k44eMHlIdxLpj1utR49s3zioCIMXS5n5Lm45p9ZLfUiXn7tGHchyZmCnMrNjxFgIj7-6w0rDUJV6bMZu1y8jGbZl8SFDu24ITEBgI0F6T0/s1600/a.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/4555675646595520598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/4555675646595520598?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4555675646595520598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4555675646595520598'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2016/10/arduino-due-programming-using-atmel.html' title='Arduino Due programming using Atmel Studio 6'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisgGWhlqT-K5RWvtUjtCuEHhavOis9FUf-mVykEUpGRQdm4E0BI-mvuoVim70AhDwz8Ufec3CmkpjhliHwbuZJe2yKsHQLWukru4nKeX70p6QOTqWP8cU1zijzrmC2mJFc0MjjVTWwdvo/s72-c/P_20161021_010204.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-1082800704267138897</id><published>2016-10-02T22:11:00.005+05:30</published><updated>2020-11-22T21:03:27.227+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="accelerometer"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="knock sensor"/><category scheme="http://www.blogger.com/atom/ns#" term="MMA7361"/><category scheme="http://www.blogger.com/atom/ns#" term="relay"/><category scheme="http://www.blogger.com/atom/ns#" term="tap sensor"/><category scheme="http://www.blogger.com/atom/ns#" term="uno"/><title type='text'>Knock sensor using MMA7361 and Arduino UNO R3</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
AIM: To be innovative with &amp;nbsp;accelerometer sensors and teach you how to use them. &amp;nbsp;(With CODE&amp;nbsp;+ Connection Diagram given below)&lt;/h2&gt;
&lt;div&gt;
&lt;b&gt;watch video here:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/1HFL1WBL-OM/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/1HFL1WBL-OM?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2xJRagBf1-VYhho5PlDoKWSr5r8vSuphW9PXW76gh8dxKH6NkxLYE2ttepFZLJ9vL32xpBbhZWjMk-Wukw29OZsBeE1DPS8fXIdomyvtUVQwlK_gd9DM0XwpuISDET4OALKVM1ZGAxDk/s1600/BLUE-DESK-LAMP.jpg&quot; style=&quot;clear: left; display: inline; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2xJRagBf1-VYhho5PlDoKWSr5r8vSuphW9PXW76gh8dxKH6NkxLYE2ttepFZLJ9vL32xpBbhZWjMk-Wukw29OZsBeE1DPS8fXIdomyvtUVQwlK_gd9DM0XwpuISDET4OALKVM1ZGAxDk/s200/BLUE-DESK-LAMP.jpg&quot; width=&quot;125&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;&lt;b style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #073763;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqRvj8soI9zwvqHQRJ-mxJ8pHWOwiC26fR0wdiiqCM1tiPxVaS5pQZPhB5zZuMJSrlFGHXnGH9DpDsrUl5RjZ_mGBIZ0juXsNBHA7Vh7F1olMmDqKcf99OoRkAjop-YtePISopmNbNQZk/s1600/MMA7361+Module.jpg&quot; style=&quot;clear: left; display: inline; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqRvj8soI9zwvqHQRJ-mxJ8pHWOwiC26fR0wdiiqCM1tiPxVaS5pQZPhB5zZuMJSrlFGHXnGH9DpDsrUl5RjZ_mGBIZ0juXsNBHA7Vh7F1olMmDqKcf99OoRkAjop-YtePISopmNbNQZk/s1600/MMA7361+Module.jpg&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Accelerometers basically converts acceleration in x,y,z axis to analog output. Normally they give voltage output or I2C interface based which can be directly processed.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEillfDXqvIU_SW0sdhQUPJrwPi7V8ccH5ngNTtu344RapP-kzQu1JGGypbSv0MYsUS3cLM2_pq3I53Q9IRqyx43BbLxU4kq43SXEe1_APlbf72jI15THDEHzPoTpPxDEU8D8FHejInOlK4/s1600/IMAG112c6.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEillfDXqvIU_SW0sdhQUPJrwPi7V8ccH5ngNTtu344RapP-kzQu1JGGypbSv0MYsUS3cLM2_pq3I53Q9IRqyx43BbLxU4kq43SXEe1_APlbf72jI15THDEHzPoTpPxDEU8D8FHejInOlK4/s1600/IMAG112c6.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will use &lt;a href=&quot;http://eecs.oregonstate.edu/education/docs/accelerometer/MMA7361_module.pdf&quot; target=&quot;_blank&quot;&gt;MMA7361&lt;/a&gt; &lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;(NRND). &lt;/span&gt;This sensor converts acceleration to voltage which we will take advantage of to sense tap or knock.&lt;br /&gt;
&lt;br /&gt;
Normally safest tap is measured by me is 1.53g = 1.5 x 9.8 m/s2 where g = 9.8m/s2 acceleration due to gravity.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
How do I achieve m/s2 from output voltage of the sensor?&lt;/h3&gt;
1. Read ADC.&lt;br /&gt;
2. Convert ADC raw value to output voltage value of accelerometer which is given below:&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgub10qoPid3UurbkGAaGncr29yHux8LayZqBtj6AqlqjdmcDV8-TSmQKLXNVgPX1xltWfKfwIrI-qKXUmBE4mcswZGfpsTwtKJngfSMVZW9pBknkHcPVJl3sxtf0CqRZqOFrys0aHCb7o/s1600/adc+formula.png&quot; style=&quot;clear: left; margin-bottom: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgub10qoPid3UurbkGAaGncr29yHux8LayZqBtj6AqlqjdmcDV8-TSmQKLXNVgPX1xltWfKfwIrI-qKXUmBE4mcswZGfpsTwtKJngfSMVZW9pBknkHcPVJl3sxtf0CqRZqOFrys0aHCb7o/s1600/adc+formula.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
3. Remove Zero g offset which is 1.65V.&lt;br /&gt;
4. &amp;nbsp;Then divide the result by sensitivity. But the result is still in g. To remove g from calculation we multiply by 9.8m/s2 which gives us proper formula below:&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4xgwdGkdkGItCE1SBs6hdvhbsCXqCMbQF3o22BY51hl-Aw7uwBsY9HRhLa3VaRxKPQWmJ-EMSySQQMD0J3FYD_I2hoEEVBTPiPnLDOrsr65ROkojfGHZCW-FPqV32bXp-8r3G8ofDu2s/s1600/formula2.png&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4xgwdGkdkGItCE1SBs6hdvhbsCXqCMbQF3o22BY51hl-Aw7uwBsY9HRhLa3VaRxKPQWmJ-EMSySQQMD0J3FYD_I2hoEEVBTPiPnLDOrsr65ROkojfGHZCW-FPqV32bXp-8r3G8ofDu2s/s1600/formula2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h3 style=&quot;text-align: right;&quot;&gt;
&lt;/h3&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;Things needed:&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;1. Arduino UNO R3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;2. USB Charger&amp;nbsp;+ Arduino UNO USB cable.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9igBqtzba9ZS8QfAEcZAyI7ubBncqSyHe0f1ObOhyphenhyphen-RWJsKRUkihuTSE1nH92E9_dZx5ifRAo8-lxtZTo1HArm_nLJEYeMmXYukAMUDrob8pKKYGmaO4FnuODgy4kOyBKY8a2URZ-VQ4/s1600/%2524_3.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9igBqtzba9ZS8QfAEcZAyI7ubBncqSyHe0f1ObOhyphenhyphen-RWJsKRUkihuTSE1nH92E9_dZx5ifRAo8-lxtZTo1HArm_nLJEYeMmXYukAMUDrob8pKKYGmaO4FnuODgy4kOyBKY8a2URZ-VQ4/s1600/%2524_3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk-iwYn4_1q2sdGRz_e8xF316zd3F-5IWRIhm67cZgkL0NWBzLb0X5uXX6Uvr1FFZHHZAK9RWWqj9XlDRSDLwGgaU19IupwW5bp_pcfaCH7yFdzPDtPcj7Aqd4PTut8-LCT486mzoeiyo/s1600/usb-ab-cable.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk-iwYn4_1q2sdGRz_e8xF316zd3F-5IWRIhm67cZgkL0NWBzLb0X5uXX6Uvr1FFZHHZAK9RWWqj9XlDRSDLwGgaU19IupwW5bp_pcfaCH7yFdzPDtPcj7Aqd4PTut8-LCT486mzoeiyo/s1600/usb-ab-cable.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;3. SSR Relay 40A. (Ratings depends on your load of LAMP. I had 40A in my stock.)&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbfKOx_EPUhEl1LIF258iPQeEz0VsF-zYHFgDwOxoft_2cxCOsBJ123cCaw41JazXdPxOptx1TIKFZiuhEG8V3niIuphkKWy_v4meDv_DP7oBx7T4Na4EDup-UB_GBGKqKiDEUIGY08rA/s1600/SSR.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbfKOx_EPUhEl1LIF258iPQeEz0VsF-zYHFgDwOxoft_2cxCOsBJ123cCaw41JazXdPxOptx1TIKFZiuhEG8V3niIuphkKWy_v4meDv_DP7oBx7T4Na4EDup-UB_GBGKqKiDEUIGY08rA/s1600/SSR.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;4. Lamp with Switch. (Shown in connection diagram)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;Connection diagram:&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZWY3uZK2BiN-lWLP_RpOkzWbuJazePq0JsYx5Q8xeYYc7ET1xS0D2wV_xxY4TDAyP5weYMQmt6A-6p74hauYRtPaxrVZe54-RWzpmrfqqW6OOpbE0avBYau2dsMlvhymEEHp1g-4KiY8/s1600/tapsense_lamponoff.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZWY3uZK2BiN-lWLP_RpOkzWbuJazePq0JsYx5Q8xeYYc7ET1xS0D2wV_xxY4TDAyP5weYMQmt6A-6p74hauYRtPaxrVZe54-RWzpmrfqqW6OOpbE0avBYau2dsMlvhymEEHp1g-4KiY8/s1600/tapsense_lamponoff.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h2&gt;
Download the Arduino code and needed images here:&lt;/h2&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilBiqK6e9fzyB7ZCi6C8_xE1glCPzgi4jb9gZan-ZoGdXEmJhHF9-avMvs7x4CHwmGQ7ko61xK4WWf1KBBlz8xmohNo4tyWmRCEQzOBYj_pB-Rwq_kFobyF2vqKUnUsIB1xCcXwjp4Oek/s1600/code.png&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilBiqK6e9fzyB7ZCi6C8_xE1glCPzgi4jb9gZan-ZoGdXEmJhHF9-avMvs7x4CHwmGQ7ko61xK4WWf1KBBlz8xmohNo4tyWmRCEQzOBYj_pB-Rwq_kFobyF2vqKUnUsIB1xCcXwjp4Oek/s1600/code.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
DOWNLOAD HERE&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h3&gt;
&lt;a href=&quot;https://drive.google.com/drive/folders/0Bzq0D3ZT0_ddaDZiaXlIQVJLbUU?usp=sharing&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;&lt;b&gt;DOWNLOAD CODE&lt;/b&gt;&lt;/button&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;READ MORE:&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
1.&lt;b&gt;Why tap &lt;/b&gt;/&lt;span style=&quot;font-weight: normal;&quot;&gt; &lt;/span&gt;&lt;b&gt;knock sensor?&lt;/b&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sensors basically makes everything easy. I have a large desk and sometimes the plug is too far to turn the lamp ON/OFF. Specially for the people who age and have hard time moving around to turn on just a lamp. So basically just tap or knock on the desk and turn the lamp ON/OFF when needed. This actually helps sometimes when you are too busy to get up from desk just to turn on the lamp or this same can be modified for aged people who live alone.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ5kz7cx6u5xSw7iabewgrc4DV7sKLRw8S14_U-6JVeMdM9_svMviRkgd4c9JleN0vjkzELq6rBbchVQqfLEVY5nccsaXfMVNiZGtwkftM10c60sNHoF3E8ARHhv7aCbk4Ex2W0sCmQME/s1600/P_20161002_165316.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ5kz7cx6u5xSw7iabewgrc4DV7sKLRw8S14_U-6JVeMdM9_svMviRkgd4c9JleN0vjkzELq6rBbchVQqfLEVY5nccsaXfMVNiZGtwkftM10c60sNHoF3E8ARHhv7aCbk4Ex2W0sCmQME/s1600/P_20161002_165316.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
2. What are we using to build hardware?&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We will make this tap sensor using arduino UNO and MMA7361 module.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
MMA7361 module is an accelerometer which can sense motion in all 3 axis. For this application we need only z axis (i.e.&amp;nbsp;+z axis and - z axis since vibration is sinusoidal in nature you can choose any one)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
3. Hardware working?&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We need to place MMA7361 sensor module on the desk. I glued it at the center of the box I chose. We need to note which axis will get affected by knock. Say for now the desk is on -z axis side. So when I tap the desk, the sensor will detect signal in +/-&amp;nbsp;z axis direction. This can be used for sensing knocks. The sensitivity of knock can be setup easy. You do not want to turn lamp ON/OFF accidentally. So what we do is adjust the trigger point little higher then normal taps we do on our desk. I found out the &lt;b&gt;good knock shock is around -1.53g&amp;nbsp;&lt;/b&gt;where &lt;b&gt;g is 9.8m/s2&lt;/b&gt;. Knock to turn ON the lamp. Knock to turn OFF the lamp. Lamp is linked to Arduino with a Solid State relay.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
4. What to take care of during coding?&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
a. Since you are coder you definitely bang your head or hands on the desk while you frustrate.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
b. You also sometimes lean towards the computer and keep your elbows on the desk, which can produce sensing in z axis.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
c. Also books, pens creating noise in sensing region.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In other words, false triggers often will happen if you are not observing. We fix this issues by limiting the knocks with parameters and eliminate few noises but not all are possible.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
d. Even arduino is so fast in reading analog input that sometimes single tap can toggle the lamp many times.&lt;b&gt; I have found tap usually falls in 20ms range&lt;/b&gt;. Analog ADC can sample at much faster rate hence creating multiple toggles. To prevent this we add delay of 300ms after trigger sense.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Since you will be working with 230V AC line on lamp side. &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Be careful!!!&lt;/span&gt;&lt;/b&gt;. You can harm yourself if you touch the AC lines.&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;
Making of the lamp pictures:&lt;/h3&gt;
&lt;div&gt;
1. You need to open the box and remove the switch wires. This wires need to be connected to SSR (Solid state relay).&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUcko9EY8LkbHWnDXNdBv53Le2NlCh9q17PbgMV9Nu-JZrhA-x827fgQPaOaOnAosNN_sXZTDeuUirPKwhD5-vhm-pZZTiZ6WwY4-6Qi7wZra5p3ty-7K-O8tRq6e7Pm5KZvAK9IAkihQ/s1600/P_20161002_135605.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUcko9EY8LkbHWnDXNdBv53Le2NlCh9q17PbgMV9Nu-JZrhA-x827fgQPaOaOnAosNN_sXZTDeuUirPKwhD5-vhm-pZZTiZ6WwY4-6Qi7wZra5p3ty-7K-O8tRq6e7Pm5KZvAK9IAkihQ/s1600/P_20161002_135605.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
2. You also need to find Live and Neutral lines of AC Line and connect USB charger to it. So all together 4 wires will come out. If its a lamp with choke, then keep the choke in the circuit.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirlLJ0F_7wng0GFnaz6jfZhzOuaxM9iQC91koQ3LnLsLMjlUudciT81gdZxFvTvVu0IbHHWT_QtTxb4X2VQd31EpRGOK1XjwnZtjZqohFdOI0y4wAUoMT8uJFg_StDieDEkZWqEYHxey0/s1600/P_20161002_135834.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirlLJ0F_7wng0GFnaz6jfZhzOuaxM9iQC91koQ3LnLsLMjlUudciT81gdZxFvTvVu0IbHHWT_QtTxb4X2VQd31EpRGOK1XjwnZtjZqohFdOI0y4wAUoMT8uJFg_StDieDEkZWqEYHxey0/s1600/P_20161002_135834.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
3. I soldered even the USB Charger. The SSR screws were jammed so I soldered on screws. After soldering them cover them with insulation tape, or for long life use heat shrink tubes.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht8s3jStu0OHn1R3maZTh7TEKzrvry9ymD1rx-xFrMoLvsVIuskcqgSuHbDMWNdKHu_PfMJvH7mfCAGTkJ9t7Cu9fN5DDUSTYiossaQ3Ubgjkt0ZWCCtgHWXeVSZTZ9RrDTZuXP19H1kQ/s1600/P_20161002_151952.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht8s3jStu0OHn1R3maZTh7TEKzrvry9ymD1rx-xFrMoLvsVIuskcqgSuHbDMWNdKHu_PfMJvH7mfCAGTkJ9t7Cu9fN5DDUSTYiossaQ3Ubgjkt0ZWCCtgHWXeVSZTZ9RrDTZuXP19H1kQ/s1600/P_20161002_151952.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Drill hole sufficient enough to take out 4 wires. Make sure you seal the hole with glue gun.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1erDuzsiAfVNiZMZpzJ3B_0vafHE6bPNs5wbJ-4RKdTI7c7JLHGMoFjNNRZgkdioz72Nuz_XoPd-kQgBhPY49gNZSBUpahxiDWM8SD-hqEn5ruhodtMO9DQozTS6EYa6RSr3ySLqLbhE/s1600/P_20161002_154848.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1erDuzsiAfVNiZMZpzJ3B_0vafHE6bPNs5wbJ-4RKdTI7c7JLHGMoFjNNRZgkdioz72Nuz_XoPd-kQgBhPY49gNZSBUpahxiDWM8SD-hqEn5ruhodtMO9DQozTS6EYa6RSr3ySLqLbhE/s1600/P_20161002_154848.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Connect everything and place properly. Also cover the SSR screws in glue to avoid shock. While glue the MMA7361 make sure you do not let glue touch any pins. I debugging for hours why the sensor was not working but apparently there is some parasitic capacitance effect with the glue and the pins. You may also glue arduino and usb charger so it doesn&#39;t move around.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStGawX6gNc7veXWHjsDe1CERaLrfnPOP7BAF-WBfRnLrad6bPXQFMYfSnlEoFXhdzp8iPpXHy9NDm6thnKooy9k5xnR85MgoX2ultlbuBUH5N1ZcCnr4xhKhcSm0mAvq5Rn9yvf7nuNc/s1600/P_20161002_165038.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStGawX6gNc7veXWHjsDe1CERaLrfnPOP7BAF-WBfRnLrad6bPXQFMYfSnlEoFXhdzp8iPpXHy9NDm6thnKooy9k5xnR85MgoX2ultlbuBUH5N1ZcCnr4xhKhcSm0mAvq5Rn9yvf7nuNc/s1600/P_20161002_165038.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;
Final outcome:&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgirycU7RAcGDU9xNw_uq73oI_3R-xXVyAKLCAYcdaufYNEk8fBzj3Znc85m46q9YV885OIcJk9yOBJtGoiMO0QEWoV3rs1VkM0z7UnEDJHSID9Vm7mz_fqAhV-NqRBPPy28kuY018UY2o/s1600/P_20161002_165316.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgirycU7RAcGDU9xNw_uq73oI_3R-xXVyAKLCAYcdaufYNEk8fBzj3Znc85m46q9YV885OIcJk9yOBJtGoiMO0QEWoV3rs1VkM0z7UnEDJHSID9Vm7mz_fqAhV-NqRBPPy28kuY018UY2o/s1600/P_20161002_165316.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
All the best and thank you for reading.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;If you like my post,&lt;/span&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;text-align: left;&quot;&gt;please subscribe&lt;/b&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;text-align: left;&quot;&gt;so you get the latest updates.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgkFhOkjgh-pcUjPHltr-1uK8zlOpKB8m6k44eMHlIdxLpj1utR49s3zioCIMXS5n5Lm45p9ZLfUiXn7tGHchyZmCnMrNjxFgIj7-6w0rDUJV6bMZu1y8jGbZl8SFDu24ITEBgI0F6T0/s1600/a.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgkFhOkjgh-pcUjPHltr-1uK8zlOpKB8m6k44eMHlIdxLpj1utR49s3zioCIMXS5n5Lm45p9ZLfUiXn7tGHchyZmCnMrNjxFgIj7-6w0rDUJV6bMZu1y8jGbZl8SFDu24ITEBgI0F6T0/s1600/a.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/1082800704267138897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/1082800704267138897?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1082800704267138897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1082800704267138897'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2016/10/knock-sensor-using-mma7361-and-arduino.html' title='Knock sensor using MMA7361 and Arduino UNO R3'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/1HFL1WBL-OM/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-6015091149754353951</id><published>2015-05-25T23:48:00.003+05:30</published><updated>2020-11-22T21:06:51.991+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="256bit"/><category scheme="http://www.blogger.com/atom/ns#" term="5V"/><category scheme="http://www.blogger.com/atom/ns#" term="89C51"/><category scheme="http://www.blogger.com/atom/ns#" term="CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="Colors"/><category scheme="http://www.blogger.com/atom/ns#" term="Palettes"/><category scheme="http://www.blogger.com/atom/ns#" term="PWM"/><category scheme="http://www.blogger.com/atom/ns#" term="RGB"/><title type='text'>3 Channel Simple PWM Example for AT89C51 (Revision 2.0)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;AIM: To teach you how to implement basic PWM modulation on AT89C51 with the help of timer and work with RGB LED example code.&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
Basics:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;AT89C51 &lt;/b&gt;doesn&#39;t not have a PWM peripheral &lt;b&gt;built in&lt;/b&gt;. So here the concept of creating one comes in. We know how to make Digital outputs high and low through coding. Lets make use of this and timers to our advantage to create one.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We have learnt how Pulse Width Modulation (PWM) works. The clock Pulses are given in a time frame with divisions in time frame (resolutions = 32/64/128/&lt;b&gt;256&lt;/b&gt;/512/1024) which gives us attenuated voltage which we will be using to control &amp;nbsp;RGB LED brightness which in return gives colors. We will be using 256 Bit resolution because many of the free available palettes are with 256 combination support.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Like for example this can be done like shown below:&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2MIh993XIHpgYA3-np9uI_iIRqM4-4jw2iiJeNIhHegDzZeXMRT3HaTd5-gb-0y5jL2H0ddEXsef_mgBI1H5mx8O_kfitm_ENX3YmuuzaHh2iqOAVBikVGsRGLTUZZGzcAenlLU1Kryc/s1600/pwmout.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;97&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2MIh993XIHpgYA3-np9uI_iIRqM4-4jw2iiJeNIhHegDzZeXMRT3HaTd5-gb-0y5jL2H0ddEXsef_mgBI1H5mx8O_kfitm_ENX3YmuuzaHh2iqOAVBikVGsRGLTUZZGzcAenlLU1Kryc/s400/pwmout.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;PWM brief idea (click to zoom)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
So after going through this you must be wondering how to make this counts to set high and low on a Output pin. So this is when precision timer comes into picture. Lets understand how to configure this timer to our advantage. Check this article &lt;a href=&quot;http://embeddedlifehelp.blogspot.com/2014/04/how-to-create-delay-function-on.html&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;view&lt;/button&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case let us consider &lt;b&gt;Tmax = 10mS. &lt;/b&gt;(10 milli seconds).&lt;br /&gt;
So for each division to happen accurately. You must adjust the timer for :&lt;br /&gt;
timer interrupt = &amp;nbsp;&lt;u&gt; &amp;nbsp; &amp;nbsp;Tmax &amp;nbsp; &amp;nbsp;&lt;/u&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resolution&lt;br /&gt;
so we get &amp;nbsp; &lt;br /&gt;
timer interrupt = &amp;nbsp;&lt;u&gt; &amp;nbsp; &amp;nbsp; 10mS &amp;nbsp;&lt;/u&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;256&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &amp;nbsp;39.0625μS&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So calculating using timer preset value for 39μS we get 0xFFDB (65499) which we have to put into timer TH0,TL0 registers.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now main question arises in your mind is timer is done, pwm is understood but how to know which color will come on RGB LED according to our pwm counts?&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Well it is simple then you think!&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
What I do is I open any sketching tool or paint tool. Then I open color palettes. Check image below&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia8SGspHUrTKEL8awOce_oCEC4HrQPASmVsEtPOOytte2CDTplrXe_N595Oa4Memsd3UmNqVHB2uZsCH-g7tY_FRW-r9z3NM6fV2KmusQKs2WUdcBJQMZcEgMwM3MOezc82tfk5Pr11fQ/s1600/Untitled.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;215&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia8SGspHUrTKEL8awOce_oCEC4HrQPASmVsEtPOOytte2CDTplrXe_N595Oa4Memsd3UmNqVHB2uZsCH-g7tY_FRW-r9z3NM6fV2KmusQKs2WUdcBJQMZcEgMwM3MOezc82tfk5Pr11fQ/s400/Untitled.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Palettes idea (click to zoom)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
So you choose your color in the big multi-color square block. And you will get color counts like this below:&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4XMSBk8uSgYMh7sVNPU1Kgw9Ax9z_v3r69ws6trpVHDjUEldrNfTNcAasRCt0qpiCPssNAcKIt6levFIcPso4TAgm3Pl04GsZ5Pwvonh6srNASwmsazOoXw-5lnTA4yDlXtJRWPJ-0ic/s1600/Untitled-1.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;215&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4XMSBk8uSgYMh7sVNPU1Kgw9Ax9z_v3r69ws6trpVHDjUEldrNfTNcAasRCt0qpiCPssNAcKIt6levFIcPso4TAgm3Pl04GsZ5Pwvonh6srNASwmsazOoXw-5lnTA4yDlXtJRWPJ-0ic/s400/Untitled-1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Palette as color generator (click to zoom)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
I want a purple color to be displayed on my RGB Led. So my counts from above is as below:&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Red counts&lt;/span&gt; = 154,&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: lime;&quot;&gt;Green counts&lt;/span&gt; = 65,&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Blue counts&lt;/span&gt; = 235.&lt;/b&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ins class=&quot;adsbygoogle&quot; data-ad-client=&quot;ca-pub-9425596972394917&quot; data-ad-slot=&quot;6390855755&quot; style=&quot;display: inline-block; height: 90px; width: 728px;&quot;&gt;&lt;/ins&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;

So lets start making one. First we need a schematic layout for RGB LED driver and controller. I have taken some trouble making this one better then I used to make. Hope you like this type schematics.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The microcontroller can be as you want. Since this theory can work on any microcontroller you like eg. PIC,ARM,AVR,STM and so on...Even for arduino board UNO R3, you just need the RGB LED driver section. Power is taken by UNO through USB so you do not require much circuitry there.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;WARNING&lt;/span&gt;:The current calculations are given below in schematic diagram itself. For higher current RGB LED&#39;s you need to calculate maximum limits of the hardware first. UNO and other hardware doesn&#39;t support current above 300mA. USB power can go upto 500mA max. Doing so you may end up burning the device. Be careful there. Offcourse PTC will protect if you put a right one for higher current.&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Schematic diagram:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEb7eLwQNBKhqgYN8gBIuqlViOYsoK8Z1sfuYMB-py75MlvPYew4jjyma8XOeObWcbNd9qRfgwxbhUizj6ZufJu_uAEUWNCX_-ftwTOvUZaxxlViaHRclNvxwbL2cDRMhkieZKGLh6ugk/s1600/pwm.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEb7eLwQNBKhqgYN8gBIuqlViOYsoK8Z1sfuYMB-py75MlvPYew4jjyma8XOeObWcbNd9qRfgwxbhUizj6ZufJu_uAEUWNCX_-ftwTOvUZaxxlViaHRclNvxwbL2cDRMhkieZKGLh6ugk/s400/pwm.png&quot; width=&quot;288&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Schematic diagram (click to zoom)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Bill of material:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMOrJ7PkCTNSo2luWq-UWRQha9yJEUgudWHYRH8HNAX2qSCWHOh_FE_zlLUagFQydwt1CFJdtxsUvI7E2n1Rw_gTktl7JkXhtE5ITzi6nO4sz9qvwVR83kMizu4OU2iRiAQ8DmncF2evQ/s1600/Untitled.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;181&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMOrJ7PkCTNSo2luWq-UWRQha9yJEUgudWHYRH8HNAX2qSCWHOh_FE_zlLUagFQydwt1CFJdtxsUvI7E2n1Rw_gTktl7JkXhtE5ITzi6nO4sz9qvwVR83kMizu4OU2iRiAQ8DmncF2evQ/s400/Untitled.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Bill of material with element14 order codes (click to zoom)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhydoLxfuV5wJGkUuH2pxAXUdZ-GG2tEfXRFN8qw_MMmWMuua5HEwTps0mM4A5X95ffRD7ekOXgjmujpOt9z3Kq0EYLvK6oH5Z0tI4sUs4k1aDB6JVoUiKSC3rN3m55685PRy6RJAyZDPI/s1600/led_pinout.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;90&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhydoLxfuV5wJGkUuH2pxAXUdZ-GG2tEfXRFN8qw_MMmWMuua5HEwTps0mM4A5X95ffRD7ekOXgjmujpOt9z3Kq0EYLvK6oH5Z0tI4sUs4k1aDB6JVoUiKSC3rN3m55685PRy6RJAyZDPI/s400/led_pinout.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;RGB LED I chose for this application. (Source: Internet)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CODE for RGB Led Driver in C (Keil uVision):&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;/*start of code*/&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCj1I2BZfzT2E5-UHxFXNO-B5xFktKmdTxI5ADaQrw6GiP2gJhAp4x8JdXTda-prFGWMq8Ej1fRoYHwmc2zSlEtabNK8TzIIim2l1yr-hjAs19xh3ReiMjTdPS7R7UUO0vKSP2V5CejEQ/s1600/Untitled.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCj1I2BZfzT2E5-UHxFXNO-B5xFktKmdTxI5ADaQrw6GiP2gJhAp4x8JdXTda-prFGWMq8Ej1fRoYHwmc2zSlEtabNK8TzIIim2l1yr-hjAs19xh3ReiMjTdPS7R7UUO0vKSP2V5CejEQ/s400/Untitled.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;c code (click to zoom)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;/*end of code*/&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
Download whole project here &lt;a href=&quot;https://drive.google.com/open?id=0Bzq0D3ZT0_ddTFRHYVdQbmxRZ2M&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;Download&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
In the above code. P3_0 behaves as PWM channel for RED, P3_1 behaves as PWM channel for GREEN, P3_3 behaves as PWM channel for BLUE.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Maximum period (&lt;b&gt;Tmax&lt;/b&gt;) is given by Timer interrupt interval multiplied by 256 which is maximum resolution.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Note that: pwm_r, pwm_g, pwm_b contains values that you need to load to attenuate the load properly. You can increase the timer interrupt period to even higher. I kept it low frequency to eliminate &lt;b&gt;digital noise&lt;/b&gt;. (Ringing in mosfet) (needs extra RC circuit across Drain and source)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;APPLICATIONS IN MIND RUSHING!!!!!&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. You can make now a PWM based&amp;nbsp;&lt;b&gt;RGB Pixel display&lt;/b&gt;! 1 bit resolution screen. This time you add luminosity control.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. This same with different circuit can be used as PWM based&amp;nbsp;&lt;b&gt;10x10 matrix RGB color display&lt;/b&gt; to create a tiny color display of 10x10 resolution.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
3. You can create a PWM based&amp;nbsp;&lt;b&gt;temperature based RGB Color Display&lt;/b&gt;. Where LM35 can be used to read adc input and then you can convert the temperature to fixed color to know temperature presets.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
4. You can create PWM based&amp;nbsp;&lt;b&gt;PC terminal based RGB color display &lt;/b&gt;by linking pc terminal and sending color code through Visual C based PC Software with palette on it.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
5. You can make a PWM based&amp;nbsp;&lt;b&gt;Mood Lamp with RGB Color vision&lt;/b&gt; which changes color on your mood. (Sounds/ vibration can be used to sense the tension or happiness)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You are now ready to make your own!!!&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;If you like my post,&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;text-align: left;&quot;&gt;please subscribe&lt;/b&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;so you get the latest updates.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeWyIcwqfZLzTWWVl-UrNwZ1ahy8DHxYWPQ0fPTdaiy0MEilEZT6q-bwKTN3cLxijkiYXa1kR434I-2jcX7nfTtzF9x4b4cT85nISYErCY708ndVSv_gV_MnacdJVyDcwi19sOTgWTUXA/s1600/a.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;190&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeWyIcwqfZLzTWWVl-UrNwZ1ahy8DHxYWPQ0fPTdaiy0MEilEZT6q-bwKTN3cLxijkiYXa1kR434I-2jcX7nfTtzF9x4b4cT85nISYErCY708ndVSv_gV_MnacdJVyDcwi19sOTgWTUXA/s200/a.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span face=&quot;&amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif&quot; style=&quot;background-color: white; font-size: 14px; line-height: 19.6px;&quot;&gt;Thank you for reading,&lt;/span&gt;&lt;br /&gt;
&lt;span face=&quot;&amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif&quot; style=&quot;background-color: white; font-size: 14px; line-height: 19.6px;&quot;&gt;Macjan Camilo Fernandes&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span face=&quot;&amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif&quot; style=&quot;background-color: white; font-size: xx-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;a href=&quot;https://drive.google.com/open?id=1lzPvjN-Gt3Vt5sHbzbpoe-Tiwpjh3rYtzcxPQBhqYOA&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;FEEDBACK FORM&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span face=&quot;&amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif&quot; style=&quot;background-color: white; font-size: xx-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;



&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/6015091149754353951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/6015091149754353951?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/6015091149754353951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/6015091149754353951'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2015/05/3-channel-simple-pwm-example-for-at89c51.html' title='3 Channel Simple PWM Example for AT89C51 (Revision 2.0)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2MIh993XIHpgYA3-np9uI_iIRqM4-4jw2iiJeNIhHegDzZeXMRT3HaTd5-gb-0y5jL2H0ddEXsef_mgBI1H5mx8O_kfitm_ENX3YmuuzaHh2iqOAVBikVGsRGLTUZZGzcAenlLU1Kryc/s72-c/pwmout.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-8756486204921995884</id><published>2015-04-22T09:20:00.002+05:30</published><updated>2020-11-22T21:07:50.032+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="guidance"/><category scheme="http://www.blogger.com/atom/ns#" term="hobbyist"/><category scheme="http://www.blogger.com/atom/ns#" term="Microcontroller"/><title type='text'>Where do I start learning embedded systems?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOiAZqWmegi-3C2ZYcUCROh4Xqb_6rcmECSBp2HMM7VYAvXGJAkTcEu3dLxtX0kXNghb7cYiOeEOCcJ7xQvNZJKRfFS1InYVw8zo1lKKur0ZHMQLnGO6VG4DvThZagdblG5413sIxTsIA/s1600/Look+at+this+photo+taken+with+Camera+ZOOM+FX.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;301&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOiAZqWmegi-3C2ZYcUCROh4Xqb_6rcmECSBp2HMM7VYAvXGJAkTcEu3dLxtX0kXNghb7cYiOeEOCcJ7xQvNZJKRfFS1InYVw8zo1lKKur0ZHMQLnGO6VG4DvThZagdblG5413sIxTsIA/s400/Look+at+this+photo+taken+with+Camera+ZOOM+FX.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;Welcome to embedded world!!!.&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
There are super vast topics in embedded systems and hobbyists mostly aim for project specific. I assume you have already done some circuits before and you know most of the pin conventions of the IC&#39;s and other components. We like to know why this IC functions the way it&#39;s not suppose to happen rite. Because most IO&#39;s are fixed logic. Embedded deals with custom logics so same IC can do many stuff. We call them microcontrollers. Microprocessors is way beyond hobbyists and I do not recommend for beginners.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
But now so many learning kits come with simply language SDK. Like raspberry pi. But think twice when you chose.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
To turn LED on we do not need high end super processors or microcontrollers either. You should know what&#39;s inside that controller IC.&lt;/div&gt;
&lt;b style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;color: blue;&quot;&gt;So these are some questions you need to go through before doing your first embedded project.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1. Do you really want to do this?&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;2. Is it reliable? Are you paying too much for this?&amp;nbsp;&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;b&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;3. Am I really doing this for learning purpose or selling purpose?&lt;/b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
(selling then stop there itself. If it&#39;s available in circuit diagram on some page of a book it&#39;s already patented or not your original product)&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;4. Are you qualified or studied enough to do this?&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
(sometimes you need high end peripherals like graphics LCDs, camera etc which you may hardly know and there are 95% chances you will fail)&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;5. Is it matter to do this project is open source?&amp;nbsp;&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Some embedded microcontrollers need software which needs to be paid before doing any compilation of the code. That is even worse. Open source ideally recommended.&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;b&gt;6. If you are making it as a product then will it sell?&lt;/b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;7. How cheap is it?&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;8. What&#39;s it&#39;s market value if existing?&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;9. How much certifications it has? (CE, BIS)&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;10. Are you ready for selling atleast 200+ per day or even 1000+ in a month on demand? &lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqGZba4v9vr2Q9JhLWdKhQ_AzqO81eJksxOfVwSgDJEnMjuVr0QK7_Hi4xGXJLGUj8fSzRAqmaN4AaA-e4EY8jFQc_gG9MtPwVSbP7pnL2kXFOeh2ogZ2ZLIK4xp61v4aJxq6dC2J14EA/s1600/4b.png&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqGZba4v9vr2Q9JhLWdKhQ_AzqO81eJksxOfVwSgDJEnMjuVr0QK7_Hi4xGXJLGUj8fSzRAqmaN4AaA-e4EY8jFQc_gG9MtPwVSbP7pnL2kXFOeh2ogZ2ZLIK4xp61v4aJxq6dC2J14EA/s320/4b.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
There are many other questions besides these. Your idea always exists in other part of the world so make sure you do research before starting New product. When making hobby projects find out if these already done projects need extra work to work it out. Or it doesn&#39;t even work.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
When comes to microcontrollers vast language used is C language. Easy to understand. But learn Assembly language and do not use it. Unless your coding is just for simple purpose. Sometimes assembly language is useful when comes to saving a lot of programming space and where speeds are concerned but trust me you do not need to learn that far.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Make a proper decision of selecting a controller. Sometimes the application is so small but controller can handle 30 of these processes. So eg. Say you want just one RS232 port and few peripherals. Do not buy controller with 4 UARTs. Cost/power/space everything will increase.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Some engineers are so stupid they use high end microcomputers like raspberry pi, Beaglebone and so on for relay switching which even arduino uno can do. &lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Then comes interest. Everything to start and get completed needs interest. This is hard. I have lost interest in so many projects just because I knew I couldn&#39;t do them. Sometimes one problem just couldn&#39;t get solved like eg. Timing issue, Mis fire, communication not 100% working and more. These issues always happen. Even brilliant minds get errors and issues. That is why when solving they become genius in coding.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You will need a personal computer to burn programs and even a programmer device. So make sure you chose the right one. If you got AVR programmer and you had interest in 8051 based system. Oh hell! Well obviously if u know logic you can implement these on AVR. And vice versa. Learn to understand these logics.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Always remember what you have learnt from the past issues and fixes. Remember behind success there is a lot of hard work involved. &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;My Experience!&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
For the first time I learnt 89C51 which is very easy to learn. Maybe even you can start with this. Logic is same for every microcontroller but once you are clear with the peripheral blocks/logical blocks inside microcontroller then you can code any new controller which is just launched. Arduinos are great because they are meant for hobbyists. So if u understood the logic the same 89C51 based project or avr project can be implemented on arduino. You just need to map the pins properly or map the logic properly.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Learn how to modify codes for different libraries/ devices/ or different PCBs.&lt;/b&gt; It&#39;s a good practice. &lt;b&gt;Learn to interface for keypad, LCD, LEDs, speaker, potentiometer, and so on.&lt;/b&gt; It will take atleast 2years if you are quick learner to understand microcontrollers. You will be ready to program anything you want.&amp;nbsp; All if you got interest.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Learn where you can. If you can&#39;t buy tools you can join a course or ask your friend to gift you one. Why waste money on t-shirt or shoes or any apparel for gifting when you can ask you arduino or something similar to continue your liking. Be a good friend of tools. I got super collection of tools needed to do my projects.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
Thank you for reading.&lt;br /&gt;
&lt;br /&gt;
And all the best to you ahead!&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you like my post,&amp;nbsp;&lt;b&gt;please subscribe&lt;/b&gt;&amp;nbsp;so you get the latest updates.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXfiVdf4OKTpqO-JJ2GuiTUim-VkKXHONzOtTiDJmCna-_S-DuW_VmFhpdFvKXMNNcKs1oIhQRYCZsOQFMFNQBuGH4G6hF4LSx8b-RIz4bXAWBfhe7B9gXdo860eHI_7ZyPV_ChhTpt8Q/s1600/a.jpg&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXfiVdf4OKTpqO-JJ2GuiTUim-VkKXHONzOtTiDJmCna-_S-DuW_VmFhpdFvKXMNNcKs1oIhQRYCZsOQFMFNQBuGH4G6hF4LSx8b-RIz4bXAWBfhe7B9gXdo860eHI_7ZyPV_ChhTpt8Q/s1600/a.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/8756486204921995884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/8756486204921995884?isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8756486204921995884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8756486204921995884'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2015/04/where-do-i-start-learning-embedded.html' title='Where do I start learning embedded systems?'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOiAZqWmegi-3C2ZYcUCROh4Xqb_6rcmECSBp2HMM7VYAvXGJAkTcEu3dLxtX0kXNghb7cYiOeEOCcJ7xQvNZJKRfFS1InYVw8zo1lKKur0ZHMQLnGO6VG4DvThZagdblG5413sIxTsIA/s72-c/Look+at+this+photo+taken+with+Camera+ZOOM+FX.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-3564175779370885814</id><published>2015-03-28T12:12:00.004+05:30</published><updated>2024-04-18T23:59:17.108+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ascii convert"/><category scheme="http://www.blogger.com/atom/ns#" term="hex"/><category scheme="http://www.blogger.com/atom/ns#" term="serial"/><category scheme="http://www.blogger.com/atom/ns#" term="sprintf"/><title type='text'>C code to convert Integer into ASCII HEX</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;UPDATED: 18-04-2024&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Why I made this post???&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
I was working with &lt;b&gt;debug uart communication&lt;/b&gt;. And I wanted to know hexadecimal representation of values of certain data. Problem was I did not get any &lt;b&gt;easy conversion&lt;/b&gt; tool. Besides &lt;b&gt;SPRINTF&lt;/b&gt;. So this little code will help you &lt;b&gt;convert integer (uint8_t)&amp;nbsp; to ASCII&lt;/b&gt;&amp;nbsp;&lt;b&gt;HEX&lt;/b&gt; during debugging applications.&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;This code can be used in your embedded firmware to do conversions and print to terminal specially for those microcontrollers which has no support for sprintf function or has very less memory to support sprintf function.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;
eg:&lt;br /&gt;
&lt;b&gt;char datab[20];&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;converthex(datab, 100);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;printf(&quot;%s\n&quot;,datab);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Ans: 0x64&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;CODE:&lt;/b&gt;

  
&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;void converthex(char *data, unsigned int a){ //definition&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;unsigned int temp =a;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;int digits=0,set;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;int i=0;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;unsigned int x;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;unsigned int mask;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;mask=0x0f;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;while(temp!=0){&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=temp/16;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; digits++;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(digits&amp;gt;1)mask=mask&amp;lt;&amp;lt;4;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;set=digits;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;set--;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;data[i]=&#39;0&#39;;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;i++;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;data[i]=&#39;x&#39;;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;i++;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;temp=a;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;while(digits!=0){&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x=(temp&amp;amp;mask);&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x=x&amp;gt;&amp;gt;(set*4);&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(x&amp;lt;=9)data[i]=0x30+x;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else{&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data[i]=0x41+(x-10);&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; digits--;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=temp&amp;lt;&amp;lt;4;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp; &amp;nbsp; data[i]=&#39;\0&#39;;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;}&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;you can download code blocks project here &lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;button&gt;&lt;a href=&quot;https://gitlab.com/embeddedlifehelp/converters.git&quot; target=&quot;_blank&quot;&gt;DOWNLOAD&lt;/a&gt;&lt;/button&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;I&#39;ve also updated various ways you can use this function in code blocks example this way you can use it in your embedded system c code as well.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;If it really helped you, please do comment your feedback and share it with your friends and colleagues.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiuMGJX3Syf0NFpBzVu0wLV-t21DtZKR4eStHBTGT-cz5QSOddjfyxS7h1S9A_fqnRmCSfSZl_RhGvfYTNfRMPrBiIWoPkPqx6UvmAhiYmEUo8icP60XpQ6Ut7SUgonA78ety4irCQ7zpFSWzsWYaee999X2qozDNIEocEv7ezkwbEFUtJOTfkzZOHeyyc&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;194&quot; data-original-width=&quot;204&quot; height=&quot;157&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiuMGJX3Syf0NFpBzVu0wLV-t21DtZKR4eStHBTGT-cz5QSOddjfyxS7h1S9A_fqnRmCSfSZl_RhGvfYTNfRMPrBiIWoPkPqx6UvmAhiYmEUo8icP60XpQ6Ut7SUgonA78ety4irCQ7zpFSWzsWYaee999X2qozDNIEocEv7ezkwbEFUtJOTfkzZOHeyyc=w165-h157&quot; width=&quot;165&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;

</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/3564175779370885814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/3564175779370885814?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/3564175779370885814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/3564175779370885814'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2015/03/c-code-to-convert-hex-into-ascii.html' title='C code to convert Integer into ASCII HEX'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEiuMGJX3Syf0NFpBzVu0wLV-t21DtZKR4eStHBTGT-cz5QSOddjfyxS7h1S9A_fqnRmCSfSZl_RhGvfYTNfRMPrBiIWoPkPqx6UvmAhiYmEUo8icP60XpQ6Ut7SUgonA78ety4irCQ7zpFSWzsWYaee999X2qozDNIEocEv7ezkwbEFUtJOTfkzZOHeyyc=s72-w165-h157-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-5532406600018972602</id><published>2015-03-27T13:20:00.002+05:30</published><updated>2020-11-22T21:09:42.620+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ascii convert"/><category scheme="http://www.blogger.com/atom/ns#" term="float"/><category scheme="http://www.blogger.com/atom/ns#" term="serial"/><title type='text'>C code to convert floating point value to ASCII array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
I was working on gyro/accelero sensor which required calculations to be done precisely.&lt;br /&gt;
&lt;br /&gt;
This some compiler will not give me support to use my favourite &lt;b&gt;SPRINTF&lt;/b&gt; function which makes everything easy to print floating point value in ascii format on uart. So I sat down using DEVC and made cody myself to print floating point. This code usually helps when you want to print on LCD.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Hope this helps you.&lt;br /&gt;
&amp;nbsp;Example:&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt; &lt;b&gt;char datab[20];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; convert(datab,-256.126,2);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; printf(&quot;%s&quot;,datab);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;CODE:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMKCO9E0K2KLN0_UF33EJZMVDkfiD75HD-QIAcvC-KKu9kq1DLnT0vaZVPuuL_NE-ZupbrN77RHWcNiJKYMzwHIpBMDkimkpAOkRj-cyc2PyvimcTzR3FwBMxFOebhbLqjUxbgk0i8S4/s1600/2png.png&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMKCO9E0K2KLN0_UF33EJZMVDkfiD75HD-QIAcvC-KKu9kq1DLnT0vaZVPuuL_NE-ZupbrN77RHWcNiJKYMzwHIpBMDkimkpAOkRj-cyc2PyvimcTzR3FwBMxFOebhbLqjUxbgk0i8S4/s1600/2png.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;
You can download DEV C project here &lt;a href=&quot;https://drive.google.com/open?id=0Bzq0D3ZT0_ddUTY4cS11N3ZGd0E&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;Download&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
Thank you for reading.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you like my post,&amp;nbsp;&lt;b&gt;please subscribe&lt;/b&gt;&amp;nbsp;so you get the latest updates.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;!--0--&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/5532406600018972602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/5532406600018972602?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/5532406600018972602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/5532406600018972602'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2015/03/c-code-to-convert-floating-point-value.html' title='C code to convert floating point value to ASCII array'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMKCO9E0K2KLN0_UF33EJZMVDkfiD75HD-QIAcvC-KKu9kq1DLnT0vaZVPuuL_NE-ZupbrN77RHWcNiJKYMzwHIpBMDkimkpAOkRj-cyc2PyvimcTzR3FwBMxFOebhbLqjUxbgk0i8S4/s72-c/2png.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-4255517319851989903</id><published>2015-03-26T20:32:00.001+05:30</published><updated>2016-02-06T12:47:36.449+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="extended pointer"/><category scheme="http://www.blogger.com/atom/ns#" term="memcpy"/><category scheme="http://www.blogger.com/atom/ns#" term="memset"/><title type='text'>Taking address of &quot;buffer&quot; may require an extended pointer for this device</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
Microchip&#39;s MPLABX IDE X16 Compiler gives problems on dspic33 series microcontrollers when doing &lt;b&gt;memcpy&lt;/b&gt; or &lt;b&gt;memset. &lt;/b&gt;Warning is generated such as :&amp;nbsp;&lt;b&gt;Taking address of &quot;buffer&quot; may require an extended pointer for this device&lt;/b&gt;&amp;nbsp;for these functions. These also helped me to reduce errors for SD CARD functions, string functions which include UART communication. &lt;span style=&quot;color: blue;&quot;&gt;But I have noticed the warnings doesn&#39;t effect the code.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So I wrote my own functions for replacing these two:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;A) MEMCPY function replacement:&lt;span style=&quot;color: red;&quot;&gt; Just declare these functions in your code. Will work.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;void my_memcpy(void *x, const void *y, unsigned int length)&lt;/b&gt;&lt;b&gt;; //Declaration&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;void my_memcpy(void *x, const void *y, unsigned int length)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp;while(length--)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; *(unsigned char*)x++=*(unsigned char*)y++;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;div&gt;
&lt;b&gt;B) MEMSET function replacement:&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Just declare these functions in your code. Will work.&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;b&gt;void my_memset(char *d, int value, unsigned int num )&lt;/b&gt;; //Declaration&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;void my_memset(char *d, int value, unsigned int num )&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while(num--)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *(char*)d++=value;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Hope This helped you too.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thanks for reading.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/4255517319851989903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/4255517319851989903?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4255517319851989903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4255517319851989903'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2015/03/extended-address-space-required-error.html' title='Taking address of &quot;buffer&quot; may require an extended pointer for this device'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-572049715976646734</id><published>2014-12-31T00:54:00.003+05:30</published><updated>2016-02-06T12:48:49.719+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="16x2"/><category scheme="http://www.blogger.com/atom/ns#" term="16x4"/><category scheme="http://www.blogger.com/atom/ns#" term="20x2"/><category scheme="http://www.blogger.com/atom/ns#" term="20x4"/><category scheme="http://www.blogger.com/atom/ns#" term="40x2"/><category scheme="http://www.blogger.com/atom/ns#" term="40x4"/><category scheme="http://www.blogger.com/atom/ns#" term="api"/><category scheme="http://www.blogger.com/atom/ns#" term="CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="generic"/><category scheme="http://www.blogger.com/atom/ns#" term="library"/><title type='text'>Generic LCD Driver for 16x2/ 16x4/ 20x2/ 20x4 HD44780 LCD Controllers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;E&lt;/b&gt;mbedded&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt; L&lt;/span&gt;&lt;/b&gt;ife introducing simple LCD interfacing using generic LCD driver designed to fit into any microcontroller you want to with some changes at IO level.&lt;br /&gt;
&lt;br /&gt;
As inspired by arduino libraries. Now in todays world we go very low on details on how things really work in background. Sometimes speed of achievement is necessary to achieve certain goals in software and hardware.&lt;br /&gt;
&lt;br /&gt;
Generic LCD driver is designed in such a way that you have to edit only few necessary changes to make it work on your microcontroller. So since basic IO functions differ for different microcontrollers and speed too, that is why I&#39;ve not defined the basic IO functions. But examples will be updated every day for different microcontrollers.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFlqcHjEkPvHAKArZAtHXOjiTXZfF-3dC9zoDj_Lp1qponDhJwgKJJ4ct0ZnoZ-kX-52_nDrFgXwf3ZlFmVxeCWn-Q0_C9h8WNfvzEctd69wN84ILtCnZU-c8uVFWvlTfs2iWJzOeaUlg/s1600/lcd_driver.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;303&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFlqcHjEkPvHAKArZAtHXOjiTXZfF-3dC9zoDj_Lp1qponDhJwgKJJ4ct0ZnoZ-kX-52_nDrFgXwf3ZlFmVxeCWn-Q0_C9h8WNfvzEctd69wN84ILtCnZU-c8uVFWvlTfs2iWJzOeaUlg/s1600/lcd_driver.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So normally as I see this system as, the microcontroller is the brain here. Which hence communicates to LCD controller to display certain data you want to display.&lt;br /&gt;
The library functions contains 2 types of level functions:&lt;br /&gt;
&lt;b&gt;IO Level functions&lt;/b&gt; where you have to modify them as per your microcontroller port syntax with some minor changes and providing some delay too (delay varies for different microcontroller frequencies).&lt;br /&gt;
&lt;b&gt;API functions&lt;/b&gt; are designed for you to get access to microcontroller at top level and not to care whats going on below this layer. This are the functions you need to use in your coding.&lt;br /&gt;
&lt;br /&gt;
&lt;left&gt;

&lt;/left&gt;&lt;b&gt;&lt;/b&gt;
&lt;a href=&quot;http://embeddedlifehelp.blogspot.in/p/blog-page_2.html&quot; target=&quot;_blank&quot;&gt;&lt;br /&gt;&lt;/a&gt;
&lt;a href=&quot;http://embeddedlifehelp.blogspot.in/p/blog-page_2.html&quot; target=&quot;_blank&quot;&gt;(DOWNLOAD GENERIC LCD LIBRARY FROM HERE)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You need to know how the library works:&lt;br /&gt;
There is file inside called &lt;b&gt;lcdconf.h&lt;/b&gt;&lt;br /&gt;
In this files,&lt;br /&gt;
&lt;b&gt;LCD_LENGTH &lt;/b&gt;:Value is set to 16 for 16x2/16x4 LCD&#39;s. Value is set to &#39;20&#39; for 20x2/20x4 LCD&#39;s.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;LCD_HD44780&lt;/b&gt; needs be set to 1. Right now it supports only one type LCD controller but soon options to control LCD&#39;s with different controllers will come.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;LCD_LINES: &lt;/b&gt;Value is set to 2 for 16x2/20x2 LCD&#39;s. Value is set to 4 for 16x4/20x4 LCD&#39;s.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;INTERFACE_8_BIT&lt;/b&gt; is set to 1 by default. Means the controller databus will work in 8bit mode. If this is set to 0 the Interface will work in 4bit mode.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;BACKLIGHT_CONTROL&lt;/b&gt; is set to 1 by default. If you are not using IO powered backlight control you can set it to 0.&lt;br /&gt;
&lt;br /&gt;
In &lt;b&gt;lcd.c&lt;/b&gt; there are IO level functions and API level functions.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;API Level Functions&lt;/b&gt;&lt;/u&gt;:&lt;br /&gt;
&lt;br /&gt;
LCD initialization function:&lt;span style=&quot;color: red;&quot;&gt;//Initializes lcd 8bit mode/ 5x8 character/ 2 Lines select/Display On&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;void api_lcd_initialize(void);&lt;/b&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
LCD print function: &lt;span style=&quot;color: red;&quot;&gt;//prints data of given width on line, at cursor position.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;void api_lcd_printf(BYTE line, BYTE cursor, CHAR8 *databuffer, BYTE data_length);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
where,&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;line = unsigned char value for line (1,2,3,4) .&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;cursor = unsigned char value for cursor position (1,2,3....20).&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;databuffer = data pointer to the string to be printed. (max 16 or 20 per line)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;data_length = number of characters in the string to be printed. (max 16 or 20 per line)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LCD clear function: &lt;span style=&quot;color: red;&quot;&gt;//clears the LCD screen for given line.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;void api_lcd_clearf(BYTE clear_sel);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
where,&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;clear_sel = line to be cleared completely. (1,2,3,4)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
LCD custom character setup:&lt;span style=&quot;color: red;&quot;&gt;// The CGRAM data array is saved for your customized characters&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;void api_lcd_custom_character_ram(char *cgram);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
where,&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;cgram = contains array of 64bytes of custom character data. (Max 8 custom characters. 8 bytes each for 1 character.)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/b&gt;&lt;br /&gt;
LCD backlight control: &lt;span style=&quot;color: red;&quot;&gt;//Can turn on/off the LCD backlight to save power.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;void api_lcd_backlight(BYTE state);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
where,&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;state = B_ON for backlight on, B_OFF for backlight off.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;NOTE: THE LIBRARY WILL COMPILE WITHOUT ANY ERRORS FOR FIRST TIME. BUT THE FUNCTIONS WILL NOT WORK WITHOUT ASSIGNING PORT PINS ACCORDINGLY. SO KINDLY CHECK EXAMPLES HOW TO DEAL WITH PORT MAPPING. IT WILL GIVE YOU IDEA. ONCE THIS IS DONE. YOU WILL HAVE NO ISSUES TO PLAY WITH LCD.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;You can Map the ports by checking out examples given below download. &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Thank you for reading,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Macjan Camilo Fernandes&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/572049715976646734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/572049715976646734?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/572049715976646734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/572049715976646734'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/12/generic-lcd-driver-for-16x2-16x4-20x2.html' title='Generic LCD Driver for 16x2/ 16x4/ 20x2/ 20x4 HD44780 LCD Controllers'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFlqcHjEkPvHAKArZAtHXOjiTXZfF-3dC9zoDj_Lp1qponDhJwgKJJ4ct0ZnoZ-kX-52_nDrFgXwf3ZlFmVxeCWn-Q0_C9h8WNfvzEctd69wN84ILtCnZU-c8uVFWvlTfs2iWJzOeaUlg/s72-c/lcd_driver.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-784342380461827592</id><published>2014-12-22T21:28:00.002+05:30</published><updated>2016-02-06T12:49:43.633+05:30</updated><title type='text'>I²C for beginners made easy (Generic Study)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;AIM&lt;/b&gt;: To teach you how I²C works and how to implement it on any microcontroller to support your application.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://upload.wikimedia.org/wikipedia/en/thumb/9/9f/I%C2%B2C_bus_logo.svg/220px-I%C2%B2C_bus_logo.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://upload.wikimedia.org/wikipedia/en/thumb/9/9f/I%C2%B2C_bus_logo.svg/220px-I%C2%B2C_bus_logo.svg.png&quot; height=&quot;200&quot; width=&quot;182&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;BASICS&lt;/b&gt;: (&lt;span style=&quot;color: red;&quot;&gt;THINGS YOU NEED TO KNOW&lt;/span&gt;)&lt;br /&gt;
1. I²C - means &lt;b&gt;Inter - Integrated Circuit&lt;/b&gt;.&lt;br /&gt;
2. This protocol is designed by &lt;b&gt;Philips Semiconductor&lt;/b&gt; known today as &lt;b&gt;NXP Semiconductors&lt;/b&gt;.&lt;br /&gt;
3. You can have multiple masters/ multiple slaves but maximum 7 devices for one master.&lt;br /&gt;
4. It works on 2 signals provided Grounds of all devices are connected together. The two signals are &lt;b&gt;SCL&lt;/b&gt; and &lt;b&gt;SDA&lt;/b&gt;. Also VCC and GND in some cases are used for off board connectivity.&lt;br /&gt;
&lt;br /&gt;
SCL - Serial Clock.&lt;br /&gt;
SDA - Serial Data.&lt;br /&gt;
&lt;br /&gt;
Many Devices support I²C bus. Specially EEPROMs, most of the microcontrollers, IO expanders, ADC&#39;s and DAC&#39;s, Sensors and even Displays and so on.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How does the signals look like?&lt;/b&gt;&lt;br /&gt;
Whenever we need to study any protocol first thing you need to read is signal diagram. Most datasheets show the Frame Diagrams.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;403&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_HxU9Msyf5C1lcrL74zrbQza3pwymvsQWYva8EI8ZJwackMFPt-i8hhYV_9Va9DMWqtaDttSAG2zkoi3rvL6uchOy3Fr5y2Y-warMtsKZSkfXO2TLYuDqshMLIYxuxDytcS-72vFqNyI/s1600/i2c1.png&quot; width=&quot;640&quot; /&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;RED REGION&lt;/span&gt;&lt;/b&gt;: If SCL and SDA lines are both at logic 1. The I2C bus is assumed to be at idle state. That is no data gets received or transferred.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;b&gt;START REGION&lt;/b&gt;&lt;/span&gt;: To start communication from idle we need to set SDA logic level to 0 and after some delay set SCL to logic level 0. This region is also called &lt;b&gt;S&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;DATA TRANSFER REGION&lt;/b&gt;&lt;/span&gt;: To transfer the data, while SCL is at logic level 0 the data has to be set bit wise on SDA line. The transfer is done bitwise (Bit by Bit) from MSB to LSB. (MAX = 8bit).&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once data has been set on SDA line. The SCL line is bring up at logic level 1 to transfer data to slave or master and then SCL line is bough to logic level 0 to set the next bit for transfer. Once transfer is done for all data, the master must change the SDA line as input to read the SDA line for ACK (Acknowledgement) and NACK (No Acknowledgement). During ACK/NACK the SDA line of MASTER has to be input and also SCL line must be at logic level 1 and then 0 to transfer the ACK/ NACK bit to master. Once this is done the MASTER SDA line can be set as output.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;ACK&lt;/b&gt;: To read this Set master SDA line as input (&lt;b&gt;for bit banging mode only&lt;/b&gt;, for master with i2c feature don&#39;t need to change SDA line as input). Set clock SCL to logic level 1 and then logic level 0. (Clock delays are same throughout all data transfers). (The signal is at logic level 0 on SDA). This region is called &lt;b&gt;A&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;NACK&lt;/b&gt;:To read this do same as ACK. (Here the signal is at logic level 1 on SDA). This region is called &lt;b&gt;N&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;SR&lt;/b&gt;: (Also known as &lt;b&gt;START REPEAT&lt;/b&gt;) This is same as &lt;b&gt;START REGION&lt;/b&gt; but with some changes.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This part of signal mostly occurs during reading from slave. After &lt;b&gt;NACK&lt;/b&gt; is received, the slave releases the SDA line and so the master controls it back.&lt;span style=&quot;color: red;&quot;&gt; &lt;b&gt;Hence to make start repeat work the master must set the SDA line to logic level 1 after some delay turn the SCL line to level 1 and so after some delay repeat the START REGION procedure.&lt;/b&gt;&lt;/span&gt; Yes offcourse if the master has inbuilt i2c bus then it will take care of this. But in bit banging mode you need to know all of this. This region is called &lt;b&gt;SR&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: orange;&quot;&gt;STOP REGION&lt;/span&gt;: Once all data has been transmitted or received the SCL line must be bought to logic level 1 and then after some delay you must bring the SDA line to logic level 1. This region is also called as &lt;b&gt;P&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;How do you implement all this regions into c code?&lt;/b&gt; This is where all your knowledge comes into play. This code below is for master i2c bus.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;ccode&quot;&gt;&lt;/pre&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;void i2c_idle(void)&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCL=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;//busy condition&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SDA=1;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(100);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;void i2c_start(void)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SDA=0;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(50);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCL=0;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(50);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;void i2c_repeatstart(void) //repeat start&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SDA=1;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(50);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCL=1;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(50);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_start();&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;void i2c_stop(void)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SDA=0; &lt;/b&gt;//N_ACK = 1 so set SDA to 0&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCL=1;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(50);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SDA=1;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(50);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;void i2c_clock(void)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCL=1;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(10);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCL=0;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(10);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;void i2c_ack(void) &lt;/b&gt;//ack i2c&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BYTE ack;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ack=SDA;&amp;nbsp; &lt;/b&gt;//acknowledge&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_clock();&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This above method is bit banging mode. The minimum delay above I used produced 20uS(delay(1)). You can change this for suiting your purpose. To be on safe side I have kept min limit to 20uS which is max. 50KHz bus speed.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The i2C bus can still go low upto 5Mbps in speed. The above test is done for 100KHz bus speed.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Ideal for bitbanging mode in 8051 microcontrollers.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
I have made tutorial for EEPROM 24LC512 interfacing to AT89C51/52 . You can check out the code files by &lt;a href=&quot;http://embeddedlifehelp.blogspot.com/2014/12/eeprom-interfacing-with-8051-using-i2c.html&quot; target=&quot;_blank&quot;&gt;clicking here&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;(Examples with more interfacing peripherals coming soon)&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;sqs-block code-block sqs-block-code&quot; data-block-type=&quot;23&quot; id=&quot;block-yui_3_17_2_1_1403233109866_163956&quot;&gt;
&lt;div class=&quot;sqs-block-content&quot;&gt;
&lt;pre class=&quot;source-code&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/pre&gt;
&lt;pre class=&quot;source-code&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/pre&gt;
Thank you for reading. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;Macjan Camilo Fernandes&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;sqs-block-content&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/784342380461827592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/784342380461827592?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/784342380461827592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/784342380461827592'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/12/ic-for-beginners-made-easy-generic-study.html' title='I²C for beginners made easy (Generic Study)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_HxU9Msyf5C1lcrL74zrbQza3pwymvsQWYva8EI8ZJwackMFPt-i8hhYV_9Va9DMWqtaDttSAG2zkoi3rvL6uchOy3Fr5y2Y-warMtsKZSkfXO2TLYuDqshMLIYxuxDytcS-72vFqNyI/s72-c/i2c1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-3779419353521770169</id><published>2014-12-21T18:13:00.000+05:30</published><updated>2014-12-21T18:13:00.978+05:30</updated><title type='text'>EEPROM Interfacing with 8051 using i2c (AT89C4051/AT89C51/AT89C52/AT89C52) Generic Driver</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;WARNING:&lt;/span&gt; THE CODE HAS BEEN TESTED AND WORKING SUCCESSFULLY.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
AIM: To make EEPROM interfacing to 8051 microcontrollers simpler with few functions pretested and no need further debugging. (AT89C4051/ AT89C51/ AT89C52/ AT89C55/ AT89S4051/ AT89S51/ AT89S52/ AT89S55 devices supported).&lt;br /&gt;
&lt;br /&gt;
BRIEF DESCRIPTION:&lt;br /&gt;
Interface Type: I2C Bit Banging mode.&lt;br /&gt;
EEPROM Type: &lt;b&gt;24LC512&lt;/b&gt; (Tested)&lt;br /&gt;
&lt;b&gt;Max Size on Flash Memory: 564Bytes.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;RAM use: 20Byte.&lt;/b&gt;&lt;br /&gt;
Microcontroller: AT89S52&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;TEST CIRCUIT:( KINDLY NOTE THE CIRCUIT ONLY INCLUDES I2C AND EEPROM CONNECTIONS. MICROCONTROLLER CONNECTIONS ARE NOT SHOWN)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2p4PMPUtxRu2CXdd2WnnrKPnWoYTOd3YAtP0qg37h7d_TR-5igDct9RqSGLlSCx__q2OwAJ6XonNHpg0guLm712a6hUx-3fTyH0tyQR8PgUty8q8k_lbK9-h1wjJFvkeBA19ujTASKyc/s1600/I2C.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2p4PMPUtxRu2CXdd2WnnrKPnWoYTOd3YAtP0qg37h7d_TR-5igDct9RqSGLlSCx__q2OwAJ6XonNHpg0guLm712a6hUx-3fTyH0tyQR8PgUty8q8k_lbK9-h1wjJFvkeBA19ujTASKyc/s1600/I2C.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to assign pins inside code???&lt;br /&gt;
&lt;br /&gt;
1. Go to &lt;b&gt;eeprom.h&lt;/b&gt;&lt;br /&gt;
2. change this area highlighted in red here. Assign pins properly.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEincJmU8ERkN9PMhaJMa02bTWj89Sow-hZs2YKNAJy1VSHDDV5_Tin84_3s5Hs2-KBtYEl7mBfDAXS4QzqmBN4cq9-1pERoR06_R0UAgkXsxO5rlCmd3p1QlJgPNEPnUoyoA_O4kXNwcI4/s1600/modify.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEincJmU8ERkN9PMhaJMa02bTWj89Sow-hZs2YKNAJy1VSHDDV5_Tin84_3s5Hs2-KBtYEl7mBfDAXS4QzqmBN4cq9-1pERoR06_R0UAgkXsxO5rlCmd3p1QlJgPNEPnUoyoA_O4kXNwcI4/s1600/modify.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
3. Include this files into your project.&lt;br /&gt;
4. Include eeprom.h in main.c&lt;br /&gt;
5. Make use of the functions given below and you are good to go.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Functions Added:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The functions below are the only functions you need to know for data reading and writing. The user has access to all 0x0000 to 0xFFFF addressing space.&lt;br /&gt;
&lt;br /&gt;
To write data to specific address use this instruction:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;void api_eeprom_write(BYTE addr_h,BYTE addr_l, BYTE data_b);&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
where,&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;BYTE addr_h &lt;/b&gt;= higher order of address.&lt;br /&gt;
&lt;b&gt;BYTE addr_l &lt;/b&gt;= lower order of address.&lt;br /&gt;
&lt;b&gt;BYTE data_b &lt;/b&gt;= data to be written.&lt;br /&gt;
&lt;br /&gt;
No Return Value. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The size of all above variables is 8-Bit or 1Byte.&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
How to use it???&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;unsigned char test=0x26; &lt;/b&gt;//8bit variable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;//enter test variable on eeprom at location 0x1022&lt;br /&gt;&lt;b&gt;api_eeprom_write(0x10,0x22, test); &lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;BYTE api_eeprom_read(BYTE addr_h,BYTE addr_l); &lt;/b&gt;//Read data from specific address&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
where,&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;BYTE addr_h &lt;/b&gt;= higher order of address.&lt;br /&gt;
&lt;b&gt;BYTE addr_l &lt;/b&gt;= lower order of address.&lt;br /&gt;
&lt;br /&gt;
Return Value = Data at that address 8bit&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;How to use it???&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;unsigned char test; &lt;/b&gt;//8bit variable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;//read eeprom at location 0x1022 and store the data into test variable&lt;br /&gt;&lt;b&gt;test = &lt;/b&gt;&lt;b&gt;api_eeprom_read(0x10,0x22);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&amp;nbsp;THE CODE IS AVAILABLE HERE &lt;a href=&quot;https://googledrive.com/host/0Bzq0D3ZT0_ddQ3FCdm50d0stR00&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;click here&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further modifications will include page writes/reads and array writes/reads. (code will be releasing shortly)&lt;br /&gt;
&lt;br /&gt;
Thank You for Reading,&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/3779419353521770169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/3779419353521770169?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/3779419353521770169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/3779419353521770169'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/12/eeprom-interfacing-with-8051-using-i2c.html' title='EEPROM Interfacing with 8051 using i2c (AT89C4051/AT89C51/AT89C52/AT89C52) Generic Driver'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2p4PMPUtxRu2CXdd2WnnrKPnWoYTOd3YAtP0qg37h7d_TR-5igDct9RqSGLlSCx__q2OwAJ6XonNHpg0guLm712a6hUx-3fTyH0tyQR8PgUty8q8k_lbK9-h1wjJFvkeBA19ujTASKyc/s72-c/I2C.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-8488814221140530251</id><published>2014-11-01T12:27:00.003+05:30</published><updated>2016-02-06T12:51:01.599+05:30</updated><title type='text'>Difference between Atmega8A and Atmega16A</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Today I will make you clear what&#39;s the difference between Atmega8A and Atmega16A microcontroller.&lt;br /&gt;
&lt;br /&gt;
To understand this you will need to download both the datasheets by clicking here.&lt;br /&gt;
&lt;a href=&quot;http://www.atmel.com/images/atmel-8159-8-bit-avr-microcontroller-atmega8a_datasheet.pdf&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;atmega8a&lt;/button&gt;&lt;/a&gt; and &lt;a href=&quot;http://www.atmel.com/Images/Atmel-8154-8-bit-AVR-ATmega16A_Datasheet.pdf&quot; target=&quot;_blank&quot;&gt;&lt;button&gt;atmega16a&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Lets begin with hardware wise:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHZJPfQvhrdgY4hg6VyaUXv4f7q5N75mTtj_aHUahXl_Dtiq2-zgDkrwYeNmDP8Ax75OpW9qXAuhqgfyY7Lfm442daEKpMlW1NZN_oUyPBIUImMmJ4LRTLbPx5nbyKwhK2rbvgXrOgqTg/s1600/atmega8a.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;301&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHZJPfQvhrdgY4hg6VyaUXv4f7q5N75mTtj_aHUahXl_Dtiq2-zgDkrwYeNmDP8Ax75OpW9qXAuhqgfyY7Lfm442daEKpMlW1NZN_oUyPBIUImMmJ4LRTLbPx5nbyKwhK2rbvgXrOgqTg/s1600/atmega8a.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Has two 8bit IO Ports and one 7bit IO Port. Altogether it makes &lt;b&gt;23 IO Pins&lt;/b&gt; available.&lt;/li&gt;
&lt;li&gt;Has &lt;b&gt;6 channel&lt;/b&gt; 10bit ADC each (PDIP package)&lt;/li&gt;
&lt;li&gt;Has AVR 8bit RISC Microprocessor working at 16MHz with &lt;b&gt;8KB Flash memory&lt;/b&gt;, 512bytes of EEPROM, and 1KB of internal SRAM.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9C4nXKWRZBtRu_UEuH8a7dbz9WXUtuDXl5dZsQ5JcOrp7O3-Fr9O2L0Z6CaQuQRYOc-ctGAuCjg4ogCC9bw3RaB7H12pm0sK1kt40evjMxM9dqDYttKeXdnGhc1xfQMl5AcAElQ8cv7U/s1600/atmega16a.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9C4nXKWRZBtRu_UEuH8a7dbz9WXUtuDXl5dZsQ5JcOrp7O3-Fr9O2L0Z6CaQuQRYOc-ctGAuCjg4ogCC9bw3RaB7H12pm0sK1kt40evjMxM9dqDYttKeXdnGhc1xfQMl5AcAElQ8cv7U/s1600/atmega16a.png&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Has four 8bit IO Ports and altogether makes&lt;b&gt; 32 IO Pins&lt;/b&gt; available.&lt;/li&gt;
&lt;li&gt;Has &lt;b&gt;8 channel &lt;/b&gt;10bit ADC each (PDIP package).&lt;/li&gt;
&lt;li&gt;Has 8bit AVR RISC Microprocessor working at 16MHz with &lt;b&gt;16KB Flash memory&lt;/b&gt;, 512bytes of EEPROM and 1KB of internal SRAM.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So In brief if you notice hardware wise the difference is in availability of number of IO pins, ADC channels and Programmable Flash Memory. So while choosing micrcontroller you need to make sure what type of application you want to use it in. Here are few points you can select microcontroller based on.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Does my application needs more IO&#39;s? Do I need external Interface say eg: LCD/ 7 Segment Displays etc.?&lt;/li&gt;
&lt;li&gt;How big will be my coding? Do I need extra flash memory interms of programming needs?&lt;/li&gt;
&lt;li&gt;How many analog inputs I&#39;ll be reading?&amp;nbsp; &lt;/li&gt;
&lt;/ul&gt;
This questions will answer the hardware needs of choosing between atmega8a and atmega16a. Sometimes you need even more IO&#39;s then you can chose multiplexing methods and also I2C based IO expander IC&#39;s.&lt;br /&gt;
&lt;br /&gt;
When you think your programming is based on C. I recommend you to take a microcontroller with more flash memory since C coding uses pointer based programming at times and may need more memory then when coded with assembly language.&lt;br /&gt;
&lt;br /&gt;
Size of the application also plays major role in selecting microcontroller. Say you want to make use of just 2 IO&#39;s and one ADC to do checking on voltage and say set LED&#39;s accordingly if its high or low. This application is very small and you do not need such a microcontroller with so many IO&#39;s. If you have no choice and you got to choose between Atmega8a and Atmega16a then you should choose Atmega8 for this above application. (for real: I recommend attiny microcontroller which is even smaller version of AVR controller).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Lets begin software wise:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
If you are using Atmel Studio 6 and above. You are asked to choose the microcontroller in beginning. You can that time select Atmega8a or Atmega16a. At this time, the software internally defines Atmega8a or Atmega16a. This hence automatically selects desired header files for the microcontroller you are working on.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;So in-case of programming IO&#39;s you can use IO registers which are available on that microcontroller as you are aware the atmega8a contains lesser IO&#39;s then the atmega16a. So in atmega8a you will not have access to IO register A since the port itself is not there. Also Pin PC7 is not there.&lt;/li&gt;
&lt;li&gt;In-case of analog channels you can only use 6 ADC channels. ADC channels 7,8 are not available on atmega8a.&lt;/li&gt;
&lt;li&gt;Overall Programming size you will get is up-to 8kb. You have to make sure you do the coding efficiently in C here. For larger applications on atmega8a; I recommend to use assembly language.&lt;/li&gt;
&lt;/ul&gt;
Now secondly, interms of code transfer. Since the microcontroller architecture is matching and the difference is only between IO&#39;s, ADC&#39;s and Flash memory. We can easily transfer the c code you designed for atmega8a to atmega16a. But c code designed for atmega16a cannot be transferred to atmega8a because of less IO&#39;s and ADC&#39;s unless your application has the IO ADC and Flash requirements on atmega8a.&lt;br /&gt;
&lt;br /&gt;
So,&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Concluding from above:&lt;/b&gt; You can use the same hardware and can program with c language which you studied for any of one of these microcontroller. Atmega8a code can be transferred to atmega16a and atmega16a code can be transferred to atmega8a without issues unless the IO requirements are sufficient on atmega8a. the Internal AVR RISC architecture of microcontroller remains the same.&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt; This also applies to atmega32a&lt;/b&gt;&lt;/span&gt; which I have not included to explain.&lt;br /&gt;
&lt;br /&gt;
In the names Atmega&lt;span style=&quot;color: red;&quot;&gt;&lt;u&gt;8&lt;/u&gt;&lt;/span&gt;a , atmega&lt;span style=&quot;color: red;&quot;&gt;&lt;u&gt;16&lt;/u&gt;&lt;/span&gt;a, and also atmega&lt;span style=&quot;color: red;&quot;&gt;&lt;u&gt;32&lt;/u&gt;&lt;/span&gt;a the red marked corresponds to Flash memory in KB and rest architecture wise is same for all.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading,&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/8488814221140530251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/8488814221140530251?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8488814221140530251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8488814221140530251'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/11/difference-between-atmega8a-and.html' title='Difference between Atmega8A and Atmega16A'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHZJPfQvhrdgY4hg6VyaUXv4f7q5N75mTtj_aHUahXl_Dtiq2-zgDkrwYeNmDP8Ax75OpW9qXAuhqgfyY7Lfm442daEKpMlW1NZN_oUyPBIUImMmJ4LRTLbPx5nbyKwhK2rbvgXrOgqTg/s72-c/atmega8a.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-7599266250436188075</id><published>2014-10-16T16:25:00.004+05:30</published><updated>2016-02-06T12:52:55.674+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="internet"/><category scheme="http://www.blogger.com/atom/ns#" term="No-IP"/><category scheme="http://www.blogger.com/atom/ns#" term="server"/><category scheme="http://www.blogger.com/atom/ns#" term="uno"/><category scheme="http://www.blogger.com/atom/ns#" term="w5100"/><title type='text'>Turn on LED On/Off from internet using Arduino UNO R3 based Webserver (mini IOT example)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Aim: To teach basics in connecting Arduino Uno R3 to internet with Arduino Web Server and to turn On/Off LED using the same. The hardware network is designed for beginners and is not professionally suggested.&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Things required:&lt;/b&gt;&lt;br /&gt;
Arduino Uno R3 board = 1 Qty.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL-oRzikIPT8c9mbAJ7RlWknTAGYtm3hD-KkMw3CwK-_X36ZffK6b7E-sbts_39VEwzGo8KIzc62UoXv5p2o25rJy8HtnOIVeOUJutMZnva7MBwPZIW7y-TaUbPODOWzEC6Xw5WrK2jlo/s1600/ArduinoUno_R3_Front.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;220&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL-oRzikIPT8c9mbAJ7RlWknTAGYtm3hD-KkMw3CwK-_X36ZffK6b7E-sbts_39VEwzGo8KIzc62UoXv5p2o25rJy8HtnOIVeOUJutMZnva7MBwPZIW7y-TaUbPODOWzEC6Xw5WrK2jlo/s1600/ArduinoUno_R3_Front.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
W5100 Ethernet Shield = 1 Qty.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjElcxwisdrYXI2lBRnhT-4rzYfhywY1zM0xvEMFx1tfDX8ykB0VWf1T_u6tbirXiTBolo5hqn7C9B0xDEeQTMPgqCoQmjFm-KQ8SJsUikTaxShnctCIc_j9w6njfWahr3D-S-_fGqAYuE/s1600/IMG-20141010-WA0001.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjElcxwisdrYXI2lBRnhT-4rzYfhywY1zM0xvEMFx1tfDX8ykB0VWf1T_u6tbirXiTBolo5hqn7C9B0xDEeQTMPgqCoQmjFm-KQ8SJsUikTaxShnctCIc_j9w6njfWahr3D-S-_fGqAYuE/s1600/IMG-20141010-WA0001.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Ethernet/ LAN Cable = 1 Qty.&lt;br /&gt;
Jumper Wire (male to male) = 2 Qty.&lt;br /&gt;
Red LED = 1 Qty.&lt;br /&gt;
Resistor 220 Ohms = 1 Qty.&lt;br /&gt;
Standard USB Cable A Plug to B Plug for Arduino = 1 Qty.&lt;br /&gt;
Laptop with Windows 7 Operating System.&lt;br /&gt;
Internet connection (USB dongle or Cable). I got Tata Photon+ 3G&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Softwares Required:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://downloads.arduino.cc/arduino-1.0.6-windows.exe&quot;&gt;&lt;button&gt;Arduino IDE&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
USB Drivers for Arduino&lt;br /&gt;
&lt;a href=&quot;http://www.noip.com/download?page=win&quot;&gt;&lt;button&gt;DuC&lt;/button&gt;&lt;/a&gt; (DNS Update Client) (from No-IP)&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/pjs-passport/&quot;&gt;&lt;button&gt;PassPort Utility&lt;/button&gt;&lt;/a&gt; on SourceForge.net&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Accounts Required:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.noip.com/&quot;&gt;&lt;button&gt;No-IP&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Knowledge Required:&lt;/b&gt;&lt;br /&gt;
Arduino Language.&lt;br /&gt;
HTML Language.&lt;br /&gt;
Google Drive.&lt;br /&gt;
Networking in Windows.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Block Diagram: &lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzRJ5vN3yeNx_8qR1Ad-HaW22YAvg2KXdM5L6ucxO3nwYVyuq5S6-MjKKoZMUBKCoI-THt5uMuosWo6ikNA0lFah-bKGeRmwPrMBJXmKM9AK9a48sE_i7oRiN0uWMsOr3iOuX3z7sz3cU/s1600/webserver1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;425&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzRJ5vN3yeNx_8qR1Ad-HaW22YAvg2KXdM5L6ucxO3nwYVyuq5S6-MjKKoZMUBKCoI-THt5uMuosWo6ikNA0lFah-bKGeRmwPrMBJXmKM9AK9a48sE_i7oRiN0uWMsOr3iOuX3z7sz3cU/s640/webserver1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;Connections shown through photographs:&lt;/b&gt;&lt;br /&gt;
(&lt;span style=&quot;color: red;&quot;&gt;Green Jumper Wire corresponds to Ground / Yellow Jumper Wire corresponds to Digital IO Pin 6 Output&lt;/span&gt;)&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlkyB_tN9UhXjiNoxXlMlISue8sxdUOT8kLtV41w-9O_BWDf5qBjY0yPcGm5D75mwZ98rOXPqxHIZP1STgzLxeE3Htj3yyycEMTOQcLZ0cflbexYii0YRew4UR9XJok8uC-4Y_I0gMBPo/s1600/CameraZOOM-20141016134903638.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlkyB_tN9UhXjiNoxXlMlISue8sxdUOT8kLtV41w-9O_BWDf5qBjY0yPcGm5D75mwZ98rOXPqxHIZP1STgzLxeE3Htj3yyycEMTOQcLZ0cflbexYii0YRew4UR9XJok8uC-4Y_I0gMBPo/s1600/CameraZOOM-20141016134903638.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;My Web Server Setup&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAQ0AqBphK5pb3VB9sGUQliJkh_pHphUNVeC2TRBRsuQE-rw_zmjtgLH-_jrpV12pvXAIp_HaesXfdwLcPecyAm5BOwRon1zZlkd85weczCTSh83pgM2VvWtKQBIX4LMt3fDW-Oa2NwM8/s1600/CameraZOOM-20141016135030565.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;482&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAQ0AqBphK5pb3VB9sGUQliJkh_pHphUNVeC2TRBRsuQE-rw_zmjtgLH-_jrpV12pvXAIp_HaesXfdwLcPecyAm5BOwRon1zZlkd85weczCTSh83pgM2VvWtKQBIX4LMt3fDW-Oa2NwM8/s1600/CameraZOOM-20141016135030565.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Red LED connected in Series with 22 Ohms for Current Limiting&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKkMboHr1khBjoT2Ga4kgmtfteqU1hf8t1gJCvIgrQApaOofxzorp_X82h3BDqgsBttC55Q2P4uEMC9sIFXziwRkQ0bGKW4jKaJIuDJmXlAR8n0h5tOqRaLtiCRlnj_IFm3wJjXmtawgU/s1600/CameraZOOM-20141016135048101.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;482&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKkMboHr1khBjoT2Ga4kgmtfteqU1hf8t1gJCvIgrQApaOofxzorp_X82h3BDqgsBttC55Q2P4uEMC9sIFXziwRkQ0bGKW4jKaJIuDJmXlAR8n0h5tOqRaLtiCRlnj_IFm3wJjXmtawgU/s1600/CameraZOOM-20141016135048101.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Arduino connection for Ground and Digital Output&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now Open Arduino IDE.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Open ethernet web server file using ( File - Examples - Ethernet - WebServer )&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In the Sketch first you will see&amp;nbsp; includes of SPI and Ethernet. Since communication to w5100 Ethernet Chip is done through SPI Interface and so do the SD Card but that feature we will come in next tutorial. The ethernet shield configuration is configured for W5100 IC. I don&#39;t know if the header file works for other controllers since I&#39;ve not tested them.&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWqH4RQzk1JXUPaUFiiVa7wxw-0HC16ktnZM5NEcBBRuiU3AU-jkMsE3SzNSiUwyxudl9PcAhTswhi9yC6rzBLzJiuudt8elZtXV8_2U5U01o6BsFESlZ0k4z284H99UeeSLGrrerlbek/s1600/Capture2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWqH4RQzk1JXUPaUFiiVa7wxw-0HC16ktnZM5NEcBBRuiU3AU-jkMsE3SzNSiUwyxudl9PcAhTswhi9yC6rzBLzJiuudt8elZtXV8_2U5U01o6BsFESlZ0k4z284H99UeeSLGrrerlbek/s1600/Capture2.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Basic Ethernet Initialization&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Then we store the mac address to the ethernet chip which is given to you on the hardware otherwise you can use this given mac_address from example (&lt;span style=&quot;color: red;&quot;&gt;0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&lt;/span&gt; ).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Then store IP address of your arduino ethernet shield. Mine is (&lt;span style=&quot;color: red;&quot;&gt;192.168.137.100&lt;/span&gt;) but you can modify this as per your configuration. For example my computer LAN IP address is &lt;span style=&quot;color: red;&quot;&gt;192.168.137.1&lt;/span&gt; . So as per that configuration I had to adjust arduino Ethernet IP address. &lt;b&gt;To change computer LAN Settings go to Control Panel - Network and Sharing Center - Change Adapter Settings - Local Area Connection - (Right Click) Properties - Internet Protocol Version (TCP/IPv4) - Properties - Select use follow IP address -&amp;nbsp; Change IP address to 192.168.137.1 - Change subnet mask to 255.255.255.0 and click OK&lt;/b&gt;. Your LAN settings are done. You can now officially link your arduino to computer through TCPIP protocol.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Next comes Ethernet Server PORT. Usually the example states port as &lt;span style=&quot;color: red;&quot;&gt;80&lt;/span&gt; but when you make your arduino available on web you usually should take port &lt;span style=&quot;color: red;&quot;&gt;8080&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So rewrite&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;EthernetServer server(8080);&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
With this settings itself now you are ready to go on Local network. After uploading code to arduino uno. You can open Internet Explorer/ Firefox/ Google chrome browser on your desktop/laptop.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
type in &lt;b&gt;http://192.168.137.100:8080&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You will be getting the browser page on LAN. The page will refresh every 5 seconds and will display analog input values which will get updated every 5 seconds as per page refresh.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Remember the code example includes HTML file which looks as below:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Wkft8t6IarByeO7c0RWBfZ4EVm2d3biRP9WiM0E2L3N_qO-HQsxUEO6QTtp7SNlj7SsTGcE-of763moAChq5j43WIFbRs5bWLArc2DNfW2nDRcAYoA22kUTmRbFpQVkm28PXhvGkg2g/s1600/Capture1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Wkft8t6IarByeO7c0RWBfZ4EVm2d3biRP9WiM0E2L3N_qO-HQsxUEO6QTtp7SNlj7SsTGcE-of763moAChq5j43WIFbRs5bWLArc2DNfW2nDRcAYoA22kUTmRbFpQVkm28PXhvGkg2g/s1600/Capture1.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
When you get this page on browser it will look like below:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrkgQh-KcmSTP5pq2-Tke9S6d_GbVKMWDGhheukRgL5PBzd5zzUMw25XlAVGjO5LilwNx3L3U9YmbKmxlzoKG4-KmqNeK53k3b_7KcdQVn4PHd3ccsGLcN4JXM6p1vljuIbGg8GlfAUdQ/s1600/Capture7.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrkgQh-KcmSTP5pq2-Tke9S6d_GbVKMWDGhheukRgL5PBzd5zzUMw25XlAVGjO5LilwNx3L3U9YmbKmxlzoKG4-KmqNeK53k3b_7KcdQVn4PHd3ccsGLcN4JXM6p1vljuIbGg8GlfAUdQ/s1600/Capture7.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
But to understand what was sent to client computer (your PC) you need to &lt;b&gt;Right Click - View Page Source&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqv-xPcQXQIeRgB1s08XeLfVdnoR1dxnLJB9wK_NWehU6IgQtB919ldomSt0444brPchykCPzNk3CzxcxsZ5QF4RRm9SSvc_H9-HS0hiwvRRPYeQJjwqEf5nzkYb_5pf_YDF2WkVdUx9s/s1600/Capture8.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqv-xPcQXQIeRgB1s08XeLfVdnoR1dxnLJB9wK_NWehU6IgQtB919ldomSt0444brPchykCPzNk3CzxcxsZ5QF4RRm9SSvc_H9-HS0hiwvRRPYeQJjwqEf5nzkYb_5pf_YDF2WkVdUx9s/s1600/Capture8.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The above picture will tell you what you received from arduino ethernet. Now compare this to your arduino web server code. Did you notice?? The HTML file lines are getting printed in &lt;b&gt;Client.println &lt;/b&gt;command which hence gets updated every 5 seconds which you will see as refresh 5 written.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
To modify this use your HTML Skills to make your modifications as per your settings. I cant help you with the HTML coding because its totally new topic. You got to learn on your own atleast some simple stuff.&lt;/div&gt;
&lt;br /&gt;
You can also download my code for turning On/Off LED. &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddZkRuSWtjUXJvQWs/view?usp=sharing&quot;&gt;&lt;button&gt;Click Here&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
You can view my page (Live) By &lt;a href=&quot;http://embeddedlifehelp.blogspot.in/p/blog-page_291.html&quot;&gt;&lt;button&gt;Click here&lt;/button&gt; &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I have tweaked some changes in webserver example file provided by arduino IDE to support my needs.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now upto here your setup will work only for LAN connections.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
How to make it available online???&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Since I&#39;m using USB dongle (photon&amp;nbsp;+) its IP address changes everytime I connect to the internet.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
To tackle this problem you need to make account on No-IP website which I provided above.&lt;/div&gt;
To sign up: &lt;a href=&quot;https://www.noip.com/sign-up&quot;&gt;&lt;button&gt;Click here&lt;/button&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Use hostname with ddns.net which is free. In this case I selected mine as &lt;b&gt;embeddedlife.ddns.net&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
After doing this procedure. Sign In.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
After signing in, click on &lt;b&gt;manage host. &lt;/b&gt;You will see your domain name (embeddedlife.ddns.net in my case).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Click on modify. Select host type as &lt;b&gt;Port 80 Redirect&lt;/b&gt;. This host is defined for server purposes so by default your port will be &lt;b&gt;8080&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Click on update host. And your job is done on this website. You can check all the features include on the website after mastering the whole idea.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Next is download &lt;b&gt;DuC (DNS Update Client)&lt;/b&gt; you can find the link above in software requirements.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
After installing. Run DuC as administrator. Enter user name and password.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrXvgvJYRrUfcUQUO49oIBmuE5kPbISw7c3MqwdubSfLneO_x5MDZiC6AY8uPH0fqsakwtA8po0wCdu3PgXWncGZpMnnDZckpCa2kSe7C9vL6Qo9pvcD-_BZCVBml5EGzNBtZClPGdeUA/s1600/Capture9.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrXvgvJYRrUfcUQUO49oIBmuE5kPbISw7c3MqwdubSfLneO_x5MDZiC6AY8uPH0fqsakwtA8po0wCdu3PgXWncGZpMnnDZckpCa2kSe7C9vL6Qo9pvcD-_BZCVBml5EGzNBtZClPGdeUA/s1600/Capture9.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You will get above information. Your present IP will be set in 3rd Tick mark. This IP in few minutes will be updated inside No-IP account using this software. To link host click on edit host/ select the domain then ok. Now&amp;nbsp; with this settings embeddedlife.ddns.net is linked to my recent IP address. This IP address changes every time you reconnect or error on your USB Dongle. So to make this IP Static in nature we need to make use of this tool. Thank you No-IP.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
But if you want permanent IP Address you can always ask your internet dealer for packages. Usually dedicated IP will cost you alot.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now secondly,&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You need to forward all the connections coming to your PC to Arduino because your Server lies there. Which can be done using &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Router only&lt;/span&gt;&lt;/b&gt;! With a method called &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;port forwarding&lt;/span&gt;&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
But I don&#39;t have a router connected to my computer!!! I have direct internet access through USB dongle, then what&#39;s the different method??&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
It took me days to find out what is an option here.&lt;/div&gt;
Well thank you to Sourceforge.net. From software requirements download &lt;b&gt;PassPort Utility&lt;/b&gt; from above.&lt;br /&gt;
&lt;br /&gt;
PassPort Utility looks like this: &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmopcfkTNRGE57-7URWV6ygiN0lwToeeOvlGKn2376lwT9cVAcwTwcxgP15PftE0AUSVO2IK8EaJjnR2TSO57XTU-VpzFK2MhyTgaDI_sqRs1MSSraMHdTqY7Ib_RmxYJiB4eGNY6TNns/s1600/Capture10.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmopcfkTNRGE57-7URWV6ygiN0lwToeeOvlGKn2376lwT9cVAcwTwcxgP15PftE0AUSVO2IK8EaJjnR2TSO57XTU-VpzFK2MhyTgaDI_sqRs1MSSraMHdTqY7Ib_RmxYJiB4eGNY6TNns/s1600/Capture10.PNG&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
Run the PassPort Utility as administrator. Then Click on service on menu. Install. It will install a service in &lt;b&gt;(right click on computer) - Manage - Services&lt;/b&gt;. Check for service named : &lt;b&gt;PassPort(Port forwarding)&lt;/b&gt; and click start if its not started.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
Now come back to PassPort Utility Software and click on &lt;b&gt;Define/view forwards&lt;/b&gt;. You will get the below screen:&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4YYP0N8XEiV-nfo6TeGoSo-G72hZlaza5IkgsDYGWI6_zP5AfRo9Y7wg5G3NPis3tIVNTMkv3zusB1ho2Mxq0IYMStkWra5iN8C7HOuiwSoyqpmHzqcytGEsXhFEIyyoib2FD9WAk_5A/s1600/Capture11.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4YYP0N8XEiV-nfo6TeGoSo-G72hZlaza5IkgsDYGWI6_zP5AfRo9Y7wg5G3NPis3tIVNTMkv3zusB1ho2Mxq0IYMStkWra5iN8C7HOuiwSoyqpmHzqcytGEsXhFEIyyoib2FD9WAk_5A/s1600/Capture11.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now we need to divert the incoming connection from internet to your arduino. That is done by editing source port as : IP Address visible on DuC. eg. on my computer IP was visible as &lt;b&gt;14.97.77.140 &lt;/b&gt;and I entered source address as &lt;b&gt;14.97.77.140 and port as 8080&lt;/b&gt; since your domain will direct you to this address and server responds to port 8080. This all will happen provided you keep DuC running. The above IP address is dynamic IP of your USB dongle which changes when you re connect to internet. But using No-IP we are making it static in nature. So now enter Target port/host address as you programmed in arduino that is&lt;b&gt; 192.168.137.100&lt;/b&gt; &lt;b&gt;and listens on port 8080&lt;/b&gt;. Select &lt;b&gt;TCP&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
And click Add. Then ok.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You can click on Start. Now PassPort Utility will act like Router and will divert port 8080 to your arduino.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;(NOTE: DuC and PassPort Utility and Internet needs to be ON all the time and so your Desktop/Laptop)&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now you are ready to go live. Try your mobile or any other computer with internet to access your own page. Mine looks like this on mobile check below:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJv47IFtwaztW5mfF5SR8xu8qm3zBQ5DyYTBDqlRnHWqg0axdGOIZ6V3UJkkTXL-1-WLy-FodW7fOlFcE5vSGCPA0Opsipha8RHHceLjZYSROER_4fHSInU80qn4t6XTgDTyJCFFjAlMY/s1600/2014-10-16_16-00-19.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJv47IFtwaztW5mfF5SR8xu8qm3zBQ5DyYTBDqlRnHWqg0axdGOIZ6V3UJkkTXL-1-WLy-FodW7fOlFcE5vSGCPA0Opsipha8RHHceLjZYSROER_4fHSInU80qn4t6XTgDTyJCFFjAlMY/s640/2014-10-16_16-00-19.png&quot; width=&quot;384&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Did you notice the LED color changes?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I personally created a PNG file using my ms paint software and updated it on Google Drive under (share settings as view as public). So there are basically 2 PNG files. One where LED is off and another where LED is on. So basically you can use Google Drive for saving your image files and using it. &lt;b&gt;To use images you select the image uploaded on Google file and on right side click on details. Copy the HOSTING address. This address will help you to print the image on your page. And not the share link Note it.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now everything is up to you with modifying the HTML and looks and making your server look smarter. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Advantages with this method:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Easy Learning.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
No router needed.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Possible way to create a webserver.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Without internet it acts like a local server and can be accessed locally through work network.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Can access your circuit using internet anywhere in the world.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Disadvantages with this method:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
DuC and PassPort needs to be ON and so your Desktop. Overall power consumption is more. This setup is suited for Offices which need servers only during working hours and not meant for home automation.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
So guys I hope you liked my tutorial on Web Server. But coming to my webserver. It is on only when I turn my computer On so never mind. &lt;b&gt;Now you can make your own.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXfiVdf4OKTpqO-JJ2GuiTUim-VkKXHONzOtTiDJmCna-_S-DuW_VmFhpdFvKXMNNcKs1oIhQRYCZsOQFMFNQBuGH4G6hF4LSx8b-RIz4bXAWBfhe7B9gXdo860eHI_7ZyPV_ChhTpt8Q/s1600/a.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXfiVdf4OKTpqO-JJ2GuiTUim-VkKXHONzOtTiDJmCna-_S-DuW_VmFhpdFvKXMNNcKs1oIhQRYCZsOQFMFNQBuGH4G6hF4LSx8b-RIz4bXAWBfhe7B9gXdo860eHI_7ZyPV_ChhTpt8Q/s1600/a.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Thank you for reading,&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/7599266250436188075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/7599266250436188075?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/7599266250436188075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/7599266250436188075'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/10/turn-on-led-onoff-from-internet-using.html' title='Turn on LED On/Off from internet using Arduino UNO R3 based Webserver (mini IOT example)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL-oRzikIPT8c9mbAJ7RlWknTAGYtm3hD-KkMw3CwK-_X36ZffK6b7E-sbts_39VEwzGo8KIzc62UoXv5p2o25rJy8HtnOIVeOUJutMZnva7MBwPZIW7y-TaUbPODOWzEC6Xw5WrK2jlo/s72-c/ArduinoUno_R3_Front.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-9109549785050214202</id><published>2014-06-15T19:28:00.001+05:30</published><updated>2016-02-06T12:53:48.159+05:30</updated><title type='text'>LED ON/ OFF using Serial Commands on Arduino Uno R3</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
For reference tutorial follow arduino website.&lt;br /&gt;
&lt;br /&gt;
This is a sketch for Arduino Uno I have written which when commanded on serial port turns LED ON/OFF at pin 13 (On board LED) so you do not need any additional hardware to test this code.&lt;br /&gt;
&lt;br /&gt;
Components required: Arduino Uno R3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh52O3adQc2Wr-IySjvlsnq0x135ibTejrVNzZGLX6SVosXqu7Xvivov1_su212fBuIOkQUP6cQeGmqMJUz66TPRPcCa6_S2YzRiul3J-wd9TC7ju1v_hyxiCtaIhu649uRT8mpwBhotiE/s1600/Look+at+this+photo+taken+with+Camera+ZOOM+FX.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;481&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh52O3adQc2Wr-IySjvlsnq0x135ibTejrVNzZGLX6SVosXqu7Xvivov1_su212fBuIOkQUP6cQeGmqMJUz66TPRPcCa6_S2YzRiul3J-wd9TC7ju1v_hyxiCtaIhu649uRT8mpwBhotiE/s1600/Look+at+this+photo+taken+with+Camera+ZOOM+FX.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Copy the sketch below and upload for testing:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;#include &quot;string.h&quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void setup()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; Serial.begin(9600);&lt;br /&gt;&amp;nbsp; pinMode(13,OUTPUT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void loop()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int i;&lt;br /&gt;&amp;nbsp; char rx_buffer[10];&lt;br /&gt;&amp;nbsp; Serial.print(&quot;Enter Command = &quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;=9;i++)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(Serial.available()==0);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rx_buffer[i]=Serial.read();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(rx_buffer[i]==&#39;;&#39;)break;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; if(strncmp(&quot;LED_ON&quot;,rx_buffer,6)==0)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(13,HIGH);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Serial.print(&quot;LED_ON;\n&quot;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else if(strncmp(&quot;LED_OFF&quot;,rx_buffer,7)==0)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(13,LOW);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Serial.print(&quot;LED_OFF;\n&quot;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Serial.print(&quot;Command Faulty\n&quot;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Commands to be entered:&lt;br /&gt;
LED_ON; -&amp;gt; To turn on LED&lt;br /&gt;
LED_OFF; -&amp;gt; To turn off LED&lt;br /&gt;
Anything else will respond Command Faulty.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Test screen(On Serial monitor):&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Enter Command = Command Faulty&lt;br /&gt;Enter Command = Command Faulty&lt;br /&gt;Enter Command = LED_ON;&lt;br /&gt;Enter Command = LED_OFF;&lt;br /&gt;Enter Command = LED_ON; &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Happy arduino programming&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/9109549785050214202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/9109549785050214202?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/9109549785050214202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/9109549785050214202'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/06/led-on-off-using-serial-commands-on.html' title='LED ON/ OFF using Serial Commands on Arduino Uno R3'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh52O3adQc2Wr-IySjvlsnq0x135ibTejrVNzZGLX6SVosXqu7Xvivov1_su212fBuIOkQUP6cQeGmqMJUz66TPRPcCa6_S2YzRiul3J-wd9TC7ju1v_hyxiCtaIhu649uRT8mpwBhotiE/s72-c/Look+at+this+photo+taken+with+Camera+ZOOM+FX.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-8443723339380923304</id><published>2014-05-11T17:10:00.000+05:30</published><updated>2016-02-06T12:54:44.769+05:30</updated><title type='text'>Create header files for AT89C51</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;AIM: To help you understand how the header files and source files are made for ease of programming.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I&#39;ve been asked questions many time regarding the header files and custom functions created for your own purpose say for Eg. to turn a port ON or to turn a particular port pin OFF. This basics extend so far you can create functions to most of the registers in 89C51 or any other microcontroller you want.&lt;br /&gt;
&lt;br /&gt;
To begin with lets make sure you learn something useful at the end so I will have to explain you with some example. I&#39;ll start with PORTS. I&#39;ll create a header and a source file for PORTS of 89C51. This both files which also will be also knows as custom library files for your ease will help you make programming easy then before.&lt;br /&gt;
Lets create a project in keil for 89C51-&amp;gt; So here it goes. So open keil. This is how it looks,&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGapZzeuUL5qiT8dpT9rm5n2Cx1jtQsAZn25VhblfSdychYsVkn-B7UAYKDkC_XSQXCwhS5WnDU1hJbC8pGvpe3HEmxkjcDtxRr-iOxyt7nW5lpJlE1YJP80fx6kCnhLxVbiJjc5ZSD4/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGapZzeuUL5qiT8dpT9rm5n2Cx1jtQsAZn25VhblfSdychYsVkn-B7UAYKDkC_XSQXCwhS5WnDU1hJbC8pGvpe3HEmxkjcDtxRr-iOxyt7nW5lpJlE1YJP80fx6kCnhLxVbiJjc5ZSD4/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Then Create a new project for your testing purpose. I have named the project as port. Select 89c51 as CPU. Then click ok.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQl1jkPaGitCFNPW5hSdswGY1I2NoZAjLJMwf7fmW774koU4Hf0-Wdahh29GKR2wduXCiqkuuSJ0isUI3oIKIzsIYAcbfcB3b7lSmqLYlEFxxyscSi8mGTKAem4-aQw7amH5eKm0kOxz0/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQl1jkPaGitCFNPW5hSdswGY1I2NoZAjLJMwf7fmW774koU4Hf0-Wdahh29GKR2wduXCiqkuuSJ0isUI3oIKIzsIYAcbfcB3b7lSmqLYlEFxxyscSi8mGTKAem4-aQw7amH5eKm0kOxz0/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now this is important part. I like to separate headers and source files into separate folders. Makes easy to know where they are located when the project is large. So Click on target and you will find &lt;b&gt;Source Group 1&lt;/b&gt; so Right click on that folder then Remove Source Group 1. Now right click on target and create two new folders called &lt;b&gt;Source&lt;/b&gt; and &lt;b&gt;Header&lt;/b&gt; by selecting &lt;b&gt;add group&lt;/b&gt;. Check the image below: (Check Left side for source and header folders inside target 1)&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVqSME6ypyexqZuQqul5ljyTWnowK3Xw0_pwqVpWUVoZoVunazROMAVFxNgJHWhamAYhPQFZH4_aoWDIDHNgWsvnv3u7-swem3Cv48hq0TE89mukzQ9H3HDniZKDi6g_AENgDlTgn1Rn4/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVqSME6ypyexqZuQqul5ljyTWnowK3Xw0_pwqVpWUVoZoVunazROMAVFxNgJHWhamAYhPQFZH4_aoWDIDHNgWsvnv3u7-swem3Cv48hq0TE89mukzQ9H3HDniZKDi6g_AENgDlTgn1Rn4/s1600/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click on Target 1-&amp;gt; Options for Target 1.&lt;br /&gt;
This are my settings for Target. 12MHz crystal, Use on - chip ROM. Check the image below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXkTyRGHckughcjScSKP734dpl6u8xtIweNDEj8jn9ROTl6MF4_DIcb7h0XJTe_IbT_0T51NpiCMzY_b6MthNPhtwcT4dYpJVEjfU4Ka6KSBFYVpV2OfORRJjR1SJaCQjYmNy5iiRBW3A/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXkTyRGHckughcjScSKP734dpl6u8xtIweNDEj8jn9ROTl6MF4_DIcb7h0XJTe_IbT_0T51NpiCMzY_b6MthNPhtwcT4dYpJVEjfU4Ka6KSBFYVpV2OfORRJjR1SJaCQjYmNy5iiRBW3A/s1600/4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click on Output Tab later after this settings, tick mark on create HEX file. (HEX-80) format. Now you are ready to start with programming.&lt;br /&gt;
Now create new files main.c , &lt;b&gt;port.h&lt;/b&gt; , and &lt;b&gt;port.c&lt;/b&gt; .&lt;br /&gt;
&lt;br /&gt;
In C programming &quot;filename.h&quot; files are basically called header files. This file contains mostly include files, variable declarations, function declarations, defines, etc. &quot;port.h&quot; will contain your function declarations and some include files needed to make those functions work. &quot;port.c&quot; file will contains the definitions of that function. This functions will resemble same as you will write in main.c so lets start with them. Create these three files and add them in respective folders. Check image below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE5WXxzJfgEwya-TM9mmaQQ6rkZYkYfyWu0QdaKi-Scibyf7hQv58OjSRWObGozqa_2aqN0sFjt20XrY-SCKKjmVDLhghPkVNcrYwMoxhOhBZkz6O1YOlRayoL-gefGdMIafiq1-5UUwk/s1600/5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE5WXxzJfgEwya-TM9mmaQQ6rkZYkYfyWu0QdaKi-Scibyf7hQv58OjSRWObGozqa_2aqN0sFjt20XrY-SCKKjmVDLhghPkVNcrYwMoxhOhBZkz6O1YOlRayoL-gefGdMIafiq1-5UUwk/s1600/5.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So to work with 89C51 microcontroller in Keil. First you need to know the include file made by keil itself. The register addresses are defined by keil header file. I mostly read &quot;REGX51.h&quot; It is in include folder inside keil compiler files (Folder &lt;b&gt;Keil -&amp;gt; C51 -&amp;gt;Atmel -&amp;gt;REGX51.h&lt;/b&gt;). Please do read it. Because I will be using the same registers below.&lt;br /&gt;
&lt;br /&gt;
So what functions do we want for the port? I have created these so far. Check below: (&lt;b&gt;port.h below&lt;/b&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjTyChxQT6sbbEjsTMeKXA8H0jLnVz2peigfd_GDJduICNLttTpulFx-B4f91FIbgbV6Yy4TDBvr3QzYiAtEQszVigMkeE9NtKbzG8CkaSw7S0dMwA6kdQ2HezWKDYlbtHBmrmq3V3-l8/s1600/6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjTyChxQT6sbbEjsTMeKXA8H0jLnVz2peigfd_GDJduICNLttTpulFx-B4f91FIbgbV6Yy4TDBvr3QzYiAtEQszVigMkeE9NtKbzG8CkaSw7S0dMwA6kdQ2HezWKDYlbtHBmrmq3V3-l8/s1600/6.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The above picture clearly explains what will be header file for your custom functions. You can name your function whatever you want. Plus you can do as many possible logic with it to get a outcome. Here I did few functions to set and clear port, also to set and clear pin on the port. So to make these functions work we need to create the definitions. So lets start with &lt;b&gt;port.c&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG_7wWrGAEqeeO3oRMJFXvs55TbfVknTAxblHF-9orVGr8rLc8_s5QKsqeSUfFp9UK1jb_6EVsdgQZsObDeiw3n-bWNZp4UJnEFF716dvf6nq1f3GNB8xDrNy2yq496O7iqwl6J4oPwhU/s1600/7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG_7wWrGAEqeeO3oRMJFXvs55TbfVknTAxblHF-9orVGr8rLc8_s5QKsqeSUfFp9UK1jb_6EVsdgQZsObDeiw3n-bWNZp4UJnEFF716dvf6nq1f3GNB8xDrNy2yq496O7iqwl6J4oPwhU/s1600/7.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So did you see what changes I have done. I have included port.h file in port.c file. It has to be done since the declarations have been defined there. Also notice the port.c file contains most of the definitions similar to main.c . Now lets use these header and source files for our multipurpose use. So I&#39;ll create a basic routine to test these functions on each port.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjzgWvzmayp2t_wm2MeBwn5290ZuMKPkLDgqtluB4oGCunScNgBdKblYFirmK5xw1aTSEfcwIhP44wzlSGFwo7nkNrz_6ICpliUH6EdEtVxrUWYFr41765fWUDQQfVwEvtLykYu2rmaGE/s1600/8.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjzgWvzmayp2t_wm2MeBwn5290ZuMKPkLDgqtluB4oGCunScNgBdKblYFirmK5xw1aTSEfcwIhP44wzlSGFwo7nkNrz_6ICpliUH6EdEtVxrUWYFr41765fWUDQQfVwEvtLykYu2rmaGE/s1600/8.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Did you see the changes I did in the main loop? Now I don&#39;t need to think much behind what ports are. Just my own functions are enough to know that this will set port and clear port.&lt;br /&gt;
&lt;br /&gt;
You can view the files here: ( &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddV0ZGSjJIVlpzclk/edit?usp=sharing&quot;&gt;main.c&lt;/a&gt;) ( &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_dddXJJVTNaOWtZT0U/edit?usp=sharing&quot;&gt;port.h&lt;/a&gt;) ( &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddNEctZkpjbXQ0WU0/edit?usp=sharing&quot;&gt;port.c&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
Or you can download the keil project here (&lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddZWVURy12M0ZkcVU/edit?usp=sharing&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What are the advantages behind this technique?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. Reduces code lines shows less complexity.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. Very easy to debug and find errors.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;3. The files can be copied and pasted into another project and can be used.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To make the code more fancy you can use this #define technique.&lt;br /&gt;
Right now you will write the function as &lt;b&gt;port_set(1);&lt;/b&gt;&lt;br /&gt;
So,&lt;br /&gt;
#define PORT1 1&lt;br /&gt;
This by putting in port.h you can now write the above function as &lt;b&gt;port_set(PORT1);&lt;/b&gt;&lt;br /&gt;
That makes code more user friendly and understandable.&lt;br /&gt;
&lt;br /&gt;
Also &lt;b&gt;case 1:&lt;/b&gt; in switch statement can be now replaced with above technique as &lt;b&gt;case PORT1:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So apply this technique and create header and source files for each hardware unit of 8051.&lt;b&gt; (&lt;/b&gt;timer, port, uart) etc.&lt;br /&gt;
&lt;br /&gt;
So hope you learned how to create header and source files. This will also help you understand how the header and source files are made and to be used which are included inside the compilers and libraries itself.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading,&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/8443723339380923304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/8443723339380923304?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8443723339380923304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8443723339380923304'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/05/create-header-files-for-at89c51.html' title='Create header files for AT89C51'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGapZzeuUL5qiT8dpT9rm5n2Cx1jtQsAZn25VhblfSdychYsVkn-B7UAYKDkC_XSQXCwhS5WnDU1hJbC8pGvpe3HEmxkjcDtxRr-iOxyt7nW5lpJlE1YJP80fx6kCnhLxVbiJjc5ZSD4/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-8363423798454065901</id><published>2014-05-03T17:14:00.003+05:30</published><updated>2016-12-20T22:38:38.121+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="1ms delay"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC16F877A"/><title type='text'>Delay function for PIC16F877A (delay in milli seconds)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Aim: To teach how to create delay function in milli seconds using internal timer.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
When I created milli second delay routine for 89C51 most of the readers told me what will it look like on PIC16F877A because they wanted precision timer for PIC microcontrollers too. So I&#39;ll explain you how to do it.&lt;br /&gt;
&lt;br /&gt;
To create delay we need to know few things below:&lt;br /&gt;
1. To calculate timer variable depending on crystal used.&lt;br /&gt;
2. To enable timer 1 for delay operation using ISR (Interrupt Service Routine)&lt;br /&gt;
3. To create delay routine to based on above timer.&lt;br /&gt;
4. How to interpret 1 microsecond timer based on above study. &lt;br /&gt;
&lt;br /&gt;
We will be using &lt;b&gt;Timer 1 in 16- bit mode&lt;/b&gt; for creating delay application.&lt;br /&gt;
Lets look at timer 1 block diagram in details so that I can show you what you need to know here.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifMmS56Mq8tnKvrGfb5MefDu-pkGWahBHCqVXlcNXe6wGJ6WW2FE_aPmyltVf3MQucyMnu2u0S9ltxQqyr5_eiO34hyphenhyphen5fCbet1BsYN0TEc6wJrDnJoavJYxJIpD-qwgawqIRDcSztOyeU/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifMmS56Mq8tnKvrGfb5MefDu-pkGWahBHCqVXlcNXe6wGJ6WW2FE_aPmyltVf3MQucyMnu2u0S9ltxQqyr5_eiO34hyphenhyphen5fCbet1BsYN0TEc6wJrDnJoavJYxJIpD-qwgawqIRDcSztOyeU/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is the logic diagram of timer 1 in PIC16F877A. You need to know that we are using &lt;b&gt;8MHz&lt;/b&gt; &lt;b&gt;Crystal&lt;/b&gt; and no external Clock generators. So we need to ignore external clock generators. So if you check this block diagram above TMR1CS chooses which clock to select. So obviously our 8MHz clock so you need to set &lt;b&gt;TMR1CS=0;&lt;/b&gt; so if you check it out this 8MHz clock is internally divided by 4 (FOSC/4), so this comes to &lt;b&gt;2MHz internally&lt;/b&gt;. When we are doing calculations we need to take this clock into consideration.&lt;br /&gt;
&lt;br /&gt;
Prescalar is kept 1:1 since we do not want to change our frequency. Since this is an internal clock we do not need to synchronize so &lt;b&gt;T1SYNC=1;&lt;/b&gt;&amp;nbsp; then finally when these settings are done you turn the timer on by giving &lt;b&gt;TMR1ON=1;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The timer counts get incremented in &lt;b&gt;TMR1H, TMR1L&lt;/b&gt; registers. If we set this register with timer value we calculated using crystal information and generate exact 1KHz we can create 1ms delay in no time.&lt;br /&gt;
&lt;br /&gt;
But this is not yet over. We need to know how this &lt;b&gt;timer 1 control register&lt;/b&gt; looks so here it is:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyvjYMussUXT9WZCcpfl6lOUcaOw6DvppV7tXoxCsPNIX_GxNYdJdWI12efe-x9dwAccyzLiWjgBS57sil35rkAOfY-ZI4EepSOxrSbXqooo6ZoiBCN7_Yhy2XeJdf847YWmfBDcoBcyY/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyvjYMussUXT9WZCcpfl6lOUcaOw6DvppV7tXoxCsPNIX_GxNYdJdWI12efe-x9dwAccyzLiWjgBS57sil35rkAOfY-ZI4EepSOxrSbXqooo6ZoiBCN7_Yhy2XeJdf847YWmfBDcoBcyY/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So what will go inside T1CON register according to you for this settings???&lt;br /&gt;
Ans: &lt;b&gt;T1CONbits.T1SYNC=1;&lt;/b&gt; //T1 needs to be on when delay function starts. We can&#39;t keep timer running.&lt;br /&gt;
&lt;br /&gt;
Now we need to configure Interrupt registers since we need interrupt to be generated in exact 1ms delay.&lt;br /&gt;
So lets have a look at interrupt control register. (INTCON)&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifkTrOYcqhTpR9A488qoAEosMJ9AG-ueXzG5jMg-8TRIwnzgvjHh4bsbUXMdegZVSoumIW4xMuTEr8y6fMcV5H9Fh7mlnakcVPZVq_ds-By7V6Rf_cnanIJS2mamKYrB5rI-ZssurkVXQ/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifkTrOYcqhTpR9A488qoAEosMJ9AG-ueXzG5jMg-8TRIwnzgvjHh4bsbUXMdegZVSoumIW4xMuTEr8y6fMcV5H9Fh7mlnakcVPZVq_ds-By7V6Rf_cnanIJS2mamKYrB5rI-ZssurkVXQ/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Here you need to set only 2 bits. &lt;b&gt;INTCONbits.GIE=1;&lt;/b&gt;(Global Interrupt Enable Bit)  to enable all the interrupts.&lt;br /&gt;
&lt;b&gt;INTCONbits.PEIE=1;&lt;/b&gt; (Peripheral Interrupt Enable Bit) to enable interrupts related to peripherals.&lt;br /&gt;
&lt;br /&gt;
Then, after enabling global and peripheral interrupts we need to enable timer 1 interrupt enable flag. That can be set from &lt;b&gt;PIE&lt;/b&gt; register.&lt;br /&gt;
&lt;b&gt;PIE1bits.TMR1IE=1;&lt;/b&gt; // Making this bit to 1 enables timer 1 overflow interrupt flag.&lt;br /&gt;
&lt;br /&gt;
So finally you know all the registers to be studied to work with delay timer. Now lets work how to create a 1ms delay for &lt;b&gt;8MHz Clock&lt;/b&gt; (8MHz crystal used).&lt;br /&gt;
&lt;br /&gt;
So I had said that we need to save timer preset value &lt;b&gt;Tpreset&lt;/b&gt; in TMR1H and TMR1L register.&lt;br /&gt;
&lt;br /&gt;
So 8MHz internally divided (FOSC/4) which gives us 2MHz frequency = Fosc;&lt;br /&gt;
Considering prescale is 1:1.&lt;br /&gt;
2MHz/2000 =1000; // 2MHz is divided with 2000 to give 1000 = 1Khz; 1/F = 1ms.&lt;br /&gt;
So since timer value in 16 bit register can go upto from 0 to 65535 and considering counts also go incrementing here. We will have to manipulate and put the count in such a way once it reaches 65535 will become 1ms interrupt.&lt;br /&gt;
So 65535 - 2000 = 63535 = 0xF82F in hex. And this Tpreset = 0xF82F;&lt;br /&gt;
So we need to make&lt;br /&gt;
&lt;b&gt;TMR1H = 0xF8;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TMR1L = 0x2F;&lt;/b&gt;&lt;br /&gt;
Now we will get exact 1KHz since the count will increment from 0x0XF82F to 0XFFFF which will give us 2000 difference hence creating 1ms delay.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;If you understood above concept properly what will be the Tpreset if Crystal is 8MHz and you wanted to create 1 micro seconds delay???&lt;/b&gt;&lt;br /&gt;
8MHz/4 = 2MHz = Fosc&lt;br /&gt;
2MHz/2 = 1MHz = 1uS interrupt (1/F=T)&lt;br /&gt;
65535-2 = 65533 = 0xFFFD in hex. So Tpreset = 0xFFFD&lt;br /&gt;
&lt;b&gt;TMR1H = 0xFF;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TMR1L=0xFD;&lt;/b&gt;&lt;br /&gt;
This values if you put in my code ahead, this will give you 1 micro second delay.&lt;br /&gt;
&lt;br /&gt;
You can use the below calculator for determining decimal value for TMR1 Register. &lt;br /&gt;
&lt;br /&gt;
&lt;form name=&quot;timer_calc&quot; oninput=&quot;update()&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;PIC16F877A TIMER 1 CALCULATOR FOR DELAY (* Required Fields)&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
Enter Crystal Clock =
&lt;input id=&quot;a&quot; type=&quot;number&quot; value=&quot;&quot; /&gt;MHz (use range 1 MHz - 20MHz)&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;br /&gt;
Enter Prescalar Value =
&lt;input id=&quot;b&quot; type=&quot;number&quot; value=&quot;&quot; /&gt;(use range 1 to 4)&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;br /&gt;
Fin to the timer 1 = 
&lt;output a=&quot;&quot; b=&quot;&quot; for=&quot;&quot; name=&quot;x&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;Hz
&lt;br /&gt;
Minimum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;y&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Maximum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;z&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Interrupt delay required (Use above delay limits) = 
&lt;input id=&quot;dl&quot; type=&quot;number&quot; value=&quot;&quot; /&gt;mS&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;br /&gt;
&lt;button onclick=&quot;calculate()&quot; type=&quot;button&quot;&gt;Calculate&lt;/button&gt;
Timer (TMR1) Register Value in Decimal = 
&lt;output for=&quot;x a b&quot; name=&quot;cdd&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;script&gt;
var Ftest = document.timer_calc;
var fosc;
var prescaled;
var t;
var min;
var max;
var value;
var value_t;
function calculate()
{
value_t=Ftest.dl.value/(min*1000);
Ftest.cdd.value=65535-value_t;
}

function update()
{
fosc=Ftest.a.value*1000000/4;
prescaled=fosc/Ftest.b.value;
Ftest.x.value=prescaled;
t=1/prescaled;
min=t;
Ftest.y.value=min*1000;
max=65535*t;
Ftest.z.value=max*1000;
}



&lt;/script&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;So lets proceed to use this technique to our advantage and create 1ms delay.&lt;br /&gt;
&lt;br /&gt;
Check the code here (&lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_dddmVQNS1INmEyNWc/edit?usp=sharing&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
Or you can download MPLABX project here (&lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddZ2FlSWxkVzJKdFU/edit?usp=sharing&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;This code will now generate 1000ms = 1 second delay and will blink LED to 1Seconds delay time using this wonderful timer method.&lt;br /&gt;
&lt;br /&gt;
So remember how to make use of timer by setting up preset value in 16 bit timer register.&lt;br /&gt;
&lt;br /&gt;
So all the best in programming with PIC16F877A. You can use this schematic for above demo purpose (&lt;a href=&quot;http://embeddedlifehelp.blogspot.in/2010/02/pic-16f877a-help.html&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
If there is any query regarding timer let me know.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R&amp;amp;D)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/8363423798454065901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/8363423798454065901?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8363423798454065901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/8363423798454065901'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/05/delay-function-for-pic16f877a-delay-in_3.html' title='Delay function for PIC16F877A (delay in milli seconds)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifMmS56Mq8tnKvrGfb5MefDu-pkGWahBHCqVXlcNXe6wGJ6WW2FE_aPmyltVf3MQucyMnu2u0S9ltxQqyr5_eiO34hyphenhyphen5fCbet1BsYN0TEc6wJrDnJoavJYxJIpD-qwgawqIRDcSztOyeU/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-3605011892680144745</id><published>2014-05-03T17:14:00.002+05:30</published><updated>2016-10-21T20:25:17.096+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="1ms delay"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC16F877A"/><title type='text'>Delay function for PIC16F877A (delay in milli seconds)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Aim: To teach how to create delay function in milli seconds using internal timer.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
When I created milli second delay routine for 89C51 most of the readers told me what will it look like on PIC16F877A because they wanted precision timer for PIC microcontrollers too. So I&#39;ll explain you how to do it.&lt;br /&gt;
&lt;br /&gt;
To create delay we need to know few things below:&lt;br /&gt;
1. To calculate timer variable depending on crystal used.&lt;br /&gt;
2. To enable timer 1 for delay operation using ISR (Interrupt Service Routine)&lt;br /&gt;
3. To create delay routine to based on above timer.&lt;br /&gt;
4. How to interpret 1 microsecond timer based on above study. &lt;br /&gt;
&lt;br /&gt;
We will be using &lt;b&gt;Timer 1 in 16- bit mode&lt;/b&gt; for creating delay application.&lt;br /&gt;
Lets look at timer 1 block diagram in details so that I can show you what you need to know here.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifMmS56Mq8tnKvrGfb5MefDu-pkGWahBHCqVXlcNXe6wGJ6WW2FE_aPmyltVf3MQucyMnu2u0S9ltxQqyr5_eiO34hyphenhyphen5fCbet1BsYN0TEc6wJrDnJoavJYxJIpD-qwgawqIRDcSztOyeU/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifMmS56Mq8tnKvrGfb5MefDu-pkGWahBHCqVXlcNXe6wGJ6WW2FE_aPmyltVf3MQucyMnu2u0S9ltxQqyr5_eiO34hyphenhyphen5fCbet1BsYN0TEc6wJrDnJoavJYxJIpD-qwgawqIRDcSztOyeU/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is the logic diagram of timer 1 in PIC16F877A. You need to know that we are using &lt;b&gt;8MHz&lt;/b&gt; &lt;b&gt;Crystal&lt;/b&gt; and no external Clock generators. So we need to ignore external clock generators. So if you check this block diagram above TMR1CS chooses which clock to select. So obviously our 8MHz clock so you need to set &lt;b&gt;TMR1CS=0;&lt;/b&gt; so if you check it out this 8MHz clock is internally divided by 4 (FOSC/4), so this comes to &lt;b&gt;2MHz internally&lt;/b&gt;. When we are doing calculations we need to take this clock into consideration.&lt;br /&gt;
&lt;br /&gt;
Prescalar is kept 1:1 since we do not want to change our frequency. Since this is an internal clock we do not need to synchronize so &lt;b&gt;T1SYNC=1;&lt;/b&gt;&amp;nbsp; then finally when these settings are done you turn the timer on by giving &lt;b&gt;TMR1ON=1;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The timer counts get incremented in &lt;b&gt;TMR1H, TMR1L&lt;/b&gt; registers. If we set this register with timer value we calculated using crystal information and generate exact 1KHz we can create 1ms delay in no time.&lt;br /&gt;
&lt;br /&gt;
But this is not yet over. We need to know how this &lt;b&gt;timer 1 control register&lt;/b&gt; looks so here it is:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyvjYMussUXT9WZCcpfl6lOUcaOw6DvppV7tXoxCsPNIX_GxNYdJdWI12efe-x9dwAccyzLiWjgBS57sil35rkAOfY-ZI4EepSOxrSbXqooo6ZoiBCN7_Yhy2XeJdf847YWmfBDcoBcyY/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyvjYMussUXT9WZCcpfl6lOUcaOw6DvppV7tXoxCsPNIX_GxNYdJdWI12efe-x9dwAccyzLiWjgBS57sil35rkAOfY-ZI4EepSOxrSbXqooo6ZoiBCN7_Yhy2XeJdf847YWmfBDcoBcyY/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So what will go inside T1CON register according to you for this settings???&lt;br /&gt;
Ans: &lt;b&gt;T1CONbits.T1SYNC=1;&lt;/b&gt; //T1 needs to be on when delay function starts. We can&#39;t keep timer running.&lt;br /&gt;
&lt;br /&gt;
Now we need to configure Interrupt registers since we need interrupt to be generated in exact 1ms delay.&lt;br /&gt;
So lets have a look at interrupt control register. (INTCON)&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifkTrOYcqhTpR9A488qoAEosMJ9AG-ueXzG5jMg-8TRIwnzgvjHh4bsbUXMdegZVSoumIW4xMuTEr8y6fMcV5H9Fh7mlnakcVPZVq_ds-By7V6Rf_cnanIJS2mamKYrB5rI-ZssurkVXQ/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifkTrOYcqhTpR9A488qoAEosMJ9AG-ueXzG5jMg-8TRIwnzgvjHh4bsbUXMdegZVSoumIW4xMuTEr8y6fMcV5H9Fh7mlnakcVPZVq_ds-By7V6Rf_cnanIJS2mamKYrB5rI-ZssurkVXQ/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Here you need to set only 2 bits. &lt;b&gt;INTCONbits.GIE=1;&lt;/b&gt;(Global Interrupt Enable Bit)  to enable all the interrupts.&lt;br /&gt;
&lt;b&gt;INTCONbits.PEIE=1;&lt;/b&gt; (Peripheral Interrupt Enable Bit) to enable interrupts related to peripherals.&lt;br /&gt;
&lt;br /&gt;
Then, after enabling global and peripheral interrupts we need to enable timer 1 interrupt enable flag. That can be set from &lt;b&gt;PIE&lt;/b&gt; register.&lt;br /&gt;
&lt;b&gt;PIE1bits.TMR1IE=1;&lt;/b&gt; // Making this bit to 1 enables timer 1 overflow interrupt flag.&lt;br /&gt;
&lt;br /&gt;
So finally you know all the registers to be studied to work with delay timer. Now lets work how to create a 1ms delay for &lt;b&gt;8MHz Clock&lt;/b&gt; (8MHz crystal used).&lt;br /&gt;
&lt;br /&gt;
So I had said that we need to save timer preset value &lt;b&gt;Tpreset&lt;/b&gt; in TMR1H and TMR1L register.&lt;br /&gt;
&lt;br /&gt;
So 8MHz internally divided (FOSC/4) which gives us 2MHz frequency = Fosc;&lt;br /&gt;
Considering prescale is 1:1.&lt;br /&gt;
2MHz/2000 =1000; // 2MHz is divided with 2000 to give 1000 = 1Khz; 1/F = 1ms.&lt;br /&gt;
So since timer value in 16 bit register can go upto from 0 to 65535 and considering counts also go incrementing here. We will have to manipulate and put the count in such a way once it reaches 65535 will become 1ms interrupt.&lt;br /&gt;
So 65535 - 2000 = 63535 = 0xF82F in hex. And this Tpreset = 0xF82F;&lt;br /&gt;
So we need to make&lt;br /&gt;
&lt;b&gt;TMR1H = 0xF8;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TMR1L = 0x2F;&lt;/b&gt;&lt;br /&gt;
Now we will get exact 1KHz since the count will increment from 0x0XF82F to 0XFFFF which will give us 2000 difference hence creating 1ms delay.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;If you understood above concept properly what will be the Tpreset if Crystal is 8MHz and you wanted to create 1 micro seconds delay???&lt;/b&gt;&lt;br /&gt;
8MHz/4 = 2MHz = Fosc&lt;br /&gt;
2MHz/2 = 1MHz = 1uS interrupt (1/F=T)&lt;br /&gt;
65535-2 = 65533 = 0xFFFD in hex. So Tpreset = 0xFFFD&lt;br /&gt;
&lt;b&gt;TMR1H = 0xFF;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TMR1L=0xFD;&lt;/b&gt;&lt;br /&gt;
This values if you put in my code ahead, this will give you 1 micro second delay.&lt;br /&gt;
&lt;br /&gt;
You can use the below calculator for determining decimal value for TMR1 Register. &lt;br /&gt;
&lt;br /&gt;
&lt;form name=&quot;timer_calc&quot; oninput=&quot;update()&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;PIC16F877A TIMER 1 CALCULATOR FOR DELAY (* Required Fields)&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
Enter Crystal Clock =
&lt;input id=&quot;a&quot; type=&quot;number&quot; value=&quot;&quot; /&gt;MHz (use range 1 MHz - 20MHz)&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;br /&gt;
Enter Prescalar Value =
&lt;input id=&quot;b&quot; type=&quot;number&quot; value=&quot;&quot; /&gt;(use range 1 to 4)&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;br /&gt;
Fin to the timer 1 = 
&lt;output a=&quot;&quot; b=&quot;&quot; for=&quot;&quot; name=&quot;x&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;Hz
&lt;br /&gt;
Minimum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;y&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Maximum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;z&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Interrupt delay required (Use above delay limits) = 
&lt;input id=&quot;dl&quot; type=&quot;number&quot; value=&quot;&quot; /&gt;mS&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;br /&gt;
&lt;button onclick=&quot;calculate()&quot; type=&quot;button&quot;&gt;Calculate&lt;/button&gt;
Timer (TMR1) Register Value in Decimal = 
&lt;output for=&quot;x a b&quot; name=&quot;cdd&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;script&gt;
var Ftest = document.timer_calc;
var fosc;
var prescaled;
var t;
var min;
var max;
var value;
var value_t;
function calculate()
{
value_t=Ftest.dl.value/(min*1000);
Ftest.cdd.value=65535-value_t;
}

function update()
{
fosc=Ftest.a.value*1000000/4;
prescaled=fosc/Ftest.b.value;
Ftest.x.value=prescaled;
t=1/prescaled;
min=t;
Ftest.y.value=min*1000;
max=65535*t;
Ftest.z.value=max*1000;
}



&lt;/script&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;So lets proceed to use this technique to our advantage and create 1ms delay.&lt;br /&gt;
&lt;br /&gt;
Check the code here (&lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_dddmVQNS1INmEyNWc/edit?usp=sharing&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
Or you can download MPLABX project here (&lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddZ2FlSWxkVzJKdFU/edit?usp=sharing&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;This code will now generate 1000ms = 1 second delay and will blink LED to 1Seconds delay time using this wonderful timer method.&lt;br /&gt;
&lt;br /&gt;
So remember how to make use of timer by setting up preset value in 16 bit timer register.&lt;br /&gt;
&lt;br /&gt;
So all the best in programming with PIC16F877A. You can use this schematic for above demo purpose (&lt;a href=&quot;http://embeddedlifehelp.blogspot.in/2010/02/pic-16f877a-help.html&quot;&gt;click here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
If there is any query regarding timer let me know.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R&amp;amp;D)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/3605011892680144745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/3605011892680144745?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/3605011892680144745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/3605011892680144745'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/05/delay-function-for-pic16f877a-delay-in.html' title='Delay function for PIC16F877A (delay in milli seconds)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifMmS56Mq8tnKvrGfb5MefDu-pkGWahBHCqVXlcNXe6wGJ6WW2FE_aPmyltVf3MQucyMnu2u0S9ltxQqyr5_eiO34hyphenhyphen5fCbet1BsYN0TEc6wJrDnJoavJYxJIpD-qwgawqIRDcSztOyeU/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-4476761819078234001</id><published>2014-04-30T18:38:00.003+05:30</published><updated>2016-02-06T12:56:44.013+05:30</updated><title type='text'>PIC12F510 based Voltage Trigger Switch (Industrial)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;AIM: Based upon 0 - 10V input from the Analog In terminal; upon reaching trigger voltage triggers the Relay hence driving the third party device.&lt;/b&gt; LED Indicator or a Buzzer used as a second option.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve designed this small device for demo how industrial circuits are designed. For instance the &lt;b&gt;Supply voltage&lt;/b&gt; is always &lt;b&gt;+24V&lt;/b&gt;. The &lt;b&gt;Analog input voltage&lt;/b&gt; range is always from &lt;b&gt;0V - 10V&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
First things are first, you should know all the sensors used in industries to design circuit for them. Most common of them include inductive sensors, proximity sensors, flow sensors, and most common limit switches. We going to use linear potentiometer sensor which is another type used for measuring distance etc.&lt;br /&gt;
&lt;br /&gt;
There are many books online regarding the sensor selection and industrial sensors.&lt;br /&gt;
&lt;br /&gt;
Things you will need to work with this project:&lt;br /&gt;
1. PIC KIT2 programmer or higher ICD&lt;br /&gt;
2. MPLABX software along with X8 compiler both by microchip.&lt;br /&gt;
3. Some knowledge about PIC12F510 ADC and GPIO.&lt;br /&gt;
4. Components&lt;br /&gt;
&lt;br /&gt;
You can download PCB Gerber files here (&lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddZ1ZDUlBYSlNYaVk/edit?usp=sharing&quot;&gt;click here&lt;/a&gt;) (PCB done with easily available components)&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyAEdwsOQuYVLLKZ1yFFEKQhQtgBngxt9AZOmg-x_W-EZce2AVFa14bDzjFVXc5Njn8j0_DEgpXalm5fmNVlOBwM9Hj2xPzVmgN2NM1d69_eZL-HlUR7yYyxPI-p7o_5jQDveAwoI2GvU/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyAEdwsOQuYVLLKZ1yFFEKQhQtgBngxt9AZOmg-x_W-EZce2AVFa14bDzjFVXc5Njn8j0_DEgpXalm5fmNVlOBwM9Hj2xPzVmgN2NM1d69_eZL-HlUR7yYyxPI-p7o_5jQDveAwoI2GvU/s1600/Capture.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Components needed:&lt;br /&gt;
C2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.001uF&lt;br /&gt;
C1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.1uF&lt;br /&gt;
R5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10K 1/4w&lt;br /&gt;
F1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1A&lt;br /&gt;
R2,R3,R6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1K&lt;br /&gt;
D1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1N4007&lt;br /&gt;
R1,R4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 500E 1/4w&lt;br /&gt;
U2,U4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 Pin Terminal Block&lt;br /&gt;
Q1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; BC547&lt;br /&gt;
RLY1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; G5LE 10A 24VDC RELAY&lt;br /&gt;
U3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LM158&lt;br /&gt;
U1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LM7805&lt;br /&gt;
U5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIC12F510&lt;br /&gt;
J1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 PIN Terminal Block&lt;br /&gt;
SW1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Tactile Switch&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Secondly the circuit. Lets look around the schematic below :&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJhzZdpOnoJDPTYk2_k20EERwKaeWazCVdSNdza1XdWzYdnDfsz65_y5g6ZvQs5D8-qdiXCo4kdK6wofrme5-5akAmCuTbi46IEWSXGkJYRlkIAvvfv9cMYLBqeQGtV5ShFqgya6d2o0c/s1600/VOLTAGE+TRIGGER.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJhzZdpOnoJDPTYk2_k20EERwKaeWazCVdSNdza1XdWzYdnDfsz65_y5g6ZvQs5D8-qdiXCo4kdK6wofrme5-5akAmCuTbi46IEWSXGkJYRlkIAvvfv9cMYLBqeQGtV5ShFqgya6d2o0c/s1600/VOLTAGE+TRIGGER.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;The power supply section:&lt;/b&gt;&lt;br /&gt;
Includes Supply IN terminal. Most of the industrial automation circuits makes use of terminal blocks in their circuit where you can plug in multi - stranded wire. Since this device will be powered by external source (SMPS), we need not put much filters inside in our power supply regulator &lt;a href=&quot;http://www.fairchildsemi.com/ds/LM/LM7805.pdf&quot;&gt;LM7805&lt;/a&gt;. This regulator is needed for supplying +5V to our microcontroller PIC12F510. We also need to provide fuse since this device will be used in industry, the fuse is a must to prevent short circuit accidents.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Analog input section:&lt;/b&gt;&lt;br /&gt;
The analog input section consists of dual op-amp &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm158-n.pdf&quot;&gt;LM158&lt;/a&gt;. It doesn&#39;t require dual power supply. But it has feature of internally dividing the VCC into half to use it as dual supply. This &lt;b&gt;op-amp&lt;/b&gt; is used in &lt;b&gt;non - inverting mode&lt;/b&gt; in such a way that &lt;b&gt;output = 1/2 of input&lt;/b&gt;. This is because the input we going to use will only go up to +10v (analog output voltage of another device). And the Vref voltage of our PIC12F510 is +5V. The maximum input voltage converted will be up to +5V.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Microcontroller section:&lt;/b&gt;&lt;br /&gt;
The microcontroller section includes PIC12F510 microcontroller (widely used among hobbyists so I had to select it as example). You can use different microcontroller available in your market. The reset switch is to reset the microcontroller. The microcontroller has been software wise programmed to have &lt;b&gt;internal oscillator working at 8MHz&lt;/b&gt;. So no external oscillator required.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Relay driver section:&lt;/b&gt;&lt;br /&gt;
The relay driver section includes npn transistor driver using BC547(most common). The relay used is G5LE base type (for pcb&#39;s). Has ratings of 10A, +24V dc. The diode is used for preventing back emf from the relay and to protect the circuit from damaging. You can replace the relay with Buzzer for alarm application. Using buzzer as alarm here will give rise to &lt;b&gt;Voltage trigger based alarm&lt;/b&gt; as a new project.&lt;br /&gt;
&lt;br /&gt;
Software Code: (compiled with MPLABX)&lt;br /&gt;
Please &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddaGdWQVZ2akVaZUk/edit?usp=sharing&quot;&gt;click here&lt;/a&gt; for code.&lt;br /&gt;
You can also download the &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddN2xEVURySVJ3LTg/edit?usp=sharing&quot;&gt;project here&lt;/a&gt; along with the hex file.&lt;br /&gt;
&lt;br /&gt;
The code has been explained inside. But you need to know this formula here&lt;br /&gt;
&lt;br /&gt;
ADC is 8bit. Means 2^8=256 value max.&lt;br /&gt;
Vref = +5V (That is Vdd)&lt;br /&gt;
Vtrg = (Trigger voltage you want)&lt;br /&gt;
Value = Value you need to put in the if statement of trigger relay.&lt;br /&gt;
Value_reset = Value you need to put in if statement of reset relay.&lt;br /&gt;
&lt;br /&gt;
Value = (256/5) * (Vtrg/2).&lt;br /&gt;
&lt;br /&gt;
Value_reset = ((256/5) * (Vtrg/2))-10;&lt;br /&gt;
&lt;br /&gt;
The reset value is kept little lower that the trigger value to avoid flickering of relay. This happens when the adc value is not stable at trigger voltage. The flakiness in analog read can reset or trigger relay continuously giving rise to chattering of relay.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The modifications:&lt;/b&gt;&lt;br /&gt;
1. Buzzer can be included in cases of Emergency Stop alert or Alarm.&lt;br /&gt;
2. LED indicator can be added for visual display of trigger.&lt;br /&gt;
&lt;br /&gt;
So this is one of the example how to create industrial circuits. But this is not all of it. There are EMI EMC testing on these circuits so you need to add some filter diodes at input sides. Most of the IC&#39;s do contain the EMI filters.&lt;br /&gt;
&lt;br /&gt;
Any more query regarding the project let me know.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R&amp;amp;D)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/4476761819078234001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/4476761819078234001?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4476761819078234001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4476761819078234001'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/04/pic12f510-based-voltage-trigger-switch.html' title='PIC12F510 based Voltage Trigger Switch (Industrial)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyAEdwsOQuYVLLKZ1yFFEKQhQtgBngxt9AZOmg-x_W-EZce2AVFa14bDzjFVXc5Njn8j0_DEgpXalm5fmNVlOBwM9Hj2xPzVmgN2NM1d69_eZL-HlUR7yYyxPI-p7o_5jQDveAwoI2GvU/s72-c/Capture.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-2462063438033826915</id><published>2014-04-29T16:07:00.001+05:30</published><updated>2016-12-20T22:37:26.382+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="1ms delay"/><category scheme="http://www.blogger.com/atom/ns#" term="AT89C51"/><title type='text'>How to create delay function on AT89C2051/ AT89C4051/ AT89C51 for milli seconds delay time (V1.1 updated)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Aim: To teach how to create delay in milli seconds using internal timer.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Delay has been very important part in programming. Many controllers need delays in milli seconds when the commands been transmitted eg. LCD. We can just send commands without delay involved.&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
To create a delay we need to know below things first:&lt;br /&gt;
1. To calculate timer variable according to crystal used&lt;br /&gt;
2. To enable timer for delay operation&lt;br /&gt;
3. To create delay routine which will use the above timer for operation.&lt;br /&gt;
&lt;br /&gt;
We will be using timer 0 from AT89C51. Also timer 0 is common for all three microcontrollers mentioned above.&lt;br /&gt;
&lt;br /&gt;
First we need to do is calculate the &lt;b&gt;timer variable&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Since delay is in 1ms (1 milli seconds) we need to create 1KHz timer interrupt routine. In other words, 1KHz corresponds to 1ms since f = 1/T.&lt;br /&gt;
where f = frequency, T = time.&lt;br /&gt;
&lt;br /&gt;
Say we are using &lt;b&gt;11.059MHz&lt;/b&gt; crystal for our microcontroller. To create 1KHz with the given crystal frequency we need to know that 89C51 timer 1 oscillator clock is divided by 12. So our actual clock will be &lt;b&gt;921.583KHz&lt;/b&gt;. We need to make sure we get 1KHz from this (921583/922) we get 1KHz. So we need to divide by &lt;b&gt;922&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
So 922 is the value we need to save inside the timer.&lt;br /&gt;
&lt;br /&gt;
Now lets study how to start this timer 0.&lt;br /&gt;
&lt;br /&gt;
We first need to know &lt;b&gt;TMOD&lt;/b&gt; Register.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGzBQQtygmSs1gUb5S7tVVgShrje0NZxl7jM-hWCZNXLATMwvnGO4DvtdN6quM40JNTWWZJKiTFW7gE4pommg6JFc85Su26sXxdoTRGPWrUO2STcieTPAdXOvTOsFSAC_-E4DvonnGx0c/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGzBQQtygmSs1gUb5S7tVVgShrje0NZxl7jM-hWCZNXLATMwvnGO4DvtdN6quM40JNTWWZJKiTFW7gE4pommg6JFc85Su26sXxdoTRGPWrUO2STcieTPAdXOvTOsFSAC_-E4DvonnGx0c/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
First thing is we need to operate the timer in 16 bit mode. That will be &lt;b&gt;mode 1&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
So &lt;b&gt;TMOD = 0x01; // Because only last bit is set we get 0x01. (that is to enable mode 1)&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Secondly, we need to enable the timer 0 interrupt. If you check the &lt;b&gt;Interrupt Register IE&lt;/b&gt; below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdEcfPl4ohqgPBE8QoeEuf4AIrWy9nato_nvAkNLfjwYEr_tX-wzr0ltNB241jULleYVhpVUfFXW4EkdEsClt5TW2v0YQhZUVn5TpeIk-O52NP9_P9xjnw1W6pQ2iqLrUm-dVHLYhRTLk/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdEcfPl4ohqgPBE8QoeEuf4AIrWy9nato_nvAkNLfjwYEr_tX-wzr0ltNB241jULleYVhpVUfFXW4EkdEsClt5TW2v0YQhZUVn5TpeIk-O52NP9_P9xjnw1W6pQ2iqLrUm-dVHLYhRTLk/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you check the IE Register above, &lt;b&gt;ET0&lt;/b&gt; corresponds to &lt;b&gt;Timer 0 interrupt enable&lt;/b&gt; bit.&amp;nbsp; &lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
We need to set that to &#39;1&#39;. In keil compiler the good thing is that this bits can be set directly by their names.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
so we set &lt;b&gt;ET0 = 1; // this enables timer 0 interrupt&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
But no interrupts will work if we do not enable &lt;b&gt;EA&lt;/b&gt; bit which is &lt;b&gt;Global interrupt enable&lt;/b&gt; bit.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
So we set &lt;b&gt;EA=1; // this enables global interrupts&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now comes the important part. &lt;b&gt;Interrupt timer routine&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;void timer_0 (void) interrupt 1 using 0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//timer 0 interrupt routine&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;{&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enter code here&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;}&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
Now this interrupt routine has parts.&lt;br /&gt;
void - no return type function&lt;br /&gt;
timer_0 - any name you desire for your timer interrupt routine&lt;br /&gt;
interrupt 1 -&amp;nbsp; corresponds to interrupt type 1 (see diag below) which means timer 0 interrupt = 1&lt;br /&gt;
using 0 - corresponds to number for interrupt vector.&lt;br /&gt;
Check all this description below for more details regarding this: (&lt;b&gt;RESOURCE &lt;/b&gt;&lt;b&gt;= Keil Compiler Help&lt;/b&gt;)&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho2apz4K5SV2nhxu3kCOJWISkVxFXQ9LbJT7vFgJdIO2dK4K8SvkPVLJf-z09Jv3yPcpi8iMJqfFjguS8-yYOAyniQVP_7nkHThnMt5Dysm62UvJQ3HfdFKGSdDXDKF1i2iG5cy10X2fc/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho2apz4K5SV2nhxu3kCOJWISkVxFXQ9LbJT7vFgJdIO2dK4K8SvkPVLJf-z09Jv3yPcpi8iMJqfFjguS8-yYOAyniQVP_7nkHThnMt5Dysm62UvJQ3HfdFKGSdDXDKF1i2iG5cy10X2fc/s1600/Capture.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now next comes &lt;b&gt;timer variable. &lt;/b&gt;We had calculated value 922 to generate exact 1KHz timer interrupt right?? We need to save this value interms of hex form in timer register.&lt;br /&gt;
&lt;br /&gt;
Since timer will keep on counting, it will count upwards right? Say example 0x0000 -&amp;gt; 0x0001...0xffff and then reset back to 0x0000.&lt;br /&gt;
Since it will count upwards we must make sure we get 1KHz. So to get 1KHz interrupt we must subtract highest value of timer counter (0xffff) with the value we got to get the value to be entered in timer as a preset value.&lt;br /&gt;
So &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;0xFFFF (65535 in decimal) - 0x39A (922 the value we calculated above) = 0xFC65( preset value)&lt;/b&gt;&lt;/span&gt;.&lt;br /&gt;
So you need to save this preset in timer 0 registers TH0, TL0;&lt;br /&gt;
Therefore, &lt;b&gt;TH0 = 0xFC;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TL0 = 0x65;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;form name=&quot;timer_calc&quot; oninput=&quot;update()&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;AT89C51 TIMER 1 CALCULATOR FOR DELAY(* Required Fields)&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
Enter Crystal Clock =
&lt;input id=&quot;a&quot; type=&quot;number&quot; value=&quot;1&quot; /&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;/b&gt;MHz (use range 1 MHz - 24MHz)
&lt;br /&gt;
Fin to the timer 1 = 
&lt;output a=&quot;&quot; b=&quot;&quot; for=&quot;&quot; name=&quot;x&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;Hz
&lt;br /&gt;
Minimum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;y&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Maximum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;z&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Interrupt delay required (Use above delay limits) = 
&lt;input id=&quot;dl&quot; type=&quot;number&quot; value=&quot;1&quot; /&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;/b&gt;mS
&lt;br /&gt;
&lt;button onclick=&quot;calculate()&quot; type=&quot;button&quot;&gt;Calculate&lt;/button&gt;
Timer (TH1 &amp;amp; TL1) Register Value in Decimal = 
&lt;output for=&quot;x a b&quot; name=&quot;cdd&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;script&gt;
var Ftest = document.timer_calc;
var fosc;
var prescaled;
var t;
var min;
var max;
var value;
var value_t
function calculate()
{
value_t=Ftest.dl.value/(min*1000);
Ftest.cdd.value=65535-value_t;
}

function update()
{
fosc=Ftest.a.value*1000000;
prescaled=fosc/12;
Ftest.x.value=prescaled;
t=1/prescaled;
min=t;
Ftest.y.value=min*1000;
max=65535*t;
Ftest.z.value=max*1000;
}


&lt;/script&gt;&lt;/div&gt;
&lt;br /&gt;
So, everytime now the timer will start you have to make sure to enter the above preset into these registers and then start the timer. So when it reaches 0xFFFF the actual count will be 0x39A hence your interrupt will be exactly of 1KHz. Now lets take this to our advantage to create a delay.&lt;br /&gt;
&lt;br /&gt;
Check the code here for the delay: &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddUnlDZUtxbE1pUDQ/edit?usp=sharing&quot;&gt;Click here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To download the keil project and hex : &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddbVZMblBCcWF3X3M/edit?usp=sharing&quot;&gt;Click here &lt;/a&gt;&lt;br /&gt;
The code will generate 1000ms delay -&amp;gt; then turn Port 1 ON -&amp;gt; another 1000ms delay -&amp;gt; then turn Port 1 OFF for delay demo purpose.&lt;br /&gt;
&lt;br /&gt;
So, for different Crystal frequencies you will have to calculate the Preset value for the timer using above method and your universal precise delay is ready for service :)&lt;br /&gt;
&lt;br /&gt;
Good luck in programming, hoping this helps many programmers.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading, awaiting queries from you.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R &amp;amp; D)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/2462063438033826915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/2462063438033826915?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/2462063438033826915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/2462063438033826915'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/04/how-to-create-delay-function-on_29.html' title='How to create delay function on AT89C2051/ AT89C4051/ AT89C51 for milli seconds delay time (V1.1 updated)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGzBQQtygmSs1gUb5S7tVVgShrje0NZxl7jM-hWCZNXLATMwvnGO4DvtdN6quM40JNTWWZJKiTFW7gE4pommg6JFc85Su26sXxdoTRGPWrUO2STcieTPAdXOvTOsFSAC_-E4DvonnGx0c/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-1362652164123467515</id><published>2014-04-29T16:07:00.000+05:30</published><updated>2016-10-21T20:25:58.060+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="1ms delay"/><category scheme="http://www.blogger.com/atom/ns#" term="AT89C51"/><title type='text'>How to create delay function on AT89C2051/ AT89C4051/ AT89C51 for milli seconds delay time (V1.1 updated)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Aim: To teach how to create delay in milli seconds using internal timer.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Delay has been very important part in programming. Many controllers need delays in milli seconds when the commands been transmitted eg. LCD. We can just send commands without delay involved.&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
To create a delay we need to know below things first:&lt;br /&gt;
1. To calculate timer variable according to crystal used&lt;br /&gt;
2. To enable timer for delay operation&lt;br /&gt;
3. To create delay routine which will use the above timer for operation.&lt;br /&gt;
&lt;br /&gt;
We will be using timer 0 from AT89C51. Also timer 0 is common for all three microcontrollers mentioned above.&lt;br /&gt;
&lt;br /&gt;
First we need to do is calculate the &lt;b&gt;timer variable&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Since delay is in 1ms (1 milli seconds) we need to create 1KHz timer interrupt routine. In other words, 1KHz corresponds to 1ms since f = 1/T.&lt;br /&gt;
where f = frequency, T = time.&lt;br /&gt;
&lt;br /&gt;
Say we are using &lt;b&gt;11.059MHz&lt;/b&gt; crystal for our microcontroller. To create 1KHz with the given crystal frequency we need to know that 89C51 timer 1 oscillator clock is divided by 12. So our actual clock will be &lt;b&gt;921.583KHz&lt;/b&gt;. We need to make sure we get 1KHz from this (921583/922) we get 1KHz. So we need to divide by &lt;b&gt;922&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
So 922 is the value we need to save inside the timer.&lt;br /&gt;
&lt;br /&gt;
Now lets study how to start this timer 0.&lt;br /&gt;
&lt;br /&gt;
We first need to know &lt;b&gt;TMOD&lt;/b&gt; Register.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGzBQQtygmSs1gUb5S7tVVgShrje0NZxl7jM-hWCZNXLATMwvnGO4DvtdN6quM40JNTWWZJKiTFW7gE4pommg6JFc85Su26sXxdoTRGPWrUO2STcieTPAdXOvTOsFSAC_-E4DvonnGx0c/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGzBQQtygmSs1gUb5S7tVVgShrje0NZxl7jM-hWCZNXLATMwvnGO4DvtdN6quM40JNTWWZJKiTFW7gE4pommg6JFc85Su26sXxdoTRGPWrUO2STcieTPAdXOvTOsFSAC_-E4DvonnGx0c/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
First thing is we need to operate the timer in 16 bit mode. That will be &lt;b&gt;mode 1&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
So &lt;b&gt;TMOD = 0x01; // Because only last bit is set we get 0x01. (that is to enable mode 1)&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Secondly, we need to enable the timer 0 interrupt. If you check the &lt;b&gt;Interrupt Register IE&lt;/b&gt; below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdEcfPl4ohqgPBE8QoeEuf4AIrWy9nato_nvAkNLfjwYEr_tX-wzr0ltNB241jULleYVhpVUfFXW4EkdEsClt5TW2v0YQhZUVn5TpeIk-O52NP9_P9xjnw1W6pQ2iqLrUm-dVHLYhRTLk/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdEcfPl4ohqgPBE8QoeEuf4AIrWy9nato_nvAkNLfjwYEr_tX-wzr0ltNB241jULleYVhpVUfFXW4EkdEsClt5TW2v0YQhZUVn5TpeIk-O52NP9_P9xjnw1W6pQ2iqLrUm-dVHLYhRTLk/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you check the IE Register above, &lt;b&gt;ET0&lt;/b&gt; corresponds to &lt;b&gt;Timer 0 interrupt enable&lt;/b&gt; bit.&amp;nbsp; &lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
We need to set that to &#39;1&#39;. In keil compiler the good thing is that this bits can be set directly by their names.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
so we set &lt;b&gt;ET0 = 1; // this enables timer 0 interrupt&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
But no interrupts will work if we do not enable &lt;b&gt;EA&lt;/b&gt; bit which is &lt;b&gt;Global interrupt enable&lt;/b&gt; bit.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
So we set &lt;b&gt;EA=1; // this enables global interrupts&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now comes the important part. &lt;b&gt;Interrupt timer routine&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;void timer_0 (void) interrupt 1 using 0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//timer 0 interrupt routine&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;{&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enter code here&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;}&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
Now this interrupt routine has parts.&lt;br /&gt;
void - no return type function&lt;br /&gt;
timer_0 - any name you desire for your timer interrupt routine&lt;br /&gt;
interrupt 1 -&amp;nbsp; corresponds to interrupt type 1 (see diag below) which means timer 0 interrupt = 1&lt;br /&gt;
using 0 - corresponds to number for interrupt vector.&lt;br /&gt;
Check all this description below for more details regarding this: (&lt;b&gt;RESOURCE &lt;/b&gt;&lt;b&gt;= Keil Compiler Help&lt;/b&gt;)&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho2apz4K5SV2nhxu3kCOJWISkVxFXQ9LbJT7vFgJdIO2dK4K8SvkPVLJf-z09Jv3yPcpi8iMJqfFjguS8-yYOAyniQVP_7nkHThnMt5Dysm62UvJQ3HfdFKGSdDXDKF1i2iG5cy10X2fc/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho2apz4K5SV2nhxu3kCOJWISkVxFXQ9LbJT7vFgJdIO2dK4K8SvkPVLJf-z09Jv3yPcpi8iMJqfFjguS8-yYOAyniQVP_7nkHThnMt5Dysm62UvJQ3HfdFKGSdDXDKF1i2iG5cy10X2fc/s1600/Capture.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now next comes &lt;b&gt;timer variable. &lt;/b&gt;We had calculated value 922 to generate exact 1KHz timer interrupt right?? We need to save this value interms of hex form in timer register.&lt;br /&gt;
&lt;br /&gt;
Since timer will keep on counting, it will count upwards right? Say example 0x0000 -&amp;gt; 0x0001...0xffff and then reset back to 0x0000.&lt;br /&gt;
Since it will count upwards we must make sure we get 1KHz. So to get 1KHz interrupt we must subtract highest value of timer counter (0xffff) with the value we got to get the value to be entered in timer as a preset value.&lt;br /&gt;
So &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;0xFFFF (65535 in decimal) - 0x39A (922 the value we calculated above) = 0xFC65( preset value)&lt;/b&gt;&lt;/span&gt;.&lt;br /&gt;
So you need to save this preset in timer 0 registers TH0, TL0;&lt;br /&gt;
Therefore, &lt;b&gt;TH0 = 0xFC;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TL0 = 0x65;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;form name=&quot;timer_calc&quot; oninput=&quot;update()&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;AT89C51 TIMER 1 CALCULATOR FOR DELAY(* Required Fields)&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
Enter Crystal Clock =
&lt;input id=&quot;a&quot; type=&quot;number&quot; value=&quot;1&quot; /&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;/b&gt;MHz (use range 1 MHz - 24MHz)
&lt;br /&gt;
Fin to the timer 1 = 
&lt;output a=&quot;&quot; b=&quot;&quot; for=&quot;&quot; name=&quot;x&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;Hz
&lt;br /&gt;
Minimum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;y&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Maximum interrupt delay possible = 
&lt;output for=&quot;x a b&quot; name=&quot;z&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;mS
&lt;br /&gt;
Interrupt delay required (Use above delay limits) = 
&lt;input id=&quot;dl&quot; type=&quot;number&quot; value=&quot;1&quot; /&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt;&lt;/b&gt;mS
&lt;br /&gt;
&lt;button onclick=&quot;calculate()&quot; type=&quot;button&quot;&gt;Calculate&lt;/button&gt;
Timer (TH1 &amp;amp; TL1) Register Value in Decimal = 
&lt;output for=&quot;x a b&quot; name=&quot;cdd&quot; type=&quot;textfield&quot;&gt;&lt;/output&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;script&gt;
var Ftest = document.timer_calc;
var fosc;
var prescaled;
var t;
var min;
var max;
var value;
var value_t
function calculate()
{
value_t=Ftest.dl.value/(min*1000);
Ftest.cdd.value=65535-value_t;
}

function update()
{
fosc=Ftest.a.value*1000000;
prescaled=fosc/12;
Ftest.x.value=prescaled;
t=1/prescaled;
min=t;
Ftest.y.value=min*1000;
max=65535*t;
Ftest.z.value=max*1000;
}


&lt;/script&gt;&lt;/div&gt;
&lt;br /&gt;
So, everytime now the timer will start you have to make sure to enter the above preset into these registers and then start the timer. So when it reaches 0xFFFF the actual count will be 0x39A hence your interrupt will be exactly of 1KHz. Now lets take this to our advantage to create a delay.&lt;br /&gt;
&lt;br /&gt;
Check the code here for the delay: &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddUnlDZUtxbE1pUDQ/edit?usp=sharing&quot;&gt;Click here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To download the keil project and hex : &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddbVZMblBCcWF3X3M/edit?usp=sharing&quot;&gt;Click here &lt;/a&gt;&lt;br /&gt;
The code will generate 1000ms delay -&amp;gt; then turn Port 1 ON -&amp;gt; another 1000ms delay -&amp;gt; then turn Port 1 OFF for delay demo purpose.&lt;br /&gt;
&lt;br /&gt;
So, for different Crystal frequencies you will have to calculate the Preset value for the timer using above method and your universal precise delay is ready for service :)&lt;br /&gt;
&lt;br /&gt;
Good luck in programming, hoping this helps many programmers.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading, awaiting queries from you.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R &amp;amp; D)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/1362652164123467515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/1362652164123467515?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1362652164123467515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1362652164123467515'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/04/how-to-create-delay-function-on.html' title='How to create delay function on AT89C2051/ AT89C4051/ AT89C51 for milli seconds delay time (V1.1 updated)'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGzBQQtygmSs1gUb5S7tVVgShrje0NZxl7jM-hWCZNXLATMwvnGO4DvtdN6quM40JNTWWZJKiTFW7gE4pommg6JFc85Su26sXxdoTRGPWrUO2STcieTPAdXOvTOsFSAC_-E4DvonnGx0c/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-4402636669969882021</id><published>2014-04-26T15:12:00.000+05:30</published><updated>2016-10-21T20:24:22.670+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AT89C51"/><category scheme="http://www.blogger.com/atom/ns#" term="object counter"/><category scheme="http://www.blogger.com/atom/ns#" term="seven segment display"/><category scheme="http://www.blogger.com/atom/ns#" term="TDM"/><title type='text'>AT89C51 Based Object Counter using IR sensors and 4 Digit Seven Segment Display</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;WARNING: I&#39;m not responsible for any 
short circuit or damage you do to the components. The circuits are been 
tested well and working.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Count number of objects on a moving trailer and display on the seven segment display upto 4 digits with reverse counting.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Theory:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Cj3S6AKtUdqWftQFNQPG8pRNxyyotT9_38u_jdHuIsk8app9IC82wPJYM5xqK59YBuazz7qxUjUXxt2q2cMRYT6Izlt_dMMpC8GtqiOQ5es63St2aUdc_0_HUnkJSdz2VOPpqk1MvHs/s1600/OBJECT+COUNTING+copy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Cj3S6AKtUdqWftQFNQPG8pRNxyyotT9_38u_jdHuIsk8app9IC82wPJYM5xqK59YBuazz7qxUjUXxt2q2cMRYT6Izlt_dMMpC8GtqiOQ5es63St2aUdc_0_HUnkJSdz2VOPpqk1MvHs/s1600/OBJECT+COUNTING+copy.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;When production field started growing the number of people involved in doing manufacturing became more involved in cutting, drilling, packing, and counting. Counting has been very important since there was human error happening every time. Counting was possible when production count was less within a day. But since the production count went above 1000 for some companies they had to make some solution regarding counting. Many companies introduced this simple method of object counting. I&#39;ve sketched you how the object counter placement looks like in an industry for counting purpose. You must have already figured out where the object counter is, didn&#39;t you :).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Object counter basically has 2 IR sensors and 2 IR transmitters. On the left side of the picture you can see 2 red IR beams coming towards the receiver. They are transmitters. The Object blocks one of the beam, hence predicting which direction it has come. This also means we can do reverse counting with it. Only when the object passes from two beams we conclude the count as +1. The count is generated by microcontroller 89c51 (before totally logic was used), and then displayed on seven segment display. You can add on indicators like buzzer for generating sound as soon as object passes by.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic4T7oJH2srSRbpjbMwOzdlGvDHH4Gpu2uQ7pCu00U936J8Grvp_-yN2fVliOFGZMeMSLu3T1nPLwa69AIAnBFcBT6bXDvS-of1bPW3D_1hQoS7UF-O7a0ZAv0G479xjz1MSFS5iH_pk8/s1600/countersettings+copy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic4T7oJH2srSRbpjbMwOzdlGvDHH4Gpu2uQ7pCu00U936J8Grvp_-yN2fVliOFGZMeMSLu3T1nPLwa69AIAnBFcBT6bXDvS-of1bPW3D_1hQoS7UF-O7a0ZAv0G479xjz1MSFS5iH_pk8/s1600/countersettings+copy.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;When designing the counter we need to satisfy the 2 above cases.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;CASE 1: &lt;/b&gt;Object entering from &lt;b&gt;Right to Left&lt;/b&gt;( Considered as Forward motion). &lt;b&gt;Forward motion&lt;/b&gt; has to be considered as ( &lt;b&gt;+ 1&lt;/b&gt; count). So every time this motion happens we need to count up and show on the display. In this condition, beam from &lt;b&gt;t2&lt;/b&gt; is blocked hence &lt;b&gt;s2&lt;/b&gt; doesn&#39;t get the beam hence triggers the pulse which we need to save and wait for &lt;b&gt;t1&lt;/b&gt; to be blocked and &lt;b&gt;s1&lt;/b&gt; to trigger the next pulse to increment the count. The count will continue till maximum limit set inside the code.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;CASE 2:&lt;/b&gt; Object entering from &lt;b&gt;Left to Right&lt;/b&gt; (Considered as Reverse motion). &lt;b&gt;Reverse motion&lt;/b&gt; has to be considered as (&lt;b&gt; - 1&lt;/b&gt; count). So every time this motion happens we need to count down and show on the display. In this condition, beam from &lt;b&gt;t1&lt;/b&gt; is blocked and hence &lt;b&gt;s1&lt;/b&gt; doesn&#39;t get the beam hence triggers the pulse which we need to save and wait for &lt;b&gt;t2&lt;/b&gt; to be blocked and &lt;b&gt;s2&lt;/b&gt; to trigger the next pulse to increment the count. The count will continue till minimum limit set inside the code.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;NOTES:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;In both cases the IR transmitter and receiver are kept at same distance (Max. tested distance = 2m apart). The beam from transmitter has to fall on receiver. So before testing the equipment make sure they are aligned. I used Red transparent bright beam LED in place of IR to check if the sensor is aligned.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Secondly, make sure the IR LED&#39;s are working. To test that is simple, turn your camera ON and see if you can see the beam coming out of your IR LED&#39;s. If not, you need to change it.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Schematics: &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtYUlb3XidQM0ZZoxFNV5zX9XOA2_KChPqA1B980XEgcOO6v1xH9xgUsKnQlgQCqnUh7G9NrgSVkiYvmKeRQmoBeynCiHOtAZeR1v5ZvaRbOZEsppg_n2ziDopCE0XfzyxsJ9npJlr8QE/s1600/OBJECT~1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtYUlb3XidQM0ZZoxFNV5zX9XOA2_KChPqA1B980XEgcOO6v1xH9xgUsKnQlgQCqnUh7G9NrgSVkiYvmKeRQmoBeynCiHOtAZeR1v5ZvaRbOZEsppg_n2ziDopCE0XfzyxsJ9npJlr8QE/s1600/OBJECT~1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Lets have a talk on this hardware. This hardware includes 5 major blocks marked in rectangular areas. They are:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;1. AT89C51 microcontroller circuit.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;2. Seven ( 7 ) segment display and buzzer circuit.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;3. IR sensor circuit.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;4. IR Transmitter circuit.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;5. Power Supply Circuit.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Coming to the microcontroller circuit. AT89C51 is 8 - bit microcontroller (uC) with 4KB flash which is exactly what we need. This uC also has sufficient IO&#39;s for our purpose. Extra un used IO&#39;s can be internally modified for LED indication for debug purpose. It is configured to work on 11,059,000Hz (11.59MHz) frequency. Reset Switch is used to reset the controller hence resetting the counter. So no extra switch needed for this operation. The 11.059MHz Crystal used is a 3 Pin Resonator&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8lSPf0vyq8aKIWz6M9tzFw5Sdt1K43L717MOGbKkS_fIb-BfcPYFtsNxJjy5fMs3eIIAHXo225MrUSkect7WZ5527dXt3Vn7sGGBaylsRQq9tuuZ9C0ndWQaLO4a_JeOyNaO320Bw3Ks/s1600/3_pin_ceramic_r.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8lSPf0vyq8aKIWz6M9tzFw5Sdt1K43L717MOGbKkS_fIb-BfcPYFtsNxJjy5fMs3eIIAHXo225MrUSkect7WZ5527dXt3Vn7sGGBaylsRQq9tuuZ9C0ndWQaLO4a_JeOyNaO320Bw3Ks/s1600/3_pin_ceramic_r.JPG&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;This crystal doesn&#39;t need external 22pF resonators so saves space. But if you want the tradition two pin crystal do use, there is no harm. You will have to add two 22pF on either pins of crystal to ground.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;The microcontroller works on +5V pure DC. Make sure no fluctuations come through AC to DC source.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;The Seven Segment Display has 4 digit seven segment digits LT542 is a Common Anode Type where the LED segments anodes are all connected to one. So we need to light up using the cathodes. Or in other words making 0 or Ground. The schematic itself shows how the LT542 looks internally. and also the segments a,b,c,d,e,f,g,dp. So before using the seven segments try to light them up first and see if all segments are working properly. This can be done by connecting Common anode to (+2V) and the segments a,b,c,d,e,f,g,dp to ground. A good one will light all up. Bad one will create problem in displaying so don&#39;t use it. BC557 transistor is used to drive the LT542 display. In microcontroller section Resistors R2 to R9 are current limiting resistors to protect LT542 segment from burning. How they are calculated??&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Voltage to drive one led segment Vled = 2.2V.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Current through that led segment Iled = 12mA.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Voltage supplied by BC557 Vcc = +5V&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Therefore, Resistance to protect one led segment Rled = (Vcc - Vled)/Iled.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Which comes to 233.33 Ohms on calculation ~ 220 Ohms close value available in market. So use that.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;You must be wondering why just 7 data lines for 4 Seven Segment Display? They has to be 7 x 4 data lines right? Well to save all that trouble and extra components we use the method called TDM (Time Divison Multiplexing). In this method, for a particular given time each seven segment has been given a time slot. And during that time slot the data lines will be assigned to it software wise. Let me explain you through the diagram below.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYnHrn1vYd1LiAr3en945X4qamWmJdgXnb2AueDi9HMLzGxAhHPb_xJtNg_kEZZUFf-0pgkysTjrI8kpByiOElMDEvO1SL_QsnNA6m6tACWKrGhd276WEbAP63sBbzjbwaAQaTEw3fc7g/s1600/Untitled-1+copy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYnHrn1vYd1LiAr3en945X4qamWmJdgXnb2AueDi9HMLzGxAhHPb_xJtNg_kEZZUFf-0pgkysTjrI8kpByiOElMDEvO1SL_QsnNA6m6tACWKrGhd276WEbAP63sBbzjbwaAQaTEw3fc7g/s1600/Untitled-1+copy.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;TDM is divided into 4 slots for time T1, T2 , T3 , T4. For now Ttdm is calculated roughly to be 0.0906mS. That means each segment gets updated at 0.227mS rate.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;During time T1, you must make sure Q1, Q2, Q3, Q4 transistors are not driving any segments. This is made to ensure data lines are not by any chance get linked to other segment. Or the numbers will display wrong. So while segments are disabled set the data lines with &#39; unit &#39; data calculated from counter value. Then turn Q4 ON, hence driving UNIT seven segment. This will display UNIT value.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Upon the next time slot T2, disable again Q1, Q2 ,Q3 ,Q4 transistors to eliminate duplication of digits on other segments. Then send &#39; tens &#39; data on the data line calculated from counter value. Then turn Q3 ON, hence driving TENS seven segment. This will display TENS value.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;This continues till all digits are displayed and the steps are repeated at 0.0906ms rate. The changing rate is so fast it makes human eye almost look like proper whole 4 digits being displayed without problem. TDM saves lots of component space and cost. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Next, IR sensor Circuit contains &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddTk1mZ2FFMExnNEU/edit?usp=sharing&quot;&gt;TSOP1736&lt;/a&gt; IR sensor has IR photo detection response of 36KHz&lt;/span&gt;. The sensor produces low output upon IR detection, otherwise when no IR is detected the sensor remains ON.&lt;br /&gt;
This sensor is then driven by BC557 transistor for proper biasing which is then given to input of microcontroller. This microcontroller inputs of AT89C51 are external interrupts IO. So they can be internally configured to interrupt upon any trigger from the sensor. This you will learn inside the software.&lt;br /&gt;
&lt;br /&gt;
The IR transmitters contains the famous 555 timer astable multivibrator ticking at 36KHz that is blinking the IR LED at 36KHz since that is the response frequency of the IR receiver. You can use 1 or 4 IR LED&#39;s based on range or distance between both IR transmitter and receiver. R19 to R26 can be calculated based on Voltage and current rating of the IR LED. I have not put this values but you can find for your self and then put the corresponding Resistance value.&lt;br /&gt;
Formala &lt;b&gt;R = (Vcc - Vled)/Iled.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Next is power supply circuit. It uses IC regulators to give +12V and +5V separately. Overall current will be below 1A so transformer output of 12V 1A is capable to handle this rating.&lt;br /&gt;
&lt;br /&gt;
Now coming to software:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Kindly &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddT0kzX1ZnZENjZjA/edit?usp=sharing&quot;&gt;Click here&lt;/a&gt; for the code.&lt;/b&gt; The Code is written in C on Keil compiler. You can download the project by &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddMkFzX09wVFQ0cjA/edit?usp=sharing&quot;&gt;&lt;b&gt;clicking here&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The explanation for the code has been given in details using comments inside code itself.&lt;br /&gt;
&lt;br /&gt;
Improvements to be done:&lt;br /&gt;
1. Increasing of Digits can go upto another 15 digits with the remaining available IO&#39;s. Extra driver circuit will be required and some changes in the calculations and time slots.&lt;br /&gt;
2. Adding LED indicators for panel besides buzzer can be used.&lt;br /&gt;
3. Alarm trigger on certain count can be implemented using keypads. &lt;br /&gt;
&lt;br /&gt;
This device can also be used as visitor counter for one door only. (assuming one door for the room to enter and exit, provided initial state of the room has no people inside.&lt;br /&gt;
&lt;br /&gt;
You have officially understood how object counter works. Congratulations.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading. Any query related to this article let me know.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R &amp;amp; D)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/4402636669969882021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/4402636669969882021?isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4402636669969882021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/4402636669969882021'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/04/at89c51-based-object-counter-using-ir.html' title='AT89C51 Based Object Counter using IR sensors and 4 Digit Seven Segment Display'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Cj3S6AKtUdqWftQFNQPG8pRNxyyotT9_38u_jdHuIsk8app9IC82wPJYM5xqK59YBuazz7qxUjUXxt2q2cMRYT6Izlt_dMMpC8GtqiOQ5es63St2aUdc_0_HUnkJSdz2VOPpqk1MvHs/s72-c/OBJECT+COUNTING+copy.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7400379397483727887.post-1849186120921956869</id><published>2014-04-21T19:29:00.002+05:30</published><updated>2016-02-06T13:00:41.366+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="IEEE802.15.4"/><category scheme="http://www.blogger.com/atom/ns#" term="JN5148"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><title type='text'>Turn LED On wireless using Jennet Protocol with JN5148 Microcontroller Module</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;WARNING: I&#39;m not responsible for any short circuit or damage you do to the components. The circuits are been tested well and working.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit24qsRSRHmM2hXYLfkjaxR9icHsEG1cBONH7257P6so9qpivuu1jG0Oxgpo673VpoqaSxmDjGQxp-H3F4w4Y-ODaq2x1nKhx7CuXwsngvF4kMsUJLbym1qfgre-2v3P4XMIKW_-v-jU4/s1600/JN5148-001-M00T.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit24qsRSRHmM2hXYLfkjaxR9icHsEG1cBONH7257P6so9qpivuu1jG0Oxgpo673VpoqaSxmDjGQxp-H3F4w4Y-ODaq2x1nKhx7CuXwsngvF4kMsUJLbym1qfgre-2v3P4XMIKW_-v-jU4/s1600/JN5148-001-M00T.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf6kNzFiMc72SYaaenKDG260GHQyGFq1ZdgOwo2DdISN1_dF1VgxbkMo-ejo5EVPotltlSAU4POzOXxLafW3xYAw0uPEXrcMLeQemrgVKsLA9SAJWsAMqioHdnOES_jDsmFn6sLn48cVs/s1600/JN5148-001M03T-534-NXP-FNT-MED.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
This is the module I was using JN5148-001-M00. This can go upto 25Meters. &lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Lets go wireless.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;But before understanding what I&#39;m about to do, you need to know some basics.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;This Microcontroller uses wireless IEEE182.15.4 protocol or ZigBee Protocol developed by Zigbee Alliance. You can read history more on &lt;a href=&quot;http://en.wikipedia.org/wiki/ZigBee&quot;&gt;wikipedia&lt;/a&gt;. This protocol has been designed for low power applications, low data rate, and where communication security is concerned. The maximum range it can go was once 20meters,&amp;nbsp; but with external antenna support it can go upto 1km to 4km.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;When I started my first project during my MSc time, I used JN5139-001-M00. We had named it Temperature monitoring using ZigBee Network with mesh topology. Trust me, I was so blacked out just like you (assuming you are reading this blog) so do my classmates including my teachers since zigbee was newly introduced and there was no help available much. Also we had to travel far away for buying the modules and the FTDI was very expensive that time. There was no online buy facility.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;What we will learn in this topic:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;1. Hardware Schematics&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;2. Software&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;3. Jennet &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;4. Coordinator (MASTER)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;5. End Device (SLAVE)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;6. Compiling and Programming.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Our Network block diagram:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinyeJ-l3SKWBNL0eMZpXdCJ9upnbpPkQHgIW-mtZeXHbaq9PF4vGtHuT6PgL7Bf-_majZGV9P84ehT0FOqZNEwvTc0G77s8HYz_fG2Mddzn5g0dGeALlCt6mMJcpLT6Kqjo8C2-VlCrik/s1600/ZIGBEENETWORK.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;323&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinyeJ-l3SKWBNL0eMZpXdCJ9upnbpPkQHgIW-mtZeXHbaq9PF4vGtHuT6PgL7Bf-_majZGV9P84ehT0FOqZNEwvTc0G77s8HYz_fG2Mddzn5g0dGeALlCt6mMJcpLT6Kqjo8C2-VlCrik/s1600/ZIGBEENETWORK.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&amp;nbsp;Brief description:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;In this network there are two devices with similar hardware schematic. But the assignment is different. One device is programmed as Coordinator and other device is programmed as End device. The Switch SW on end device when clicked will wireless send command on Coordinator to turn LED ON on Coordinator. When You click switch SW on Coordinator, it will send wireless command to end device and will turn LED ON. So with this example I can show you two way communication. You need to reset both the devices to start again. (THIS IS JUST FOR COMMUNICATION BASICS)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Schematic Diagram for both coordinator and end device are same:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5bP7t65sBSjX3MHT4ZvUzMeFtRC05QJhsOZrzkjqrCi16xGzkSsL7f0gevlstaBVD5pdJxPZkL4t98-zJ9XMHddRaw3VzbBdcdZuzILCLnvSt7VZp7F90luMVk7W2OvMHMy893T67kIA/s1600/WIRELESS.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5bP7t65sBSjX3MHT4ZvUzMeFtRC05QJhsOZrzkjqrCi16xGzkSsL7f0gevlstaBVD5pdJxPZkL4t98-zJ9XMHddRaw3VzbBdcdZuzILCLnvSt7VZp7F90luMVk7W2OvMHMy893T67kIA/s1600/WIRELESS.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;IMPORTANT NOTE:&lt;/b&gt;&lt;br /&gt;
1. Grounds for both FTDI circuit and module circuit is same.&lt;br /&gt;
2. +5V_USB and +3.3V_FTDI must not be connected to any power supply.&lt;br /&gt;
3. +3.3V_FTDI and +3.3V must not be shorted to each other. This is done to prevent extra load of FTDI when UART or Programming is not in use.&lt;br /&gt;
4. The above schematic is for just one device. You need to make 2 devices for testing.&lt;br /&gt;
5. You need 3.3V power supply. You can buy it online. &lt;br /&gt;
&lt;br /&gt;
Read more on FTDI setup by &lt;a href=&quot;http://embeddedlifehelp.blogspot.in/2014/04/relay-control-through-pc-using-virtual.html&quot;&gt;clicking here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Now you are completely ready with hardware. You need to make 2 PCB&#39;s for 2 devices to keep them far apart.&lt;br /&gt;
&lt;br /&gt;
Coming to the software you need to download software from &lt;a href=&quot;http://www.jennic.com/support/software/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
I&#39;m going to use &lt;b&gt;JN-SW-4041 Eclipse Integrated Development Environment &lt;/b&gt;to write programs and compile them and Flash programmer tool to burn the program into the chip. Kindly focus on these two.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
The Eclipse Platform looks like this :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfzp4e2C2QE27yei5KbEYDqLU-_yz8D0PrWOoqy26QLMOP48a7r9a7SCOylBzt3PGdzo7QMQnJJ2BP45hFsSEg3VE1Z-iEH8l81lQ0to7pnZ_CHFW7nqW4GklSwSZVeB3x3u80J_bdTXE/s1600/cap1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfzp4e2C2QE27yei5KbEYDqLU-_yz8D0PrWOoqy26QLMOP48a7r9a7SCOylBzt3PGdzo7QMQnJJ2BP45hFsSEg3VE1Z-iEH8l81lQ0to7pnZ_CHFW7nqW4GklSwSZVeB3x3u80J_bdTXE/s1600/cap1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;To create new project we need to follow some steps:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
First we need to create project. For that click File -&amp;gt; C Project. Enter File name as &quot;test_me&quot; or whatever you want it to be and select empty project. Then Click finish.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb5uv521hkp1a3sbFhvO7xg0aw7c_AFvf7NNPNtY3CgvCbYoRrdvPBBx9pT83oC09Gh3wYBP-1pwub4kgIk73-lQSaZIem389Br9FF2E87uSIIF2UQY53-Hs8fNZDZPZRh98a37uFojGg/s1600/cap2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb5uv521hkp1a3sbFhvO7xg0aw7c_AFvf7NNPNtY3CgvCbYoRrdvPBBx9pT83oC09Gh3wYBP-1pwub4kgIk73-lQSaZIem389Br9FF2E87uSIIF2UQY53-Hs8fNZDZPZRh98a37uFojGg/s1600/cap2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now what you need to do is download template for JN5148 for JENNET from jennic website which can be downloaded by clicking here &lt;a href=&quot;http://www.jennic.com/jennic_support/support_files/jn-an-1061_jennet_application_template&quot;&gt;JN-AN-1061-JenNet Application Template&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Download the zip file and also the application note. Yes keep the zip file extracted.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now You need to do is right click on project in project explorer and then click on import. Then click on General -&amp;gt; File System. Now browse the above extracted template -&amp;gt; Then Select All - &amp;gt;Finish. If asked to replace some files or folders then click &quot;Yes to all&quot;.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now you will see like this below:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii_9q1wh9TzjoSMuV3dh634tS2gH2jK8m58IOJ4P-roXFQa3RveCpg0M40q1zIKiojrV4HmDFQFSZfW8X0O_Bx2xJV5XSp_xLDEXNEbagReeaZ1PhW9uwcXMClq0skpLMliXZ1S_xUY5A/s1600/cap3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii_9q1wh9TzjoSMuV3dh634tS2gH2jK8m58IOJ4P-roXFQa3RveCpg0M40q1zIKiojrV4HmDFQFSZfW8X0O_Bx2xJV5XSp_xLDEXNEbagReeaZ1PhW9uwcXMClq0skpLMliXZ1S_xUY5A/s1600/cap3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now you are all set for programming JN5148 Microcontroller. Now Lets begin with JENNET.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I&#39;ll explain you the basic functions in this template:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbConfigureNetwork(void)&lt;/b&gt;&amp;nbsp; will have all basic variables which are related to wireless network to get configured like eg: Channel, Network ID or PAN ID, Device ID and many more.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbInit(bool_t bWarmStart)&lt;/b&gt; will initialize mostly the Utilities or Peripheral Devices and also acts just like void main(void) from embedded c .&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbMain(void)&lt;/b&gt;&amp;nbsp; is just like a loop which will keep on going. So you need to follow those Enumerations and start your program inside APP_STATE_RUNNING.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbStackMgmtEvent(teEventType eEventType, void *pvEventPrim)&lt;/b&gt; contains JENNET protocol stack related activity. This includes Searching for neighboring device, adding of device, leaving of device, registering of device etc.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbStackDataEvent(teEventType eEventType, void *pvEventPrim)&lt;/b&gt; contains mostly data related events. If data received or getting transmitted the code will be processing through here. This is main area of interest to us later.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbHwEvent(uint32 u32DeviceId,uint32 u32ItemBitmap)&lt;/b&gt; is are hardware interrupt call function. For now tick timer and Switch will be generating interrupts.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;For Coordinator Settings:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
1. Set up PAN ID to 0x1234. (common-&amp;gt;config.h)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
2. Device ID must be 0x0000&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
3. No services needed.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
4. No registration needed.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
5. Configure IO&#39;s for Switch and LED.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
6. Transmit and Receive implementation.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Lets begin:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
You need to know GLOBAL NETWORK PARAMETERS to configure your coordinator. To know that &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddX3diOGFycFdkU00/edit?usp=sharing&quot;&gt;Click here&lt;/a&gt; and go to page 161. You need to assign variables to configure your JENNET network here.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
So what do we need??&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;gJenie_PanID = 0x1234&lt;/b&gt; (also called Network ID)(only to be set to coordinator)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;gJenie_NetworkApplicationID = 0x12341234; &lt;/b&gt;( For network Application Identification)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;gJenie_Channel = 11.&lt;/b&gt; (11 is STD channel In India)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;gJenie_ScanChannels = 0x00000800.&lt;/b&gt; (Set 11th bit to select 11th channel)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;gJenie_MaxChildren = 1&lt;/b&gt;. (We are using only one End device so 1) &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;gJenie_RoutingEnabled&amp;nbsp;&amp;nbsp;&amp;nbsp; = TRUE; &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;gJenie_RoutingTableSize&amp;nbsp; = 100;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;gJenie_RoutingTableSpace = (void *)asRoutingTable; &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now open AN1061_JN_Coord -&amp;gt; Source -&amp;gt;AN1061_JN_Coord.c&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
and clear what is there in &lt;b&gt;PUBLIC void vJenie_CbConfigureNetwork(void) &lt;/b&gt;and enter the above parameters.&lt;/div&gt;
&lt;br /&gt;
Now to configure IO for Switch and LED we need to know Jennie Peripheral Interface functions Click on JPI of same above pdf.&lt;br /&gt;
&lt;br /&gt;
To set IO direction&amp;nbsp; &lt;b&gt;void vJPI_DioSetDirection(uint32 u32Inputs,uint32 u32Outputs);&lt;/b&gt;&lt;br /&gt;
Since or Switch is on DIO20 and LED is on DIO17. Configuring gives&lt;br /&gt;
&lt;b&gt;vJPI_DioSetDirection(0x00100000,0x00020000);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;eJenie_Start(E_JENIE_COORDINATOR) &lt;/b&gt;will start the coordinator stack and will enable the network.&lt;br /&gt;
Once network is enabled the E_JENIE_NETWORK_UP enumeration will be set.&lt;br /&gt;
You need to put this in&lt;b&gt; PUBLIC void vJenie_CbInit(bool_t bWarmStart) &lt;/b&gt;becauses this is like void main(void) in embedded c.&lt;br /&gt;
&lt;br /&gt;
After initializing the code will jump to &lt;b&gt;PUBLIC void vJenie_CbMain(void)&lt;/b&gt; where you need to disable the watchdog because we don&#39;t want to restart at the movement.&lt;br /&gt;
So once the network is up your you need to set:&lt;br /&gt;
&lt;b&gt;eJenie_SetPermitJoin(TRUE);&lt;/b&gt; which will enable permission for end device to join.&lt;br /&gt;
So after this you are ready to transmit and receive data.&lt;br /&gt;
&lt;br /&gt;
I have removed Register Services from the application since I&#39;m not interested in Security right now.&lt;br /&gt;
&lt;br /&gt;
Now you will be in continuous loop in estate of APP_STATE_RUNNING in &lt;b&gt;PUBLIC void vJenie_CbMain(void). &lt;/b&gt;You need to put switch read input function here to scan the switch.&lt;br /&gt;
&lt;b&gt;if((u32JPI_DioReadInput() &amp;amp; 0x00100000)&amp;gt;0)&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;//data send code here&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To send data in air &lt;b&gt;eJenie_SendData(uint64 u64DestAddr,uint8 *pu8Payload,uint16 u16Length,uint8 u8TxFlags); &lt;/b&gt;function is used where:&lt;br /&gt;
&lt;b&gt;u64DestAddr &lt;/b&gt;Address of the destination node. For a broadcast or to send data to the Co-ordinator, this parameter must be set to zero (for a broadcast, u8TxFlags must also be set appropriately)&lt;b&gt;.&lt;br /&gt;*pu8Payload &lt;/b&gt;Pointer to the data to be sent&lt;b&gt;.&lt;br /&gt;u16Length&lt;/b&gt; Length of data to be sent, in bytes (for limits, see above)&lt;b&gt;.&lt;br /&gt;u8TxFlags &lt;/b&gt;Sets the transmission options. These options are detailed in Table 2 on page 165. The values can be logical ORed to simultaneously specify more than one option&lt;b&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
So our function to send to our end device will be:&lt;br /&gt;
&lt;b&gt;uint8 *payload;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;eJenie_SendData( 0, payload, 1, TXOPTION_BDCAST);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;So now the above code will look like:&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;case APP_STATE_RUNNING:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* do all necessary processing here */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((JPI_DioReadInput() &amp;amp; 0x00020000)&amp;gt;0) //Now since upon switch read is true, broadcast the message in air&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; payload[0]=0x01; // Consider 0x01 means Switch was pressed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; eJenie_SendData( 0, payload, 1, TXOPTION_BDCAST)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;break;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
So from above you are ready to do transmission to end device upon network up.&lt;br /&gt;
Now lets work on Receiving part.&lt;br /&gt;
Lets go to &lt;b&gt;PUBLIC void vJenie_CbStackDataEvent(teEventType eEventType, void *pvEventPrim)&lt;/b&gt;&lt;br /&gt;
You need to add here two important variables which will store the received data.&lt;br /&gt;
&lt;b&gt;tsData *psData = (tsData *) pvEventPrim;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;uint8 *pu8Data = psData-&amp;gt;pau8Data; //assign received data to this register.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Then in the state event your this case has to be like this:&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;case E_JENIE_DATA: //Your data from end device will be received here so do the processing here&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vUtils_Debug(&quot;Data event&quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(pu8Data[0]==0x02) //0x02 is transmitted data from End device.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vJPI_DioSetOutput(0x00020000, 0); // set LED ON on receive&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;break;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thats it!!! For the coordinator. Its so simple isn&#39;t it to setup coordinator. I was struggling for many months just to send and receive.&lt;br /&gt;
&lt;br /&gt;
Now lets work on the End device. End device also has similar main functions like coordinator:&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbConfigureNetwork(void)&lt;/b&gt;&amp;nbsp;
 will have all basic variables which are related to wireless network to 
get configured like eg: Channel, Network ID or PAN ID, Device ID and 
many more.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbInit(bool_t bWarmStart)&lt;/b&gt; will initialize mostly the Utilities or Peripheral Devices and also acts just like void main(void) from embedded c .&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbMain(void)&lt;/b&gt;&amp;nbsp; is just like a loop which will keep on going. So you need to follow those Enumerations and start your program inside APP_STATE_RUNNING.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbStackMgmtEvent(teEventType eEventType, void *pvEventPrim)&lt;/b&gt; contains JENNET protocol stack related activity. This includes Searching for neighboring device, adding of device, leaving of device, registering of device etc.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbStackDataEvent(teEventType eEventType, void *pvEventPrim)&lt;/b&gt;
 contains mostly data related events. If data received or getting 
transmitted the code will be processing through here. This is main area 
of interest to us later.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;PUBLIC void vJenie_CbHwEvent(uint32 u32DeviceId,uint32 u32ItemBitmap)&lt;/b&gt; is are hardware interrupt call function. For now tick timer and Switch will be generating interrupts.&lt;/div&gt;
&lt;br /&gt;
Now changes in &lt;b&gt;PUBLIC void vJenie_CbConfigureNetwork(void)&lt;/b&gt;&amp;nbsp; will be different.&lt;br /&gt;
You need to put these:&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;gJenie_Channel&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 11; //Channel 11= network channel select&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;gJenie_ScanChannels = 0x00000800;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;gJenie_NetworkApplicationID = 0x12341234; //Network app ID of coordinator to be joined&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;gJenie_RoutingEnabled&amp;nbsp;&amp;nbsp;&amp;nbsp; = FALSE; //End device cannot add nodes.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;gJenie_EndDevicePingInterval=1;&lt;/b&gt; &lt;b&gt;//1 = 100ms ping time&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So in end device you will enter the same format like you did in Coordinator accept now Data transmit will be&lt;br /&gt;
&lt;b&gt;uint8 payloadt &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;eJenie_SendData(0, payloadt, 1, TXOPTION_SILENT);&lt;/b&gt;&lt;br /&gt;
Silent TX option will disable acknowledgement interrupts.&lt;br /&gt;
and to receive data from the coordinator you need to do this changes:&amp;nbsp;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;case E_JENIE_DATA: //Your data from end device will be received here so do the processing here&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vUtils_Debug(&quot;Data event&quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(pu8Data[0]==0x01)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vJPI_DioSetOutput(0x00020000, 0); // set LED on on receive&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;break;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To compile, &lt;b&gt;Right click on Project Folder-&amp;gt; Set Active -&amp;gt; AT1061_JN_Coord &lt;/b&gt;to build Coordinator,&lt;br /&gt;
and &lt;b&gt;Right click on Project Folder-&amp;gt; Set Active -&amp;gt; AT1061_JN_EndD &lt;/b&gt;to build End device.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can download hex file using Flash Programmer. Here is the Screen Shot:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA1g6jRdDN6REIqlD_9Y1VBs3AnO4uQ9aKHGdJK5VKSmir9BpOoT46uvvB8JceUvErk8WXiQeVwQUPBwdY1_6dpI_j_2wiqtfEVzwH5dq1yFUgtL3VE-yjpggWXu6AxOQtCyXe11nv_gs/s1600/Fault+copy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA1g6jRdDN6REIqlD_9Y1VBs3AnO4uQ9aKHGdJK5VKSmir9BpOoT46uvvB8JceUvErk8WXiQeVwQUPBwdY1_6dpI_j_2wiqtfEVzwH5dq1yFUgtL3VE-yjpggWXu6AxOQtCyXe11nv_gs/s1600/Fault+copy.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I had to modify the old Flash Programmer file to show you how it looks.(the latest one goes beyond my screen and About and Program keys are not visible. Sorry for Inconvenience. This will do explain you how it looks when the device gets detected. You get to see the Device name : JN5148, Flash used, Mac Address 64 Bit. The MAC address are unique for&amp;nbsp; each module and you should not change them. Browse the Hex files from Build Folder of Each Device and Program them separately.&lt;br /&gt;
&lt;br /&gt;
To set in programming mode you need to know:&lt;br /&gt;
Press Prog Switch -&amp;gt; Hold&lt;br /&gt;
Press Reset Switch -&amp;gt; Hold&lt;br /&gt;
Release Reset Switch&lt;br /&gt;
Release Prog Switch.&lt;br /&gt;
Now it will be in programming mode. Your Flash programmer will now detect the module.&lt;br /&gt;
&lt;br /&gt;
After programming. It will still be in programming mode so press Reset Switch again to Run the code.&lt;br /&gt;
To debug furthur: You can read more stuff about JENNET&amp;nbsp; and implement your own models of networking and analysis. You can also connect FTDI and see how my code works using virtual terminal.&lt;br /&gt;
Messages will be coming no terminal regarding internal functionality. &lt;b&gt;vUtils_Debug( &quot;text&quot;)&lt;/b&gt; will display text messages on UART for extra debugging.&lt;br /&gt;
&lt;br /&gt;
You can download the files from &lt;a href=&quot;https://drive.google.com/file/d/0Bzq0D3ZT0_ddck1ZTnQxdEhpdkU/edit?usp=sharing&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
When both the Devices are programmed, you are ready to test.&lt;br /&gt;
&lt;br /&gt;
Best of luck, you now know the basics of JENNET and to work with JN5148.&lt;br /&gt;
&lt;br /&gt;
Note: For my MSc. Project I used to only transmit data from End Device to Coordinator. That data was 8 Bit ADC value of Temperature. The data was then shown on virtual terminal using serial UART.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any Questions or Queries let me know.&lt;br /&gt;
&lt;br /&gt;
Macjan Camilo Fernandes (R &amp;amp; D)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlifehelp.blogspot.com/feeds/1849186120921956869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7400379397483727887/1849186120921956869?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1849186120921956869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7400379397483727887/posts/default/1849186120921956869'/><link rel='alternate' type='text/html' href='http://embeddedlifehelp.blogspot.com/2014/04/turn-led-on-wireless-using-jennet.html' title='Turn LED On wireless using Jennet Protocol with JN5148 Microcontroller Module'/><author><name>Macjan Camilo Fernandes</name><uri>http://www.blogger.com/profile/15335683291927518578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit24qsRSRHmM2hXYLfkjaxR9icHsEG1cBONH7257P6so9qpivuu1jG0Oxgpo673VpoqaSxmDjGQxp-H3F4w4Y-ODaq2x1nKhx7CuXwsngvF4kMsUJLbym1qfgre-2v3P4XMIKW_-v-jU4/s72-c/JN5148-001-M00T.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>