Example: bachelor of science

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS …

THE AVR MICROCONTROLLERAND EMBEDDED SYSTEMSU sing Assembly and COnline PartMuhammad Ali MazidiSepehr NaimiSarmad NaimiMazidi & NaimiThe AVR MICROCONTROLLER & EMBEDDED SYSTEMS (Mazidi & Naimi) 629 Copyright 2011-2017 Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr NaimiThe book was previously published by: Pearson Education, contact authors, use the following email our website at 8: AVR HARDWARE CONNECTION, HEX FILE, AND FLASH LOADERS SECTION : AVR FUSE BITS631 SECTION : EXPLAINING THE HEX FILE FOR AVR637 SECTION : AVR PROGRAMMING AND TRAINER BOARD642 CHAPTER 18: I2C PROTOCOL AND DS1307 RTC INTERFACINGSECTION : TWI PROGRAMMING WITH CHECKING STATUS REGISTER 647 APPENDIX A: AVR INSTRUCTIONS EXPLAINED 671 SECTION : INSTRUCTION SUMMARY672 SECTION : AVR INSTRUCTIONS FORMAT676 SECTION : AVR REGISTER SUMMARY708 APPENDIX B: BASICS

631 The AVR Microcontroller & Embedded Systems (Mazidi & Naimi) Table 8-6: Fuse Byte (High) Fuse High Bit Description Default Value Byte No. OCDEN 7 Enable OCD 1 (unprogrammed) JTAGEN 6 Enable JTAG 0 (programmed) SPIEN 5 Enable SPI serial program and 0 …

Tags:

  System, Embedded, Microcontrollers, The avr microcontroller and embedded systems

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS …

1 THE AVR MICROCONTROLLERAND EMBEDDED SYSTEMSU sing Assembly and COnline PartMuhammad Ali MazidiSepehr NaimiSarmad NaimiMazidi & NaimiThe AVR MICROCONTROLLER & EMBEDDED SYSTEMS (Mazidi & Naimi) 629 Copyright 2011-2017 Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr NaimiThe book was previously published by: Pearson Education, contact authors, use the following email our website at 8: AVR HARDWARE CONNECTION, HEX FILE, AND FLASH LOADERS SECTION : AVR FUSE BITS631 SECTION : EXPLAINING THE HEX FILE FOR AVR637 SECTION : AVR PROGRAMMING AND TRAINER BOARD642 CHAPTER 18: I2C PROTOCOL AND DS1307 RTC INTERFACINGSECTION : TWI PROGRAMMING WITH CHECKING STATUS REGISTER 647 APPENDIX A: AVR INSTRUCTIONS EXPLAINED 671 SECTION : INSTRUCTION SUMMARY672 SECTION : AVR INSTRUCTIONS FORMAT676 SECTION : AVR REGISTER SUMMARY708 APPENDIX B: BASICS OF WIRE WRAPPING 709 APPENDIX C: IC INTERFACING AND system DESIGN ISSUES 713 SECTION : OVERVIEW OF IC TECHNOLOGY714 SECTION : AVR I/O PORT STRUCTURE AND INTERFACING720 SECTION : system DESIGN ISSUES726 APPENDIX D: FLOWCHARTS AND PSEUDOCODE 731 APPENDIX E.

2 AVR PRIMER FOR 8051 PROGRAMMERS 737 APPENDIX F: ASCII CODES 738 APPENDIX G: ASSEMBLERS, DEVELOPMENT RESOURCES, AND SUPPLIERS 740 APPENDIX H: DATA SHEETS 742 The AVR MICROCONTROLLER & EMBEDDED SYSTEMS (Mazidi & Naimi)630 SECTION : AVR FUSE BITST here are some features of the AVR that we can choose by programmingthe bits of fuse bytes. These features will reduce system cost by eliminating anyneed for external has two fuse bytes. Tables 8-6 and 8-7 give a short descriptionof the fuse bytes. Notice that the default values can be different from productionto production and time to time. In this section we examine some of the basic fusebits.

3 The Atmel website ( ) provides the complete descriptionof fuse bits for the AVR microcontrollers . It must be noted that if a fuse bit is incor-rectly programmed, it can cause the system to fail. An example of this is changingthe SPIEN bit to 1, which disables SPI programming mode. In this case you willnot be able to program the chip any more! Also notice that the fuse bits are 0 ifthey are programmed and 1 when they are not addition to the fuse bytes in the AVR, there are 4 lock bits to restrictaccess to the Flash memory. These allow you to protect your code from beingcopied by others.

4 In the development process it is not recommended to programlock bits because you may decide to read or verify the contents of Flash bits are set when the final product is ready to be delivered to market. In thisbook we do not discuss lock bits. To study more about lock bits you can read thedata sheets for your chip at AVR MICROCONTROLLER & EMBEDDED SYSTEMS (Mazidi & Naimi) 631 Table 8-6: Fuse Byte (High)Fuse High Bit DescriptionDefault OCD1 (unprogrammed)JTAGEN6 Enable JTAG0 (programmed)SPIEN5 Enable SPI serial program and0 (programmed)data downloadingCKOPT4 Oscillator options1 (unprogrammed)EESAVE3 EEPROM memory is preserved1 (unprogrammed)through the chip eraseBOOTSZ1 2 Select boot size0 (programmed)BOOTSZ0 1 Select boot size0 (programmed)BOOTRST 0 Select reset vector1 (unprogrammed)Table 8-7.

