• Out-of-Stock
C language for AVR microcontrollers. From scratch to advanced applications. Edition II
search
  • C language for AVR microcontrollers. From scratch to advanced applications. Edition II
ID: 295518

Tomasz Frenchman

Retired
 

Free shipping

free shipping in Poland for all orders over 500 PLN

 

Same day shipping

If your payment will be credited to our account by 11:00

 

14 days for return

Each consumer can return the purchased goods within 14 days

ISBN: 978-83-246-9814-1
Release date: 2015-01-09
Number of pages: 712
Format: 158x235 mm


Microcontroller under control!

  • Basics of microcontroller construction, what are the possibilities of the Atmel Studio environment and the Xplained platform from ATmega168 / 328
  • Architecture and instruction set, or why microcontrollers are worth programming in C language
  • Efficient writing of simple and complicated programs on AVR, or how to use different tricks

AVR microcontrollers are a group of systems offering great possibilities. Every amateur electronics and programming knows that you can use them in a thousand ways, and the simplicity of construction, speed of operation, the richness of the periphery and many free tools make them all the more attractive gadgets. If you would like to explore the secrets of programming microcontrollers or to improve your own skills in this field, it's time to look into this book!

The new edition includes changes that have taken place in the world of AVR in the last 3 years, i.e. the change of AVR Studio to Atmel Studio. You will find the basics of using the new IDE, creating and debugging projects in it. You will learn more about the changes in the avr-gcc compiler, especially the so-called named address spaces, which facilitated access to data stored in the FLASH memory of the microcontroller. You will discover how to use TV remote controls to control a written program and how to combine a C program with an assembler. LED enthusiasts will understand how to handle multi-colored matrices using the peripherals available in AVR, and how to hardware exchange data with popular LEDs with the WS2812B driver. If you want the microcontroller to become your ally, you must read this book!

  • Microcontroller and its surroundings, programmers
  • Arithmetic and bit operations
  • Project management and preprocessor
  • Core control and energy consumption management
  • Dynamic memory allocation and built-in EEPROM memory
  • Access to FLASH memory and microcontroller's IO ports
  • General purpose registers
  • Interrupts and timers
  • Comparator and analog-digital converter
  • Display support and interfaces (USART, SPI, TWI, USI, 1-wire)
  • Combining C code and assembler
  • Bootloader and program debugging

A microcontroller of great possibilities for your services!


Table of Contents

Introduction to the second edition (13)

Introduction (15)

  • Sample codes (16)
  • Schemes (16)
  • Required parts (16)
  • Support (18)

Chapter 1. How to start, or installing the environment (19)

  • Atmel Studio 6 - basics (20)
    • We're starting work - a new project (20)
    • Project options (22)
  • Atmel Studio - supplements (27)
    • Naggy (28)
    • MarginOfError (28)
    • Data Size Viewer (29)
    • Doxygen Integrator (29)
    • AnkhSVN (30)
  • AVR in the GNU / Linux system (30)

Chapter 2. Microcontroller and its surroundings (33)

  • Power connection (33)
    • Power decoupling (34)
  • Power filtering for the analog processor part (35)
    • Power supply (36)
  • Connecting a microcontroller with systems operating in a different voltage domain (39)
    • Conversion of logic levels between systems operating with different supply voltages (40)
    • Input and output pins (40)
    • Connecting the processor output to a 5V system (43)
    • Application of active converter (45)
    • Conversion from higher voltage to lower voltage (45)
    • Resistor splitter (46)
    • Using integrated circuit voltages for conversion (47)
    • Bidirectional buffer used in open drain (47)
  • Clock oscillators (49)
  • Rules for using external quartz (50)
  • Quartz generator 32768 Hz (52)

Chapter 3. Programmers (53)

  • Connection - general notes (54)
    • Problems (56)
  • AVR programming (56)
    • ISP programmers (57)
  • Programmers (59)
    • AVRISP mkII programmer (59)
    • USBASP programmer (60)
  • JTAG programmers (60)
    • JTAGICE mkII programmer (62)
    • JTAGICEIII (62)
    • Avron! (63)
    • AVR Dragon (63)
    • The debugWIRE interface (67)
  • Programming from the AS6 level - why use elf files (68)
  • Several processors and ISP interface (69)
  • Several processors in one system (70)
  • HV and parallel programmers (71)
  • TPI mode (71)
  • Atmel-ICE programmer (72)
    • Upgrading the firmware of tools (73)
  • Is it cheaper? (73)
  • Programming with tools provided by Atmel (74)
  • AVRDUDE program (75)

