Programming Embedded Systems Hands on Experience with AVR
Programming Embedded Systems Hands on Experience with AVR 32 By: Stefan Persson stefan. persson@miun. se amir. yousaf@miun. se Mazhar Hussain Muhammad Amir Yousaf mazhar. hussain @miun. se amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 1
Tutorial Overview q Introduction to Development Board ü ü µ-Controller Sensors Display Peripherals q AVR Studio Getting Started ü Workspace creation ü Project building ü Target creation and Loading Program q Course Objective q Live Demonstration amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 2
Introduction to Development Board µ-Controller Sensors Display Peripherals q EVK 1100 ü Evaluation kit and development system for the AVR 32 UC 3 A family ü EVK 1100 is a fully functional embedded computer system. ü Circuit board has a flexible power system that accepts 8 -20 V DC input and can be operable via USB port. ü The EVK 1100 embeds an Atmel Data flash (8 MBytes) and a SDRAM (32 MBytes). ü Several communication interfaces are available on the EVK 1100: RS 232, USB and ETHERNET. amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 3
µ-Controller Sensors Display Peripherals ü A JTAG connector is provided to interface JTAGICE mk. II (Programmer and debugger). ü EVK 1100 provides three clock inputs for controller § § § Main clock Oscillatior i. e 12 MHz A spare clock Oscillator i. e 12 MHz RTC clock at 32. 768 KHz Block Diagram EVK 1100 amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 4
µ-Controller Sensors Display Peripherals Published BY ATMEL amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 5
q Lowest power Consumption (2 x. AA battery=19 years) µ-Controller Sensors Display Peripherals q Support High data throughput. q High Speed Communication Interfaces – – – – USB up to 480 Mbit/s Ethernet up to 100 Mbit/s SPI up to 33 Mbit/s SSC up to 33 Mbit/s (I 2 S) USART up to 33 Mbit/s UART up to 4 Mbit/s I/O pin toggle up to 33 MHz amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 6
µ-Controller Sensors Display Peripherals • Support Provided : – Optimized drivers for all peripherals to speed up development. – Floating point and DSP arithmetic – USB and TCP/IP stacks – Optimized audio, picture and video codec's, display drivers, TCP/IP services, web server, FAT 12/16/32 file system, plus a complete free. RTOS Real Time OS amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 7
µ-Controller Sensors Display Peripherals Published BY ATMEL amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 8
µ-Controller Sensors Display Peripherals amir. yousaf@miun. se mazhar. hussain@miun. se Sensor Name GPIO Names Alt. Function Used Light PA 23 ADC 2 Temperature PA 21 ADC 0 Potentiometer PA 22 ADC 1 10/28/2020 9
q 4 x 20 LCD to Design Human to Machine Interface for Soft. Development amir. yousaf@miun. se mazhar. hussain@miun. se µ-Controller Sensors Display Peripherals LCD Pin GPIO Name Alt. Function 5 PA 16 SPI 1_MOSI 7 PA 17 SPI 1_MISO 6 PA 15 SPI 1_CLK 4 PA 19 SPI 1_CS 2 18 PA 18 PWM_6 10/28/2020 10
On Board Peripherals: ü USB (2. 0 mini A-B receptacle) ü Ethernet (External Ethernet Phy 10/100 and RJ 45 connector) ü Atmel Data. Flash (8 MBytes) ü SDRAM (32 MBytes) ü USARTs (Dual) ü LEDs on board (Six) ü Push Buttons (Three excluding Reset Push button) ü Joystick ü SD/MMC slot ü SPI (Two SPI interface one is dedicated for LCD one free) ü TWI (Two wire Interface) amir. yousaf@miun. se mazhar. hussain@miun. se µ-Controller Sensors Display Peripherals 10/28/2020 11
Expansion Connectors: >>SSC, PWM output 0 to 6, Timer A and timer B, TWI, ADC inputs line 0 to 7, SPI 0 to 1, USART 0 to 3, MAC, GPIO amir. yousaf@miun. se mazhar. hussain@miun. se µ-Controller Sensors Display Peripherals 10/28/2020 12
Tutorial Overview q Introduction to Development Board ü ü µ-Controller Sensors Display Peripherals q AVR Studio Getting Started ü Workspace creation ü Project building ü Target Creation and Loading Program q Course Objectives q Live Demonstration amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 13
AVR Studio Getting Started q Start -> Program -> Atmel AVR Tools -> AVR 32 Studio amir. yousaf@miun. se mazhar. hussain@miun. se Workspace creation Project building Target Creation & Loading program 10/28/2020 14
amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 15
q Running an Example Project – Workspace creation Project building Target Creation & Loading program Click File >> New >> Project >>AVR 32 Example Project • Running your own Project • Click File >> New >> Project >>AVR 32 C Project From Template amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 16
q Building a Project ü Select the project from the project plan (on left side of the window) and right click ü Click ‘Build Project’ Workspace creation Project building Target Creation & Loading program ü Build complete for project ’myproject’ ü ’Debug’ directory will be added in the workspace ü myproject. elf will be created in the Debug directory and is ready to be loaded in the controller amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 17
q For Programming EVK 1100 there are three listed methods available, (Note: we can use two among them) – In system Programming (ISP) – Programming Via JTAG port – Self Programming via One chip BOOT program Workspace creation Project building Target Creation & Loading program q Tool for using programming is JTAG or USB cable (for ISP) – JTAG ICE mk. II amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 18
q For Programming EVK 1100 we need to add a Target – Scan the target as shown in Picture amir. yousaf@miun. se mazhar. hussain@miun. se Workspace creation Project building Target Creation & Loading program 10/28/2020 19
q Configure the target device i. e JTAGICE mk. II for downloading your program amir. yousaf@miun. se mazhar. hussain@miun. se Workspace creation Project building Target Creation & Loading program 10/28/2020 20
q Loading Code in the Micro-controller ü Loading through USB DFU ü Loading through JTAG Workspace creation Project building Target Creation & Loading program On EVK 1100 Press the joystick downwards and hold it. Now press the re-start button to put the device in programming mode On AVR Studio ü Right-click on target for USB-programming and click program. ü Browse the target file and press ‘ok’ in newly appeared window to start loading the program amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 21
Workspace creation Project building Target Creation & Loading program q Loading Code in the Micro-controller ü Loading through JTAG ü Right click on JTAGICE mk. II and click on ‘Program’. ü Browse the target. elf file and press ok to start loading amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 22
Tutorial Overview q Introduction to Development Board ü ü µ-Controller Sensors Display Peripherals q AVR Studio Getting Started ü Workspace creation ü Project building ü Target creation and Loading Programs q Course Objective q Live Demonstration amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 23
Application q Our WSN Platform (Sentio) o Number of different platforms targeting different application areas ü SENTIO a stackable platform developed in 2004 (IEEE 802. 15. 4 SENTIO 32: compatible(Zigbee), having three layers i. e communication layer, processing layer (Atmel Mega 128 L 8 -bit u. C), and analog/digital interfaces to sensor layer. Sufficient for short range communication. üA latest platform that is very compact ü SENTIO-HP high-precision wireless instrument that can be used for with (IEEE 802. 15. 4 compatible (Zigbee)) characterizing processes and processor (AVR 32) on the same board. ü SENTIO-BT for urban sensing applications. ü SENTIO-e 2 for environmental monitoring, communicating at 433 MHz at ranges up to 1 km. Global communication via GSM/GPRS or to a PC via USB üIt is a Development Board, can be used for variety of wireless sensor applications amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 24
Tutorial Overview q Introduction to Development Board ü ü µ-Controller Sensors Display Peripherals q AVR Studio Getting Started ü Workspace creation ü Project creation ü Target creation ü Project building and Downloading q Course Objective q Live Demonstration amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 25
Demonstration amir. yousaf@miun. se mazhar. hussain@miun. se 10/28/2020 26
- Slides: 26