5 Fuse Byte (Low)Fuse High Bit DescriptionDefault 7 Brown-out detector trigger level 1 (unprogrammed)BODEN6 Brown-out detector enable1 (unprogrammed)SUT15 Select start-up time1 (unprogrammed)SUT04 Select start-up time0 (programmed)CKSEL33 Select clock source0 (programmed)CKSEL22 Select clock source0 (programmed)CKSEL11 Select clock source0 (programmed)CKSEL00 Select clock source1 (unprogrammed)Fuse bits and oscillator clocksourceAs you see in Figure 8-4, there aredifferent clock sources in AVR. You canchoose one by setting or clearing any of thebits CKSEL0 to CKSEL3 The four bits of CKSEL3, CKSEL2,CKSEL1, and CKSEL0 are used to select theclock source to the CPU.

6 The default choiceis internal RC (0001), which uses the on-chipRC oscillator. In this option there is no needto connect an external crystal and capacitorsto the chip. As you see in Table 8-8, bychanging the values of CKSEL0 CKSEL3we can choose among 1, 2, 4, or 8 MHz inter-nal RC frequencies; but it must be noted thatusing an internal RC oscillator can causeabout 3% inaccuracy and is not recommend-ed in applications that need precise timing. The external RC oscillator is anothersource to the CPU. As you see in Figure 8-5, touse the external RC oscillator, you have to con-nect an external resistor and capacitors to theXTAL1 values of R and C determinethe clock speed.

7 The frequency of the RCoscillator circuit is estimated by the equationf = 1/(3RC). When you need a variable clocksource you can use the external RC and replace the resistor with a turning the potentiometer you will be able to change the frequency. Notice thatthe capacitor value should be at least 22 pF. Also, notice that by programming theCKOPT fuse, you can enable an internal 36 pF capacitor between XTAL1 andGND, and remove the external capacitor. As you see in Table 8-9, by changing thevalues of CKSEL0 CKSEL3, we can choose different frequency 8: AVR HARDWARE CONNECTION632 Table 8-8: Internal RC Oscillator Operation Modes Frequency00011 MHz00102 MHz00114 MHz01008 MHzTable 8-9: External RC Oscillator Operation Modes Frequency (MHz)0101< External RC OscillatorExternalClockCrystalOscillator Low-FrequencyCrystal OscillatorCalibrated RC OscillatorClockMultiplexerFigure 8-4.

8 ATmega32 Clock SourcesFigure 8-5 External RCBy setting bits to 0000, we can use an external clock sourcefor the CPU. In Figure 8-6a you see the connection to an external clock most widely used option is to connect the XTAL1 and XTAL2 pins toa crystal (or ceramic) oscillator, as shown in Figure 8-6b. In this mode, whenCKOPT is programmed, the oscillator output will oscillate with a full rail-to-railswing on the output, causing a more powerful clock signal. This is suitable whenthe chip drives a second clock buffer or operates in a very noisy environment. Asyou see in Table 8-10, this mode has a wide frequency range.

9 When CKOPT is notprogrammed, the oscillator has a smaller output swing and a limited frequencyrange. This mode cannot be used to drive other clock buffers, but it does reducepower consumption considerably. There are four choices for the crystal oscillatoroption. Table 8-10 shows all of these choices. Notice that mode 101 cannot beused with crystals, and only ceramic resonators can be used. Example 8-1 showsthe relation between crystal frequency and instruction cycle AVR MICROCONTROLLER & EMBEDDED SYSTEMS (Mazidi & Naimi) 633 XTAL2 XTAL1 GNDNCEXTERNALOSCILLATORSIGNALF igure 8-6a.

10 XTAL1 Connection to anExternal Clock SourceXTAL2 XTAL1 GNDC2C1 Figure 8-6b. XTAL1 XTAL2 Connection to Crystal Oscillator22 pF22 pFTable 8-10: ATmega32 Crystal Oscillator Frequency Choices and Frequency (MHz) C1 and C2 (pF) for crystals 220101, 110, 111 More than 22 Find the instruction cycle time for the ATmega32 chip with the following crystal oscillatorsconnected to the XTAL1 and XTAL2 pins. (a) 4 MHz (b) 8 MHz (c) 10 MHz Solution:(a) Instruction cycle time is 1/(4 MHz) = 250 ns(b) Instruction cycle time is 1/(8 MHz) = 125 ns(c) Instruction cycle time is 1/(10 MHz) = 100 nsExample 8-1 Fuse bits and reset delayThe most difficult time for a system is during power-up.


Related search queries