Chapter 4. What we're working on, or ATmega168 / 328 Xplained Mini at a glance (77)

  • Connection of the module (78)
  • Xplained Mini at Atmel Studio (78)
  • Pins IO (79)
  • First program (80)
    • We upload the first program (83)

Chapter 5. Configuration bits (85)

  • What is that? (85)
    • Lockbits (86)
    • Fusebits (86)
  • Call number (90)
  • Configuring fuse and lockbit in AVR-libc (90)
    • Lockbits in AVR-libc (91)
    • Fusebits in AVR-libc (91)
  • Configuration in Atmel Studio (92)

Chapter 6. Arithmetic and bit operations (95)

  • Arithmetic (95)
    • Binary representation of numbers (95)
    • Simple data types (97)
    • Fixed-point arithmetic (102)
    • Floating-point arithmetic (108)
  • Bitwise operations (116)
    • Bitwise product operation (116)
    • Bitcoin operation (117)
    • Operation of a disabling sum (118)
    • Bit negation operation (119)
    • Bitrate operations (120)

Chapter 7. Basics of C language on AVR (123)

  • Reach of variables (123)
    • Global variables (124)
    • Local variables (125)
    • Indicators (127)
    • Boards (133)
  • Structures (137)
    • Indicators and structures (138)
    • Anonymous structures (139)
    • Initialization of structure fields (139)
    • Unie (140)
    • Bit fields (141)
    • Definition and declaration (142)
  • Functions (143)
    • Passing parameters by value and reference (145)
    • Recursive function calls (145)
  • Keywords (146)
    • Operators (146)
    • Control instructions (150)

Chapter 8. Project management and preprocessor (155)

  • Preprocessor (155)
    • Directive #include (156)
    • Conditional build directives (157)
    • #Define directive (158)
  • Comments (160)
  • Naming (161)
    • Literals (163)
  • Code division into files (165)
    • Function visibility (169)
    • Visibility of variables - extern keyword (170)
    • Subdirectories (172)
  • The const (173) modifier
  • Static keyword (175)
  • Inline directive (175)
    • inline function (); (177)
    • static inline function (); (178)
    • extern inline function (); (179)
  • Register modifier (180)

Chapter 9. Program sections (183)

  • Data sections (184)
    • Section .text (184)
    • Section .data (184)
    • Section .bss (185)
    • The .eeprom section (186)
  • Sections containing the program code (186)
    • Subsections .init [0-9] (187)
    • Subsections .fini [0-9] (188)
  • Special sections (188)
  • Sections and compilation options (188)
  • Sections created by the programmer (190)
  • Placing sections at the address indicated (191)

Chapter 10. Core control and energy consumption management (193)

  • RESET signal sources (193)
    • Power-on Reset (195)
    • External RESET signal (195)
    • Brown-out Detector (195)
    • Watchdog system (196)
  • Energy consumption management (201)
    • Snoozing the processor (201)
    • Turning off the BOD system (202)
    • Turning off the processor subsystems (203)
    • Preskaler clock (203)
    • Other ways to minimize energy consumption (204)

Chapter 11. Dynamic memory allocation (207)

  • Memory allocation in the AVR-libc library (209)
    • Malloc (212)
    • Calloc function (212)
    • Realloc function (212)
    • Free function (214)
  • Memory leaks and misuse of dynamically allocated memory (214)
  • Collision and stack collision detection (216)
    • Method I - own memory allocation functions (217)
    • Method II - checking the amount of available memory (217)
    • Method III - marker (217)
    • Method IV - using the JTAG or debugWire interface (217)
    • Method V - a pattern in memory (219)

Chapter 12. Built-in EEPROM memory (223)

  • A few words about what EEPROM is (223)
  • Access to EEPROM in AVR (224)
  • Prevention of damage to EEPROM memory contents (225)
  • Read and write control to EEPROM memory (226)
    • Reading the contents of a memory location (226)
    • Writing to a memory cell (226)
  • Access to EEPROM from AVR-libc (228)
    • Declarations of data in the EEPROM memory (228)
    • Functions that provide access to EEPROM memory (230)
    • Other functions operating on the EEPROM (232)
  • Wear leveling techniques (233)
  • EEPROM and power failure (235)
  • The problem of atomicity when accessing EEPROM (241)
  • Writing to EEPROM using interrupts (241)

Chapter 13. Accessing FLASH memory (245)

  • Indicators using address spaces (248)
  • As it used to be ... (252)
  • Access to FLASH memory> 64 kB (253)
  • 24-bit types (254)

