Starting Electronicsmit PIC Mikrocontroller-Basics
Microcontroller Basics Elektronik gar nicht schwer with PIC
Tam Hanna LEARN DESIGN SHARE
HARE ARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIG DESIG ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHA SHA HARE HARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIG DESIG
Starting Electronics
Microcontroller Basics with PIC ● By Tam Hanna
LEARN DESIGN SHARE
● This is an Elektor Publication. Elektor is the media brand of Elektor International Media B.V.
78 York Street, London W1H 1DP, UK Phone: (+44) (0)20 7692 8344
● All rights reserved. No part of this book may be reproduced in any material form, including
photocopying, or storing in any medium by electronic means and whether or not transiently or incidentally to some other sue of this publication, without the written permission of the copyright holder except in accordance with the provisions of the Copyright Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licencing Agency Ltd., 90 Tottenham Court Road, London, England W1P 9HE. Applications for the copyright holder's permission to reproduce any part of the publication should be addressed to the publishers.
● Declaration
The author and publisher have used their best efforts in ensuring the correctness of the information contained in this book. They do not assume, or hereby disclaim, any liability to any party for any loss or damage caused by errors or omissions in this book, whether such errors or omissions result from negligence, accident or any other cause.
● Acknowledgements
The author would like to express his thanks to Ferdinand te Walvaart of Elektor for the valuable suggestions he made throughout the duration of the preparation of this book. The author would like to thank also to his wife Nadire for her encouragement, motivation, and for being patient with me while working on this book.
● British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
● ISBN 978-1-907920-81-3 © Copyright 2020: Elektor International Media b.v. Prepress Production: D-Vision, Julian van den Berg First published in the United Kingdom 2020 Printed in the Netherlands by Wilco
Elektor is part of EIM, the world's leading source of essential technical information and electronics products for pro engineers, electronics designers, and the companies seeking to engage them. Each day, our international team develops and delivers high-quality content - via a variety of media channels (including magazines, video, digital media, and social media) in several languages - relating to electronics design and DIY electronics. www.elektormagazine.com
LEARN DESIGN SHARE
Contents Chapter 1 • Introduction and motivation................................................... 9 Instead of an introduction – on buying an NE555......................................... 9 Why PIC? Why assembler?...................................................................... 10 What do we need?................................................................................. 11 Installing MPLAB on Windows.................................................................. 11 Chapter 2 • Executing Assembly in Sequence........................................... 15 Getting closer to the PIC......................................................................... 15 Building a testing rig.............................................................................. 18 An introduction to Assembly.................................................................... 21 Understanding start-up.......................................................................... 23 Dynamic hardware configuration.............................................................. 25 What happens in the background?........................................................... 28 How outputs are configured.................................................................... 30 Conclusion............................................................................................ 32 Chapter 3 • Program Sequence Control.................................................... 33 Jump Operators and Pipelining................................................................ 34 Slow down program execution with NOP................................................... 36 Aside: Comments.................................................................................. 38 Declaration of variables.......................................................................... 39 Conditional jump operations.................................................................... 42 Troubleshooting..................................................................................... 47 Optimizing the program.......................................................................... 49 Using Subroutines................................................................................. 51 The stack and its pitfalls......................................................................... 54 What happens next?.............................................................................. 58 Chapter 4 • PIC Arithmetic Operations..................................................... 59 Understanding binary............................................................................. 59 The traps of adding things...................................................................... 61 Comparing numerical values................................................................... 64 Two’s complement................................................................................. 72 Logic operations.................................................................................... 76 Shift!................................................................................................... 79
●5
Starting Electronics - Microcontroller Basics with PIC Bottom line........................................................................................... 82 Chapter 5 • Interrupts and Sleep Modes.................................................. 83 Understanding interrupt logic.................................................................. 83 Unsharp without interrupts..................................................................... 85 Improving the reaction time.................................................................... 91 Let’s save power................................................................................... 96 Monitoring with WDT.............................................................................. 98 Outlook: timers allsorts.........................................................................102 Chapter 6 • Indirect Addressing............................................................. 104 Discrete and continuous........................................................................104 Configure the DAC................................................................................105 On lookup tables..................................................................................110 Tables from data memory......................................................................112 On disassembly and constants................................................................114 Return to table access...........................................................................117 Tables from RAM..................................................................................120 Troubleshooting with Assembler..............................................................125 Jumping across banks...........................................................................132 Bottom line..........................................................................................132 Chapter 7 • Getting Started With C........................................................ 134 The C workflow....................................................................................134 Install MCC..........................................................................................137 Start MCC............................................................................................138 Flashing _a_ LED with MCC....................................................................141 Analyze code structure..........................................................................144 Flashing _a_ LED..................................................................................150 Analyzing compiler output......................................................................151 Bottom line..........................................................................................157 Chapter 8 • Interrupts and Timers à la C............................................... 158 Interrupt handling with C.......................................................................158 Provision of interrupt logic.....................................................................161 Merging changes (against MCC-generated code).......................................163
●6
Comparative analysis of execution speed.................................................165 Optimizing C code.................................................................................171 An overview of timers...........................................................................173 More timer play....................................................................................184 Using timers to control program execution...............................................186 Good night!.........................................................................................193 Pulsewidth modulation..........................................................................195 Frequency-derived gimmicks..................................................................204 Conclusion and outlook..........................................................................207 Chapter 9 • H ardware Accelerated Buses: I2C, SPI and more...................................................................... 208 SPI – if speed is needed........................................................................210 Programming SPI.................................................................................221 I2C — a bus for many............................................................................226 I2C, reloaded.......................................................................................233 Evaluate serial data..............................................................................247 Bit banging: Wiegand Protocol................................................................257 Bit banging: state machine....................................................................260 Bit banging: coding...............................................................................261 Bottom line..........................................................................................267 Chapter 10 • Storing Data During Power-off.......................................... 268 Writing to EEPROM................................................................................268 A matter of speed.................................................................................277 Addressing games................................................................................285 HEF, or abuse the program memory........................................................288 Aside: HEF, reloaded.............................................................................295 The bottom lines..................................................................................300 Appendix A: Search Ranking.................................................................. 301 Appendix B: Fast Spectral Components.................................................. 303 On waves and parts..............................................................................304 Deeper analysis!...................................................................................306 What’s in it for me?..............................................................................309
●7
Starting Electronics - Microcontroller Basics with PIC Where do we go from here?................................................................... 310 Get help..............................................................................................310 Ideas from third parties.........................................................................312 Contacting the author...........................................................................314 Index..................................................................................................... 315
â—?8
Chapter 1 • Introduction and motivation
Chapter 1 • Introduction and motivation Many moons ago, a young man found a chance to escape his dusky surroundings by studying electronics and process computer design: a computer or an operational amplifier care not if you are young or old, a jock or nerd, Arab or Zulu, rich or downtrodden, gregarious or quiet. A Dutch publishing house, Elektor, provided a long-legendary series called Starting Electronics. Its practical focus stood out from other works: examples which could be executed with affordable, cheap to obtain (and to conceal) hardware made experimenting at home easy while also providing background information. The knowledge gained from these works then allowed me to proceed to a variety of tasks, leading to a good livelihood. My work on this book aims to distill my practical experience from all these years into a compact form. I want to show you all relevant aspects of the microcontroller world, while not overwhelming you with useless university level knowledge. When done, you should find yourself equipped with a solid understanding of 8-bit microcontrollers, ready and waiting to undertake great and monetarily or militarily rewarding tasks. Instead of dedicating my work on this book to any individual, please allow me to dedicate it to all who might find themselves in a situation similar to mine. May this book help you achieve your goals. Instead of an introduction – on buying an NE555 After being out of the electronics game for many years – mobile computing provides for an interesting, and wife-compatible income – I returned to my old place of worship. Not much had changed at the Eastern European distributor which supplied me well during darker days: the owner was still puffing on her cigar, which had become noticeably fatter and of a pricier brand. So had my waistline and my belt, as she noted pointedly. I set out to build a small pulse generator using a stock timer IC called NE555 which was all over the place some 10 years ago. To my dismay, my old friend informed me the parts are now used only by the old people. Everybody else would simply use a PIC, and go away having a happy day. Not only thanks to Massimo Banzi’s Arduino, microcontrollers have invaded all parts of electronics. This brave new world has its benefits: in the case of my above-mentioned pulse generator, for example, the digital solution allowed me to implement more sophisticated waveform patterns, thereby yielding better results ●9
Starting Electronics - Microcontroller Basics with PIC
from the device under test (commonly abbreviated DUT or DuT). Furthermore, inexpensive digital sensors take away the pain of signal conditioning. If you ever had the displeasure of dealing with exponential and logarithmic functions required for linearizing analog sensor output, simply being able to fire off a quine via a serial bus and get humidity and temperature information in exchange sounds like a miracle. In short, to paraphrase an ad campaign of old, it truly is the age of the microcontroller. The availability of high-level programming languages leads to a shocking lack of familiarity with the basics. More than once, a start-up contacted me asking for help how to get the “^)$#@#! Arduino board out of their solution.” And no, we did not talk about an advanced ARM core – the MCU in question was a primitive eight-bitter, not dissimilar to the one used in this book. A person with a solid understanding of microcontroller hardware and power supply architecture can find himself all kinds of small consulting gigs helping out university students, start-ups and the like. Why PIC? Why assembler? My long-time pal Michael Markowitz, a microcontroller designer who now handles PR at STMicroelectronics, encouraged me to add an additional 24 bits to the thinking of my readers. Advanced controllers like STM32 are impressive – their power allows the advanced visualizations seen in the Tamoggemon HygroSage product line. It is true that the PIC, an ancient eight-bit design, is far from cutting edge. On the other hand, the PIC is easy to handle, comes in a DIP case, is easily available and easy to understand. The whole data sheet of the average PIC is shorter than the mere architecture description covering the soft core (the actual computing element) found inside of an advanced high-power microcontroller. This primitivity has its advantages. A person who understands how a microcontroller works in principle has a better time when it comes to reading the above-mentioned core architecture introduction. Furthermore, he is able to, at least in theory, look behind the C compiler’s veil, which can be tremendously helpful when finding performance problems. This will also become apparent in the second part of the book, where the focus shifts away from assembler and looks at “solutions” which provide more complex interaction patterns with real-world hardware.
● 10
Chapter 1 • Introduction and motivation
What do we need? Long gone are the days when getting started with microcontroller programming was expensive. In terms of computer equipment, we don’t need particularly much either - yours truly toils away on his trusty AMD FX8320 workstation, which can be bought on the used market for cheap. However, the eight processor cores are overkill - MPLAB is not a particularly demanding platform. When working with Microcontrollers, an oscilloscope eventually crops up on your wanted list. The following book was created using a wide variety of test equipment which the author collected during his career. The brunt of the work was carried by a LeCroy 9354AM, which can be acquired cheaply on the used market. However, since we provide screenshots of all scenes, the book can also be used without an oscilloscope. In addition to that, we sometimes use a Danaher (Tektronix) TDS754D to determine time-depth information. Before you buy an oscilloscope, be sure to gain some experience with the various devices - there are many places in the book that have background knowledge to help you choose your dream device. From a wetware point of view, bring along basic knowledge of electronics. If you have read some of the previous parts of this series, you should be primed to go. Advanced mathematical knowledge is explicitly NOT required. Furthermore, the C parts will not be much fun if you don’t know the basics of C programming, but this is a skill which you can easily pick up on the go by reading a C book while working with the (intentionally simple) examples. Finally, bring along curiosity and willingness to switch between the hardware and software domains. Successful microcontroller developers see their task as a combinatorial job: limiting yourself to but one side of the equation tends to lead to grief. Installing MPLAB on Windows Microcontroller development traditionally was chaotic – Figure 1 provides a small overview of the various stakeholders. When deviating from pure Assembly development, the situation becomes complex: compilers for high level languages are a highly contested business. For some vendors chips, up to a dozen different environments fight for developers’ attention.
● 11
Starting Electronics - Microcontroller Basics with PIC
Figure 1.1: Desktop developers can – usually – get all of these tools from one source. Microchip always stood well outside of the established hierarchy, in that they offered their developers a custom development environment named MPLAB. As of this writing, MPLAB X is the current version, and it can be extended with a simple compiler for the C programming language. It might not generate the smallest or the most efficient code, but it is well-suited for small commercial tasks. Open https://www.microchip.com/mplab/mplab-x-ide in a browser of choice and scroll down to activate the Downloads tab. MPLAB is available for Windows, Linux and the Mac OS – we use Windows 8 as the transcription software used for writing this book runs but under Windows. In practical development, Linux and Mac OS behave the same – in fact, yours truly does most of his daily work under Ubuntu. The default settings of the deployment wizard can all be accepted 1:1, leading to a swift and unproblematic deployment of the product. The IDE will also ask you if you want to allow the installation of drivers. Accepting this is recommended, as the programming device will not be detected by the workstation otherwise. When done, Figure 2 will pop up. The MPLAB deployment assistant does not download the C compiler and the automatic project generator – checking the first and the third box is highly recommended.
● 12
Chapter 1 • Introduction and motivation
Figure 1.2: Our job is somewhat undone... After finishing the first step of the deployment assistant, the MPLAB installer will open two browser windows. One of them allows you to download the code configurator, while the other one permits the downloading of C compilers. We will start out with C – as of this writing, the URL http://www.microchip.com/mplab/ compilers is used. Scroll down, and enable the download tab once again. As we want to work but with 8-bit controllers, select the compiler “MPLAB® XC8 Compiler”. Its defaults can also be left alone, as the Free version suffices for most applications. Activation can be skipped by clicking Next. Finally, close the Code Configurator window with the URL http://www.microchip.com/mplab/mplab-code-configurator. Deploying MCC is not needed now and can be resumed later by visiting http://www.microchip.com/mplab/mplab-code-configurator. With that out of the way, the first round of the battle is won. Figure 3 shows how the MPLAB IDE’s welcome screen looks after starting it for the first time. Should your Windows installation issue a firewall warning, make sure to allow MPLAB to access both private and public networks in order to enable all of the debugging functionalities.
● 13
Starting Electronics - Microcontroller Basics with PIC
Figure 1.3: MPLAB X is ready to go to war!
â—? 14
Chapter 2 • Executing Assembly in Sequence
Chapter 2 • Executing Assembly in Sequence After having set up MPLAB X in the previous chapter, it is now time to start with the first few examples. Please, bear with me, however: while everyone fully understands that you want to get cracking, we need to clear a few bits of theory. When done with the example, you feast your eyes upon a “blinking” LED. Getting closer to the PIC The PIC is not a new architecture by any means: many legacy solutions can be found. If you start out with a design from literature, check whether the IC used still is in production. Many popular parts are no longer available or will be discontinued soon (see Figure 1).
Figure 2.1: Use this PIC at your own peril. Microchip likes to grow by expansion: the firm offers literally dozens of microcontrollers. In this book, we will stick to systems which work with 8-bit data words. In the realm of 8-bit microcontrollers, four families are known. They differ not only in price, but also in case size and software-related attributes such as stack size, which determines how deeply function calls can be nested. Table 1 provides a short overview of the possibilities.
● 15
Starting Electronics - Microcontroller Basics with PIC
Discipline
Baseline
Mid-Range
Enhanced
PIC18
Mid-Range Types
PIC10F2xx
PIC10F3xx
PIC12F1xxx
PIC12F5xx
PIC12F6xx
PIC16F1xxx
PIC16F5x
PIC12F7xx
PIC16F5xx
PIC16F6xx
PIC18Fxxx
PIC16F7xx PIC16F8xx PIC16F9xx Number of instructions 33
35
49
83
RAM size in Bytes
144
368
4 KB
8 KB
Program words
2K
8K
32 K
128 K
Stack depth
2
8
16
32
In practice, specify how much memory and which hardware features you need. Next, look at a distributors website to find out which chips meet your needs. When done, head over to a price comparison service such as OEMsecrets to complete the purchase on the cheap. The following two pages contain a printout of Microchip’s line card – it is not complete, but goes into detail on non-memory-related hardware features.
● 16
Chapter 2 • Executing Assembly in Sequence
8-bit PIC® Microcontroller Peripheral Integration Quick Reference Guide® Microcontroller Peripheral Integration 8-bit PIC
PIC16(L)F145X 8–48 PIC16(L)F153XX
14–20 3.5–28 2048
14
HEF
8–20 1.75–14 PIC1X(L)F157X 8–14 1.75–3.5 128 – PIC1X(HV)F752/53
HEF
10
HEF
ü
HEF
ü
1024 10
HEF ü
2048 10
ü
HEF
128 10
ü
–
256
14–20 3.5–14 8–14 1024 PIC16(L)F170X PIC1X(L)F1612/3
ü
ü
5
8
10
ü
ü ü
10
ü
ü ü
ü
10
ü
5
ü
ü
4
ü
ü
ü
5 ü
ü
ü ü
ü
ü ü
ü
ü
ü
5/9 ü
ü
ü ü
ü ü
ü
4
ü
ü ü
8ü
ü
ü
üü
ü
ü
5/810 ü ü
8ü
ü
ü
üü
ü üü
ü
PIC16(L)F170X 14–40 PIC16(L)F176X/7X
7–28 14–202048 3.5–14HEF
1024 10
HEF ü 5/1010 ü
ü üü 5/8 ü
ü ü
ü
üü
ü
8–20 PIC16(L)F183XX PIC16(L)F171X
3.5–1428–402048 7–28 256
ü HEF
5 10
ü
5/8
ü ü
ü
2048 12(3)
ü HEF
5 10
ü
ü 5/10
ü ü
ü ü
7–56 8–20 4096 3.5–14256
2048 10(3)
ü 256
5 10
ü
5ü
ü
ü
28–64 14–56 14–284096 7–28 256 PIC16(L)F191XX PIC16(L)F184XX
ü
ü
ü ü
ü ü
ü üü üü ü
ü
ü üü üü
ü ü
ü
üü üü ü
ü
ü üü
ü
üü
ü
ü
ü
ü üü
ü ü
üü
ü
28–48 16–12828–648192 14–56 256–1K 4096 12(3) PIC18(L)FXXK42PIC16(L)F191XX
ü 256
5 12(3)
ü
5ü
ü
4
ü üü üü ü
üü
64–100 32–12828–644096 16–128 – PIC18(L)FXXJ94 PIC18(L)FXXK40
12 3728
ü256–1K
10(3)
ü
5
ü
28 32–64 28–484096 16–1281K PIC18(L)FXXK83PIC18(L)FXXK42
12(3) 8192
ü 256–1K 5 12(3)
ü
ü 5
ü
ü
ü
ü
ü
PIC18FXXQ10
ü
–
5
ü
ü ü
ü
ü üü
üü
ü
ü
ü
ü ü
ü
ü
ü
ü
üü
ü
ü
ü
ü
ü
ü
ü
32–64
4096
1K
12(3)
ü
5
ü
ü
ü
ü
28–40
128
3728
1024
10(3)
ü
5
ü
ü
ü
ü
ü
ü ü üü
ü
ü üü
ü ü üü
ü ü
üü ü ü ü
ü
ü
üü
ü
12
28
ü
üü ü
üü
ü üü ü
ü
ü
ü ü üü
üü
ü ü
ü
ü
ü
ü ü
ü
5ü
3728 1024 10(3) 64–100 32–128 4096
ü
ü üü
5ü
ü
128
ü
ü
ü
ü
ü
ü
ü ü
5 10(3)
ü
ü
üü
ü
5 12(3)
ü
üü
ü üü ü
ü 256
ü ü
üü
ü 256
ü üü ü4 ü
ü
ü
ü ü
ü
ü ü üü ü
ü
ü
ü
12(3) 2048
ü
ü
ü
ü
28–64 16–12828–403728 7–56 256–1K 4096 10(3) PIC18(L)FXXK40PIC16(L)F188XX
ü
ü
ü ü
ü 5/810 ü
ü
ü
ü
ü
HEF ü
2048 10
ü
ü
ü
ü ü ü
HEF ü
ü
ü
ü
25610
14–28 7–28 14–402048 7–28 256 PIC16(L)F184XX PIC16(L)F176X/7X
ü ü
ü
ü
1024 10
PIC18(L)FXXK83
ü ü
3.5 HEF
28–40 PIC18(L)FXXJ94
ü
ü
ü
7–28 14–202048 7–14 HEF
PIC18FXXQ10
ü
L
ü
ü
10
5/9
ü
ü
10(2)
5
8
ü
28–40 PIC16(L)F171X PIC16(L)F161X
28–40 PIC16(L)F188XX PIC16(L)F183XX
Safety an Monitorin
Timing and Measurements(1)
DSM 16-bit PWM AngTMR COG HLT (8-bit) CWG 16-bit PWM (16-bit) NCO NCO (20-bit) DSM SMT (24-bit) AngTMR RTCC HLT (8-bit) TEMP/TS 16-bit PWM (16-bit) CLC NCO (20-bit) MULT SMT (24-bit) MathACC RTCC CRC/SCAN TEMP/TS HLT
ü
NCO 10-bit PWM
10-bit PWM
COG
CCP/ECCP
PRG
OPA
DAC (# of bits) ZCD
DAC (# of bits) ADC (# of bits) OPA Comp PRG HSComp SlopeComp
Comp ü
8
3.5–28 HEF
3.5
8–48
1024 10
ü
Waveform Control
ü
HEF
8–14 1.75–3.5 PIC1X(HV)F752/53 14–20 7–14 1024 HEF
PIC16(L)F153XX 8–14 PIC1X(L)F1612/3 PIC16(L)F161X
8
10 64 10(2) 256 10 1024 10
Data EEHSComp (B)
Data EE (B) HEF
8 3.5 256 HEF 6 384–896 PIC10(L)F3XX 14–20 7–14 1024 HEF PIC16LF155X/6X 8 3.5 PIC12LF1552 14–20 14 1024 HEF PIC16(L)F145X 14–20 7–14 PIC16LF155X/6X 8–20 1.75–14 1024 HEF PIC1X(L)F157X
RAM (B) ADC (# of bits)
RAM (B) 64
Program Flash Memory (KB)
Pin Count
PIC10(L)F3XX PIC12LF1552
Logic and Math
(1) TimingFunction and Measurements Peripheral Focus
Intelligent Analog
CWG CCP/ECCP
384–896
Product Family
Waveform Control
ZCD
Program Flash Memory (KB)
6
Product Family
Peripheral Function Focus Intelligent Analog
16-bit PWM SlopeComp
Pin Count
Quick Reference Guide
ü
ü üü ü ü
ü ü üü
ü ü
ü
www.microchip.com/8bit
www.microchip.com/8bit
● 17
ü
ü
ü
ü
ü
ü
Peripheral Integration
Starting Electronics - Microcontroller Basics with PIC Peripheral Function Focus
ü
ü ü
ü ü
ü
ü ü
ü
ü
ü
4
ü
ü
ü ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
4
ü
ü
ü
ü
2
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü ü
ü
ü
ü
ü ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü ü
ü
ü
ü
ü
ü ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
2
2
ü
ü
ü
DIA/MAP
DMA/VI
IDLE/DOZE/PMD
PPS
LCD
HCVD ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
2
ü
ü
ü
ü
ü
ü
2
ü
ü
ü
2
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
5
2
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü ü
ü
ü
ü
ü
1
1
4
ü ü
mTouch® Sensing
LIN Capable
USB with ACT
ü ü
ü
ü
ü
ü
ü
ü
ü ü
I2C/SPI
UART with Protocols
ü
ü
ü
ü
ü
ü ü
Low Power and System Flexibility
ü
ü ü
User Interface
Communications
EUSART/AUSART
WWDT
HLT
Safety and Monitoring
CRC/SCAN
ü
MathACC
ü
MULT
CLC
ü
Logic and Math
TEMP/TS
RTCC
SMT (24-bit)
NCO (20-bit)
16-bit PWM (16-bit)
HLT (8-bit)
ü
AngTMR
NCO
ü
Timing and Measurements(1)
DSM
CWG
COG
16-bit PWM
10-bit PWM
CCP/ECCP
ü
ü
ü
ZCD
Waveform Control
SlopeComp
PRG
OPA
alog
ü
ü
ü
ü
ü
ü
2 2
2 2 ü 2
ü
ü
ü
ü
ü
ü
ü ü
ü(5)
ü
ü
ü
ü
ü
ü
ü
ü
ü
ü(5)
ü
ü
ü
ü
ü
ü
Figure 2.2: ww1.microchip.com/downloads/en/DeviceDoc/30010068F.pdf Hardware is usually but a small part of the total cost. During development, it is highly recommended to pick a slightly more powerful controller with a large memory, as having to change the PCB design when you run out of memory is very annoying. Furthermore, you can always optimize things if you find out the PICs share of the BOM is significant. In today’s market, being the first beats being good: once a solution has entrenched itself as a standard, fighting against it is difficult. Building a testing rig No matter how we slice and dice it: we need to decide which controller will be used during the following steps. Yours truly decided to spungle a little bit: the PIC 16F18877 definitely is not the cheapest part. However, it is beneficial as it has a relatively complex internal architecture and a large amount of peripherals, ● 18
Chapter 2 • Executing Assembly in Sequence
thereby providing space to grow. The low-end 16F1503 will be discussed in the chapter on the CLC – no need to worry that you miss out. When working with embedded systems, it is recommended to build yourself a testing rig. Yours truly has done this for simple and complex projects alike - if you are knee-deep hunting down software problems, not having to worry about leads going loose on a breadboard is helpful. Furthermore, breadboards are not recommended for high-speed designs - interconnection capacitances cause problems with high-speed buses, switching regulators and precision amplifiers. Either way, a workable design for our controller looks like Figure 2.3.
Figure 2.3: This basic circuitry makes sure that we can experiment with the controller. In terms of building the testing rig, proceed as you see fit. Yours truly is an old hand and decided to use some prefabricated PCB material alongside a socket and some binding posts leading to the result in Figure 2.4. You can, of course, also pick another approach – as a testing rig is intended to serve nobody but you, it should be laid out to your tastes. Should you ever need yours truly to testify about this in a lawsuit against an uppity University, feel free to contact me at any time.
● 19
Starting Electronics - Microcontroller Basics with PIC
Figure 2.4: Thanks to the pins at the bottom, the testing rig can be placed on a breadboard. Textool el-cheapo! For rigs which see a lot of action, a textool socket is recommended. They can be purchased quite cheaply at aliexpress.com – just be prepared to wait up to four weeks for delivery. Yours truly usually buys two or three to keep a small stockpile on hand. While PICs accept a variety of voltages, we stick to 5 V. This is done for convenience – nothing speaks against a 3.3 V testing rig. The main amount of circuitry is caused by the ICSP programming connection: if you look at the PICKit, you can see a six-pin header at the front of the device. This exposes Microchip-specific pins, which allow the device to communicate for programming and debugging purposes. One interesting aspect of microcontroller design involves exposing ICSP pins in production: for small volumes, programming the boards after they are built beats buying expensive preprogrammed devices. Furthermore, ICSP makes firmware updates in the field less costly. Of course, this also is a simplification for people wanting to steal your code – keep in mind that the former Soviet Union is full of laboratories which crack PICs for less than $1000 a pop. Due to that, the additional safety risk can usually be disregarded in exchange for higher degree of convenience. The main part of interest in the 50-kΩ resistor between the MCLR pin and the power supply: MCLR is active low, which forces a reset of the PIC. By using a high-value resistor we can “pull up” the pin — the programmer can easily divert the minimal current to ground and trigger a reset during the communication. ● 20
Chapter 2 • Executing Assembly in Sequence
Reuse the pins! The ICSP pins can also be used for other applications. In this case, stick to the rules shown in the figure.
Figure 2.5: Some parts are not allowed in ICSP-related connections (via http://ww1.microchip.com/downloads/en/DeviceDoc/50002721A.pdf) An introduction to Assembly Even though there still is quite a bit to discuss, we should now make a LED blink. Connect it according to Figure 4, and don’t forget to include the resistor. Furthermore, make sure that all Vdd and Vss pins are connected to one another. While ignoring this rule usually has little consequences, in some cases, odd things happen. The reasons for this are discussed further in the appendix. Given that PICs are intended for controlling hardware, the outputs can source and sink quite a bit of current – this can be surprising for people who switch from process computers such as the Raspberry Pi, whose BroadComm SoC has problems sourcing current. Our PIC can, in theory, source up to 50 mA. This, of course, is not a value one should ever reach.
● 21
Starting Electronics - Microcontroller Basics with PIC
Figure 2.6: The LED is connected to one of the pins. In the next step, click the “MPLAB X IDE” shortcut on the desktop or in the start menu to fire up MPLAB. Click File → New Project to open the project generator wizard, and proceed to selecting the template Microchip Embedded → Standalone Project. Next, the wizard asks which microcontroller is to be targeted. A quick and easy way to cut through the pretty large list of choices is typing in part of the name in the device combo box. MPLAB enters into a tight connection with the underlying development tool. The first step allows you to select the tool which you want to use with the project – yours truly will stick to the PicKIT 4. If you have a PicKIT 3 or an ICD 3 or ICD4, you can, of course, also use it. As our microcontroller has all debugging features on board, the fifth step about selecting the plug in board does not apply to us. Some low-end PICs need expansion boards to enable debugging features. For now, switch to the sixth step and select the MPASM assembler. Finally, a name must be assigned to the project. We will use CH2-Demo1 in the following steps; feel free to pick a different name. As of this writing, newly generated projects do not get any contents except for the makefile, which should not be of concern for us in this book.
● 22
Chapter 2 • Executing Assembly in Sequence
Automatic control! A makefile is a special command sequence which gets executed by a Linux command line tool called make. It controls compilers, linkers and other tools. Should you ever find yourself working on large projects, having a basic understanding of make is recommended. A good resource for getting started can be found at https://www.gnu.org/software/make/manual/html_node/Introduction.html. In MPLAB, however, no action is needed – the IDE does a very good job of configuring things. Right-click the node Source Files, and select the menu option New→pic_8b_simple.asm to open the assembly file generator. The default settings can be confirmed by clicking Finish, leading to the following file: ; TODO INSERT CONFIG CODE HERE USING CONFIG BITS GENERATOR RES_VECT GOTO
CODE
0x0000
START
; processor reset vector ; go to beginning of program
; TODO ADD INTERRUPTS HERE IF USED
At runtime, our PIC loads commands from the program memory in a one by one fashion. Assembly is unique in that every command (usually) translates to one location in memory. For example, the GOTO command would become the GOTO bit sequence, and would find itself at the place commanded by the RES_VECT directive. If we were to place another instruction below GOTO, it would find itself below it in program memory. Understanding start-up When powered on, the controller needs to start somewhere. On the PIC, the entry point is at the very top of the memory, which corresponds to address 0x0000. The directive RES_VECT allows us to designate that the sequences following after it are intended to go to this address. In practice, one usually places a command jumping to the actual main program. This is caused by the interrupt vector, which we will look at in one of the following chapters – it sits at 0x0004, and should be “kept free”. After that, the assembler file places another section which contains the main program’s code. As its code statement does not contain an address, the linker can float it around the program memory as it sees fit:
● 23
Starting Electronics - Microcontroller Basics with PIC
MAIN_PROG CODE
; let linker place main program
START GOTO $
; loop forever
END
As executing “unprogrammed” parts of program memory is a classic antipattern, we place an endless loop in the main code – it stalls program execution by repeatedly jumping upwards. Our PIC, being a RISC microcontroller, executes most assembler instructions in a single step. When looking at an assembler file, you can trace it by hand - simply take a pen, and jump from command to command. After all of this theory, it is now time to start blinking. Replace the code in the ASM file with the following, which we will discuss after running it: LIST
p=16f18877
#include <p16f18877.inc> RES_VECT GOTO
CODE
0x0000
START
MAIN_PROG CODE
; processor reset vector ; go to beginning of program ; let linker place main program
START ;Set Bank 0, we never know BANKSEL TRISA MOVLW B’00000000’ MOVWF TRISA BANKSEL ANSELA MOVLW B’00000000’ MOVWF ANSELA BANKSEL PORTA MOVLW B’10101010’ MOVWF PORTA WORK COMF PORTA, 1 ;to F GOTO WORK END
● 24
; loop forever
Chapter 2 • Executing Assembly in Sequence
Dynamic hardware configuration Microcontrollers tend to be very flexible: unlike whiny microprocessors, they can supply clock in various fashions. In our PIC, operational status is set via a total of six registers – their content is written during programming and configures various parts of the MCU. Figure 6 makes an example of the clock supplying circuit: values such as COSC and CDIV are taken from the configuration registers and permit the customization of hardware behavior.
Figure 2.7: PIC configuration takes place in both hardware and software. Generating these configuration bits by hand tends to be an annoying job. MPLAB provides a sophisticated generator which lets us work around the problem: click Window → PIC Memory Views → Configuration Bits to open the configuration options. Our PIC can receive its working frequency from a variety of sources: if high accuracy is needed, external resonators can be connected. On some PICs, an external RC oscillator can also be used. Furthermore, most recent PIC microcontrollers have an internal oscillator module which means that no external parts are needed if reasonable accuracy is “good enough”. First, set FEXTOSC to ECM to disable the logic needed for advanced clock sources. Then, set RSTOSC to HFINT1 in order to use the 1MhZ clock source in the chip. Finally, WDTE must be set to OFF in order to prevent the watchdog timer from resetting the PIC all the time. ● 25
Starting Electronics - Microcontroller Basics with PIC
Next, click the Generate Source Code button to generate the following- It must be placed in lieu of the comment at the top of the asm file: #include “p16f18877.inc” ; CONFIG1 ; __config 0x3FEE __CONFIG _CONFIG1, _FEXTOSC_ECM & _RSTOSC_HFINT1 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON ; CONFIG2 ; __config 0x3FFF __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _ BORV_LO & _ZCD_OFF & _PPS1WAY_ON & _STVREN_ON ; CONFIG3 ; __config 0x3F9F __CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC ; CONFIG4 ; __config 0x3FFF __CONFIG _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON ; CONFIG5 ; __config 0x3FFF __CONFIG _CONFIG5, _CP_OFF & _CPD_OFF
For now, we will stick to offline programming – this means that the PICkit supplies power to the PIC while it is being programmed. Later on in the book, we will also work online. For now, keep in mind that the PicKit will stop the PIC from running while it is connected. Right-click the project in the Projects folder and select the Properties window. Next, click Conf: [default] → PK4 to open the PicKit 4 settings window: as the PicKit 4 is quite new when this book is written, the name PK4 might change. Next, select Power in the Option categories field, and check the “Power target circuit from PICkit 4” checkbox as shown in the figure.
● 26
Chapter 2 • Executing Assembly in Sequence
Figure 2.8: If this checkbox is enabled, the PICKit will power the DUT. Click the “Make and Program Device Main Project” in the toolbar – it is the little arrow pointing at the chip. MPLAB will pop up a window for selecting the programmer which should be used for deployment. Select our PICkit 4 and confirm the warning about 3V3 and 5V devices. When done, the PICKit 4 window will contain the message “Programming/Verify complete”.
Figure 2.9: These symbols allow the interaction between PIC and programmer. In the next step, disconnect the programmer from the evaluation board, apply external power and look at the LED. It will appear to be permanently on, but not at full brightness. Connecting an oscilloscope to pin 5 reveals the reason – our PIC works really, really fast.
● 27
Starting Electronics - Microcontroller Basics with PIC
Figure 2.10: Even at 1 MHz nominal clock, the PIC is quite fast. What happens in the background? It takes but one look at the diagram to understand that something is happening. The PIC is running through the program and changes the value of the output. To understand this further, we need to look at figure 2.11 â&#x20AC;&#x201C; it shows the architecture of the chip. Information can either be data or code, with code words commanding the MCU what to do with the data at hand. The separation of buses is helpful in that it allows different widths; our PIC works with 14bit program words and 8-bit data words.
Figure 2.11: A Harvard architecture has separate buses for program and data memory. Program words are made up according to the scheme shown in figure 2.11. Due to the length of only 14 bits, the amount of information is limited â&#x20AC;&#x201C; it is not possible to transfer more than one eight-bit data address per command. Microchip addresses this problem via an additional register called W, short for working register - sometimes, it also is referred to as Omega.
â&#x2014;? 28
Chapter 2 • Executing Assembly in Sequence
Figure 2.12: PIC instructions know but a few design schemes. Many, if not most commands involve the value of Omega. For example, writing an integer to a specific location in memory is accomplished via the following sequence: MOVLW B’00000000’ MOVWF TRISA
MOVLW – short for MOVe Literal to W – loads the provided bits into the working register. In the next step, MOVWF – short for MOVe W to File register - is responsible for transferring the data found in Omega to the storage register. In our case, a total of three different registers are initialized, whose role will be analyzed in the following section. For now, simply accept that their presence is required if the PIC is intended to output waveform information. The actual output is handled in an endless loop, which is structured as following:
● 29
Starting Electronics - Microcontroller Basics with PIC
WORK COMF PORTA, 1 ;to F GOTO WORK
; loop forever
END
COMF – short for COMpliment content of File register – is responsible for inverting the content of the register. Furthermore, it takes an integer parameter commonly known as D or direction. If D is set to 1, the result of the operation is written back to the register. If the value is set to 0, the data ends up in W instead. Finally, the GOTO instruction makes sure that the PIC jumps back to the beginning. Due to architectural specialties, commands like GOTO take longer than their normal brethren – we look at this in more detail in the following chapter. How outputs are configured At this point, one question remains: how does the modification of the value of the PORTx register affect the output circuitry? To answer this, we must return to the block in the beginning of our program. It presents itself as following: BANKSEL TRISA MOVLW B’00000000’ MOVWF TRISA BANKSEL ANSELA MOVLW B’00000000’ MOVWF ANSELA BANKSEL PORTA MOVLW B’10101010’ MOVWF PORTA
Today’s microcontrollers have a limited number of pins competing for the attention of an almost unlimited number of peripherals. Thus, pin functions are assigned to physical pins during configuration. These mappings are created in a fashion like the configuration registers mentioned above, the main difference is that the values are usually changed at runtime. On the PIC, the situation is made especially complex. Pins usually act not only as inputs and outputs but can also perform analog and serial functions. We will discuss these in later chapters; for now, we will limit ourselves to traditional outputting of digital values. Figure 2.13 shows the internal architecture of the controller dedicated to one GPIO pin.
● 30
Chapter 2 • Executing Assembly in Sequence
Figure 2.13: The GPIO pins are quite complex contraptions. When dealing with GPIO ports, start out by looking at the configuration. The ANSEL register determines whether the pin is intended for the analog or the digital domain. As we want to work in the digital space, we must clear the register. Forgetting to do so is a very, very common problem and leads to non-working GPIO implementations. In the next step, the actual operation mode must be determined via the TRIS register. Most, if not all microcontrollers start up with all of their GPIO pins come configured as inputs. This approach is sensible, as it prevents the occurrence of weird effects during start up – an input has a very high internal resistance and does not interact much with the surrounding circuitry. For us, simply writing zeros to the register makes all pins act as outputs. Finally, the PORT register is responsible for outputting. When a pin is configured as an output, the bit corresponding to it is written into the output transceiver – if the pin is configured as input, its value can be harvested by checking the bit inside of PORT. With this, only the BANKSEL instruction remains unexplained. It stands for bank select and can be best understood by thinking about the instruction schemes. Addresses are limited to eight bits, thereby meaning that no more than 256 locations of memory can be addressed. The architecture solves this via a global register, which determines which block of memory is active. BANKSEL, then, is a convenience instruction which allows you to configure the memory subsystem to allow access to a specific register.
● 31
Index
Index Symbolen #asm macro 296 __delay_ms 150 #ifdef 39 __interrupt() 160 .mc3 139 #pragma 145
A ADDFSR 63 Adding 63 ADDLW 63 ADDWF 63 ADDWFC 63 AND 76 ANDLW 78 ANDWF 78 ANSEL 31 Arduino 9
B Baader-Meinhoff effect 177 backfeeding 266 Bank 0 41 BANKSEL 31 Baseline 16 BCF 70 binary system 59 Binary to Decimal, by hand 60 Bit banging 257 bit fields 148 Breadboard, problems with them 19 BSF 70 BSR 40 BTFSC 43 BTFSS 43
C compiler, inline and as Inline 171 CCP 198 clock supplying circuit 25 CLRF 68 CLRWDT 98 Code Generator, Workflow and MCC, workflow 136 COMF 78 Comments 38 Comparisons, arithmetical 67 Conditional commands 42 Constant Declaration 69 Core Registers 40 Core registers, detailed structure 121 C programming, delay 150 C Programming, structure 135
D DAC configuration 106 DAC, output current 109 DAC, reference voltage 106 Debugging with table 48 DECFSZ 43 Device Resource tree 140 d flag 45 Digit Carry 65 disassembly 114 Division by shift 79
E EEPROM 268 EEPROM, write latency 274 Enhanced Mid-Range 16 ERES 108 EUSART 250 evaluation board 229
C
F
CAPTURE/COMPARE/PWM MODULE 198 Carry 65
function pointers
161
â&#x2014;? 315
Starting Electronics - Microcontroller Basics with PIC
G General Interrupt Enable 84 GIE 84 GPIO pin, architecture 31
H Harvard architecture 28 HEF, access delay 294 Hexadecimal 60 high operator, low operator 122
I I2C 226 I2C1_Master 239 I2C1_MasterReadTRBBuild 239 I2C1_MasterTRBInsert 240 I2C1_MasterWriteTRBBuild 239 I2C Bus, topology 226 ICSP 20 Ifdef 38 INCFSZ 43 Inclusive OR 76 Instruction, side effects 45 Integer Arithmetic, overflow 49 Interrupt, deterministic response time 95 INTERRUPT_GlobalInterruptEnable() 145 interrupt_manager.c 187 Interrupt, on pin change 92 INTERRUPT_PeripheralInterruptEnable() 145 Interrupt vector 85 IORLW 78 IORWF 78
L LATX 190 LFINTOSC 194 Logic gates 76 Loop, manual unrolling
â&#x2014;? 316
N NOP 36 NOT 76 NVM UNLOCK SEQUENCE 273
O Omega 29 OR 76 Oscilloscope, limited resolution 108 Overflow 49
56
P
68
Parallel Bus 208 Pareto principle 49 PCLATH 118
M Magic Constants
makefile 23 Masking 77 Master Synchronous Serial Port 215 mc3 file 139 MCC, configure GPIO 140 MCC, EEPROM API 270 MCC Generated Files 144 MCC, generated project structure 143 MCC, GPIO API and C Programming, GPIO API 148 mcc.h 147 MCC, I2C API 233 MCC, Installation 137 MCC, SPI API 215 MCC, Timer API 176 MCC, UART API 251 Mid-Range 16 MISO 210 modulation domain analyzer 33 MOSI 210 MOVLW 29 MOVWF 29 MPLAB 12 MPLAB, Linux and Mac OS 12 MSSP 215 Multiplication by shift 79
PC logic analyzers from Saleae 209 PEIE 84 PIC18 16 PIC Families 16 pin_manager.h 147 pipelining 36 pointer 104 Polling 91 PORTA, blocked by CLKOUT 61 PORTx register 30 postfix increment 254 prefix incrementation 275 preprocessor 69 Preprocessor, C programming 135 Preserve EEPROM Memory 276 Preserve Program Memory 276 Program Counter 52 Program Word Scheme 29 Project Resource List 140 pull-down 86 pull-up 86 Pulsewidth modulation 195 PWM 195 PWM1_LoadDutyValue 202 PWM, Frequency selection 197 PWM, set duty cycle 202 PWM, timer setup 200
R register 31 Reset Vector 23 RES_VECT 23 RETFIE 93
S SCLK 210 Serial bus 208 shared memory area 41 Sleep instruction SLEEP mode Sleep mode, with timer soft core
97 96 193 10
software breakpoint 242 software breakpoints 126 SPI 210 spi1.c 217 SPI1_DUMMY_DATA 221 spi1.h 217 SPI, alternative pin names 210 SPI, Mode 211 SS 210 SSD1306 212 SSD1351 212 SSP1BUF register 219 stack 52 Stack, overflow 54 state machine 260 status register 45 STM32 10 SUBLW 66 subroutine 51 Subtraction 66 SUBWF 66 SUBWFB 66
T T0EN bit 181 Tables from data memory 112 Textool 20 Timer0 175 Timer1 175 Timer2 175 Timer, as interrupt source 187 TMR0_ReadTimer 181 TMR0_WriteTimer 181 Toolchain 12 TRIS register 31 TWI 226 Two’s complement 72
U udata_shr 41
● 317
Starting Electronics - Microcontroller Basics with PIC
W Watchdog timer 98 WDTE 99 Wiegand Protocol 257 working register 29 WriteBlock 290 WriteWord 290
X XOR 76 XORLW 78 XORWF 78
â&#x2014;? 318
Starting Electronicsmit PIC Mikrocontroller-Basics
Microcontroller Basics Elektronik gar nicht schwer with PIC Tam Hanna, Occus maio. Re porporitatas ex ea voluptatquia vel molectur apit quas ea dolorecum dent fugias evenian ditaqui sum unt odis ma Tam Hanna eost,been ute sapidendio te id has programming and developing que sent quia vitiatquam microcontroller and que volorro cuptatur microprocessor systems re, odis et latempor mo for over 15 years aimed at explaborio volecti cus, various application areas. quid quatemp erumet Besides his consulting reperum expelit activities re, he gives assit, sequam est qui lectures at congresses, dolorestiur, occatem. writes specialist articles Ipidem illo bla conessinis for various magazines, and tutors. His quias popular dolores sequid Instagram que voloriochannel beris ea qui supplies background odipide lligendam inctis information on anis dipicia quidus et measurement technology modi voluptatur maxim re and electronics. rem et restet occume con
ISBN ISBN978-1-907920-81-3 978-3-89576-339-7
On con et laborro blauta quibus doluptatur re quatiaest re In this book the author all essential aspects occullant qui cupidebis ea presents coremol uptatiis re consequi doof microcontroller programming, without overloading lendes aboreprat amusant ut adi dolore aut ut et eicidus ant the reader or quasi-relevant bitsevera of persped quewith eum unnecessary imus earum laut eumquas magnis information. Having read the book, incto you should be able to quiatem. Invenia quamet re quam cor re doloreri ium understand as well as program, 8-bit que dellaborio doloreptis etus aut etmicrocontrollers. qui aut quos am aut molorunt et queto omnia volore is eaquas aut rempori tatatThe introduction microcontroller programming is worked quid most iust qui aspe velitas aut et pliandi nihictate cum out using microcontrollers from the PIC series. Not exactly quibus ma conseri eumquunto aligeni stiusandenis state-of-the-art withaut just 8 bits, thetePIC micro has the dolupit iuscipsam dolo volore prat alibusapidi simi,in qui advantage of being easy to comprehend. It istem offered denihil maio vendignis simillant magnam es pori blautat iisa DIP enclosure, widely available and not overly complex. tis adit im labo. Bus et dolum Acesequod The entire datasheet of the doloribustet PIC micro fuga. is shorter by ut quatem utenecatur? Qui odi cus,architecture volum quunda conet decades than the description of the outlining fugit adit laboreptas con pariass imusdaecum ni aut eos aut the processor section of an advanced microcontroller. verum ratum nos quamhere. net, con pore, odion nullupSimplicity has dolore its advantages Having mastered the tio comnimu sapiet et resciis antias ut alicill you aborrum fugiae. fundamental operation of a microcontroller, can easily Nam voluptat. enter into the realms of advanced softcores later. Ad quiaplaced idicium quaspelibusa quis niet Having assembly code asqui theulparum executivevelique programming dentibeatio. Nequunt ant acererc hillore hiciaethe nos language in the foreground in the first partmolupit of the book, nulparcireaches conse pedis es rem estrumet reiciis essinto conauthor a deeper level with ‘C’odi in the second part. sequ iatiunda dolorem ea simin Cheerfully alongside theauditis official militiunt subject matter, theconsent, book non niendunt aut facepel exceproribus earcid utapresents tips & veliatur tricks, interesting measurement technology, tibus et ea nonsequi utessed et ipisprogramming, quatusd aecabo. Nem practical aspects of microcontroller as well reritiu ndende comnis earumquatur seque esto dolorem. as hands-on options for easier working, debugging and Denem si qui quame viduscium que nestias estor molupta faultfinding. peditat molorepro eaqui to omniae omnimod iorrum arumquos volorrum et prescipsam es duntibus volorestion re, quisquisim quid etur simi, cus dignihilique doluptis ex et erissit quas si reni bero modigen dandit eatempos et rere
Elektor-Verlag GmbH Elektor International Media 52072 Aachen www.elektor.com www.elektor.de
LEARN DESIGN SHARE
HARE HARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ● ● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIG DESI ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SH SH SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESIGN DESIGN ●● SHARE SHARE ●● LEARN LEARN ●● DESI DESI