Chapter 14. Access to 16-bit IO registers (255)

  • Access to the 16-bit ADC register (255)
  • Access to 16-bit timer registers (256)

Chapter 15. We release, or when delays are necessary (259)

  • Delay at variable clock (263)
  • The use of timers to implement delays (265)

Chapter 16. Data files - how to add them to the project? (267)

  • Compilation of binary files (268)
  • Linking object files to a project (270)
  • Access to binary data (273)
    • Access to data using address spaces (275)

Chapter 17. Access to microcontroller's IO ports (277)

  • Pin configuration IO (278)
  • Manipulation with IO pins (282)
    • Changing the port state to the opposite (282)
    • Setting the IO line (283)
    • Resetting the IO line (283)
    • Macrodefinition _BV () (283)
    • Using bit fields (284)
  • Synchronizer (285)
  • Passing the register as a function parameter (286)
  • Practical examples (287)
    • Controlling a 7-segment display (287)
    • Connecting buttons (290)
    • Rotary encoder (294)
    • Matrix keyboard (299)

Chapter 18. General purpose registers (303)

  • Using other registers as a GPIOR (305)

Chapter 19. Breaks (307)

    • What are interruptions? (307)
    • Intrusion breaks (308)
    • Interrupt sources (309)
    • Interrupt Vectors (311)
  • Interrupt service (312)
    • Blank interrupt vectors (314)
    • Empty interrupts (314)
    • Sharing code through interrupts (315)
    • sei () / cli () (316)
    • Naked attribute and assembly interrupts (317)
    • Volatile modifier (319)
    • Data access atomicity (324)
    • Reentrant functions (327)
  • Practical examples (328)
    • Multiplexed display (329)
    • Multiplexed display with adjustable display brightness (333)
    • Button support (336)
    • Encoder support (339)
    • Matrix keyboard (340)

Chapter 20. Timers (343)

  • Clock signal (344)
    • Internal clock signal (344)
    • External clock signal (345)
  • Counter (346)
  • Comparing system (346)
    • Impact on IO pins (347)
  • External event capture module (348)
    • Noise elimination (349)
    • Comparator as an ICP event trigger (349)
  • Timer operation modes (349)
    • Simple mode (349)
    • CTC mode (352)
    • PWM modes (353)
    • Protective circuit (358)
    • Output signal modulator (359)
  • Frequency and filling meter (360)

Chapter 21. RTC - or a little about clocks (365)

    • Hardware implementation (366)
    • Program implementation (366)
  • Time by radio, or DCF77 (369)
    • A little more about DCF77 (369)
    • Data decoding (370)
    • Time conversion functions (372)
    • Receiver module DCF77 (372)

Chapter 22. Comparator (379)

  • Additional functions (380)
    • Blocking pins (380)
    • Triggering timer events (380)
    • Selection of the comparator input (380)
    • Triggering ADC Transducer (381)

Chapter 23. Analog-to-digital converter (383)

  • Selecting the reference voltage (384)
  • What does LSB mean? (385)
  • Calibration ADC (386)
  • Oversampling (387)
    • Averaging (388)
    • Decimation and interpolation (389)
  • How to increase the precision of measurements? (389)
  • Multiplexer (390)
  • Locking digital pins (391)
  • ADC Transducer (392)
    • Single conversion mode (393)
    • Continuous conversion mode (393)
  • Single and differential inputs (394)
  • Result (395)
  • Triggers (395)
  • ADC interrupts (396)
  • Precise measurements with ADC (397)
  • Examples (399)
    • Analog thermometer LM35 (399)
    • Keys (401)

Chapter 24. Operating alphanumeric LCD displays (407)

  • Support for alphanumeric displays (408)
    • Library functions (413)
    • Defining your own characters (418)
  • Transactional LCD support (420)
    • Example - menu (430)

Chapter 25. Monochrome graphic displays (439)

  • A visit to the museum, i.e. displays using KS0108 (441)
  • Modules using the ST7565R controller (450)
  • Structure and functions of the ST7565R controller (451)
  • Special functions of the controller (457)
    • Rotating the image (457)
    • Contrast adjustment (458)
    • The number of the first line displayed (459)
  • Fonts (460)
  • Small optimization (465)
  • Double buffering (467)
    • Image display start address (468)
  • Menu (469)
    • Menu based on pictograms (471)

Chapter 26. USART interface (477)

  • Serial interfaces (477)
  • USART interface (478)
  • Data transmission format (480)
  • USART interface of the AVR microcontroller (482)
    • Transmission speed (482)
    • Selection of quartz (484)
    • Data frame formats (484)
    • USART transmitter and receiver (485)
  • Data validation (486)
  • USART with Xplained Mini (487)
  • Terminal (487)
  • The use of interrupts (488)
  • Concurrent access to USART from many "threads" (493)
  • Access to USART using streams (495)
    • The get method (496)
    • Put method (496)
    • Opening the stream (497)
  • Microcontroller connection - microcontroller (498)
    • USART synchronous operation mode (499)
  • RS485 (504)
  • MPCM mode (506)
    • Computer as a master MPCM device (509)

Chapter 27. SPI interface (511)

  • Interface initialization (513)
    • Setting of IO pins (514)
    • Clock speed (516)
    • Processor in Master SPI mode (516)
    • Processor in SPI slave mode (516)
  • Examples (517)
    • Connection AVR - AVR (517)
    • AVR connection - serial register (522)
  • USART interface in SPI mode (526)
    • SPI bus clock (527)
    • SPI operating mode (528)
    • Data frame format (528)
    • Interface configuration (528)

Chapter 28. TWI interface (531)

  • Multimaster mode (534)
  • Interface initialization (535)
  • Microcontroller in I2C master mode (535)
    • START and STOP bits (535)
    • Basic functions for cooperation with I2C (536)
    • Cooperation with external EEPROM memory (539)
    • Cooperation with external FRAM memory (544)
    • Placing variables in the external EEPROM memory (545)
    • Cooperation with the RTC clock (547)
    • Support for the IO expander PCF8574 (551)
  • Processor in I2C slave mode (552)
    • Example (555)

Chapter 29. USI interface (563)

  • 4-bit counter and clock (563)
  • Interrupts of the USI (564)
  • Changing the position of pins (565)
  • Using the USI interface in SPI mode (566)
    • SPI master mode (566)
    • SPI slave mode (567)

Chapter 30. 1-wire interface (569)

  • Implementation of master 1-wire on AVR (572)
    • Implementation master 1-wire using IO pins (573)
    • Master 1-wire implementation using the UART interface (576)
    • High-level 1-wire support functions (581)
  • Digital Thermometer DS1820 (584)

Chapter 31. A lot of LEDs, a lot of fun (587)

  • LED dies (587)
    • PCB design and power supply (588)
    • Layout with a two-color matrix (590)
    • Matrix control (591)
  • WS2812B driver (593)
    • Power (595)
    • Bit banging (596)
    • Using SPI (597)

Chapter 32. TV remote controls (601)

  • Hardware part, or IR receiver (603)
  • Program part, or coding standards (604)
    • NEC and related standards (604)
  • RC5 (610)
    • Manchester Code (610)
    • RC5 decoder (611)
    • Other coding standards (615)

Chapter 33. Combining C and Assembler Code (617)

  • ABI (618)
  • Keyword asm (621)
    • Types of operands (623)
    • Access to IO ports (625)
    • Access to multi-byte data (626)
    • Access to indicators (627)
    • List of modified registers (627)
    • Multiple use of assembler insert (628)
  • .S files (629)
    • Definitions (630)
    • Definition of global symbols (630)
    • Assembly instructions (635)
    • Calling the C language function from the assembler (637)

Chapter 34. Bootloader (639)

  • NRWW and RWW memory (640)
  • Bootloader configuration bits (641)
    • Configuring locks from the application level (642)
  • FLASH programming (643)
  • The use of interrupts in the bootloader code (645)
    • Removing the interrupt vector table (645)
    • Shortening the interrupt vector array (647)
  • Bootloader boot (650)
    • Use of additional button / jumper (650)
    • The use of markers in the EEPROM memory (651)
    • Waiting for a special character in the selected communication channel (652)
    • Application start (652)
  • Sharing the application and bootloader code (653)
    • Calling the bootloader function in ATMega256x processors (655)
    • Calling the interrupt function contained in the bootloader code (658)
    • Sharing variables between the application and the bootloader (658)

Chapter 35. Debugging the program (661)

  • Debugger configuration (663)
  • Project configuration for debugging (664)
  • Hardware debugger (665)
  • Software debugger (simulator) (667)
    • Pacing file (668)
  • Traps (674)
    • Data traps (678)
    • Tracking points (679)
    • Conditional traps (681)
  • Memory preview (683)
  • Call stack overview (684)
  • Determining the simulation time (684)
  • Disassembler window (685)
  • Variable preview window (686)
    • Formatting chains (687)
  • ASSERT macrodefinition (688)
  • Interrupts during debugging (692)
  • _delay_xx and simulator (693)

Index (695)

295518

Other products in the same category (16)