0% found this document useful (0 votes)
50 views17 pages

DEC40053 Embedded System Application

Uploaded by

Iskandar Yussof
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
50 views17 pages

DEC40053 Embedded System Application

Uploaded by

Iskandar Yussof
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
POUT SHnilx MALAYSIA' ELECTRICAL ENGINEERING DEPARTMENT ACADEMIC SESSION: DEC40053 - EMBEDDED SYSTEM APPLICATIONS PRACTICAL WORK 1: INTRODUCTION TO MPLABX AND CIRCUIT SIMULATION PRACTICAL WORK DATE : LECTURER’S NAME: GROUP NO. : TOTAL STUDENT ID & NAME : MARKS, (100%) a 8 @ () DATE SUBMIT : DATE RETURN : LEARNING OUTCOMES (LO) 1. Construct and sinmulate real-time embedded system application based on PICI6F/PICI8F microcontroller effectively OBJECTIVE 1. Write program in C language in MPLABX. 2. Draw and simulate PIC circuit in Proteus. 3. Build output hardware circuit using LEDs THEORY A) MPLAB MPLAB X Integrated Development Environment (IDE) is an expandable, highly configurable software program that incorporates powerful tools to help you discover, configure, develop, debug and qualify embedded designs for most of Microchip’s microcontrollers and digital signal controllers. MPLAB X IDE works seamlessly with the MPLAB development ecosystem of software and tools, many of which are completely free B) PROTEUS Proteus is a design software developed by Labcenter Electronics for electronic circuit simulation, schematic capture and PCB design. Its simplicity and user friendly design made it popular among electronics hobbyists. Proteus is commonly used for digital simulations such as microcontrollers and microprocessors. It can simulate LED, LDR, USB Communication and many more. EQUIPMENT / TOOLS 1. Personal Computer (PC) 2. MPLAB IDE software 3. Proteus software PROCEDURE At desktop, create a folder named P1. In the P1 folder, create subfolder as below. 4 (> et a Quick access Box Sync I Desktop Documents } Downloads circurt REFERENCE see Open MPLAB X. Click File>New Project or New Project icon. File Edit View Navigate Source Refactor Production F) New File. CteleN GF openroject.. Cte shiteo Open Recent Projac Import > Ea File Edit View Navigate Source Refactor Production AGgS Se ‘Step I>Choose Project. Select Microchip Embedded option in Categories and Standalone Project in Projects. Click Next (Brent Pex omit eget 1B vee naan moet, 1B treyromt Bingen res rect 1B inert tte aco rom [cestes nen score scat conc. Russ DE greeted bila Step 2>Select device. Select All Families in Family option. In device option, select suitable PICISE microcontroller (PIC18F45K22). Click Next. i 2] ES ey [ea] [ee New>main.c Ears File Edit View Navigate Source Refactor Production Debug Team Tools Window Help BES OG be AT -B > EE wee = ult Projects x) Files | Classes Gi|{ StatPave New Logical Folder B csource File. 4 Ad xing Rem Gimme Add Existing Items from Folders... Bl xc header. Find. B owmaine i 3.11 | At file name, type LED. In extension, option c is default selection. Ignore other option, ‘casted C/UsevES AiG DedioePIPWLUED.C ea] SS Ce] oe) Bz | A file named LED will appear below Source Files. (Projects x] Files | Classes o@ pm 313 ‘A window named LED. will appear as below. This is where you will write your source code. Seaeoe = 53.22 Oise eee [asm enter an 4 [See alasrsiveciadeuaae ! ue 1 ' ' ' ' ML , Check seiting for your compiler. Click Project Properties at dashboard or click File>Project Properties>XC8 Global option. At C Standard, select C90. [BB new Pj. conesniten a as ape nm 1 ae a= sp mt nn Fea = . fess a BU YF Settnge ne rereaeencon cm Pees Sear 1 8 Sise sonore hoe Pees a omme = a ; =e Grea tirapat nner re sess Pej Prparie PW) sects 3.15 | Copy and paste program given in Appendix A into your coding window. Modify the void main (void) block with the source code below. void main (void) { setup(); Ising t ddr >1 TRISBbits.TRISBO while (1) Loox ver { LATBbits . LATBO=. } } File Edit View Navigate Source Refactor Production Debug Team Tools Window Help ASS |} © (co iinaainrget BH Clean and Build Main Project. Shift+F11 Batch Build Main Project... Set Project Configuration > Set Main Project > ‘Set Configuration Bits Check File AlteF9 Validate File Alte Shift+F9 ado Repeat Build/Run Cte FIT Stop Build/Run Tao tn Hop i ee [Build Main Project FT) |p {If your program has no error, you will get BUILD SUCCESSFUL statement in output window as below. If your program has error, you will get BUILD FAILED statement. Double click the error message and fix your program, 1D simulator = Trace/Proting PW (ul ond) = [BUILD SUCCESSFUL (eotal time: 122) Loading code trom ¢:/Users/E5-4715/Deskep/D1/PUL.X/dist/detasic/prodsction/FWL.x. production hex. 8.18 | Double click Proteus 8 Professional icon, Then click ISIS icon as Figure 18. SD: as EE a (o¢a9 deb ae hea * PROTEUS DESIGN SUITE 8.0 5.19 Untitled Proteus 8 Professional-Schematic Capture work area will appear as below. Select button P or Pick parts from libraries icon. 3 LWTTED rie 8 Peon Shana Cp ay Tie Cat Wow Too! Dagh Gaph eh Uy Tenlae Spon tip : | O6B9 Gmmasmo= (0 BR\++4909 Oe KOS Semm ae { HonePage (El Schematic Captre x m Benet e 10. | Pick Device window will appear. This is where you can select your components for simulation. You can type the components name in Keywords box or you can select in Category option, Double click your left mouse to select components below: © Microprocessor ICs > PICISF Family > PICI8F45K22 * Resistors > 0.6W Metal film > MINRES330R © Optoelectronics > LEDs > LED-RED » >) + e a (@@_cevces LED-RED MINRES2208 [aBESZ oe + ‘When all components are selected, click Cancel button to go back to ISIS window. Save this circuit as LAB. PICTEFIORDD U1 RAOIC12INO/ANO RAWICI2INIIANI RAZIC2INW/AN2;DACOUTVREF- RAQICIINWANSVREF+ RAAICIOUTISRTOGK! RASIC2OUTISRNQ'SST/HLVDINANS RABICLKOIOSC2 RATICLKUIOSC1 RBOIINTOFFLTO'SRVANI2 RBY/INTUCI2INS/ANTO RBZIINT2/CTEDI/ANS. RB3ICTEDUP2A/CCP2ICI2IN2/ANO RBAIOCOTSGIANTT RBSIOCTPSAICCP3TSCKUTIGIANTS RBBIOCAPGC RB7/IOCSPGD 2/9) we aa t He 2)? Seam on DEFAULT 2. iter & fjSyt [por Oo ' as ~D Terminals Mode @ wrt 4 i ' Construct circuit shown in Figure 23. To set power and ground source, select Terminal Mode > Power and Ground. Click Instruments icon and select DC Voltmeter. ROUP2BITSCKUT3GITICKUSOSCO RC1/P2AICCP2/SOSCI ROZICTPLSIP1AICCPITSCKLAN'4 RCSISCKSCLIANIS RCAISDIVISOAWAN1S, ROSISDOWANI7 ROBTXY/CKVANTS RCTIRXUDTHVANI9 RDOISCK2/SCL2/AN20 RDIVCCP4/SDI2/SDAZIAN21 RD2P2BIAN22 ROBPZGSSIANZS RDAIP2D/SDO2/AN24 ROSP1BIAN25 RDGIP1C/TX2ICKZIANZS RD7IPID/RX2DT2IANQT REOPSAICCPSIANS REWP3BIANG REZICOPSIANT NCTRVPPIRES INSTRUMENTS OSCILLOSCOPE LOGIC ANALYSER COUNTER TIMER VIRTUAL TERMINAL SPI DEBUGGER. 2c DEBUGGER SIGNAL GENERATOR PATTERN GENERATO| DC AMMETER, AC VOLTMETER JAC AMMETER, To save your circuit, select File > Save Project As. Go to Desktop » Pl Folder > CIRCUIT sub folder. Double click your PICISF45K22. Edit component window will appear as below. At Processor Clock Frequency, set 64MEIZ. Past Reference: ut Hiddere [] OK ] Pat abe CuaFaska2 Hide: C1 | ap Element: New Daa ce Package: ila Hider) | | Hidden Pie ProgenFie, LG Heat S| Fete eaMH2 Hide aly 1) Processor Clock Frequency a ‘Advanced Properties: Force ADC Breakpoint At Sample Time? | (Defaut) ©) Hide Aly Other Properties: (Exclude from Simulation DAtach hierarchy module (DE molude from PCB Layout Hide common pins (CE welude from Bil of Materials COE Git al properties as text Load the hex file into Proteus. In MPLAB X, at the output window, copy the statement below and paste in program file in Proteus. Outut = WD Simatator = Trace/Profing = PW (Build, toad) x sore svoceser (Ie TAZ, y Lansing code 2=] €:/Usera/$5-4710/Deakop/PI/PAl_X/dtat/detasle/production/PH1 X production hed I a Hier: C) [riers die New iLan S| [Rite S TE Aisonie5 471670 eshion? [Hide A v Processor Clock Fiequeney aie Vie To run your circuit, click Debug > Run Simulation or click the Run Simulation button at the bottom left of your ISIS window. To stop simulation, click Stop The Simulation button, [Beit] Ubon Template system Help ID) stort si Debuaging caer Run Simulation (timed breakpoint) ‘Write new programming to do task below. Right click Source File>New>main.c. In File Name option, type LED2. Stage tame and cation 3 Romeand ton Femeet [ese rom: Pit ee | Pere ened le: Uses ies PAP HLL Remove LED.c code from Source Files. Right click LED.c name below Source Files=Remove From Project. Popa rie dees = ce te concn Compt te event a" , wo 5 SE pepe: pause ‘Make sure only LED2.¢ code remain below Source Files. [Projects =| Files | Classes G pw. © GD) Header ries @-(G Important Fes @( Unker Fes GB} Source Fes Sma (i Ubraries (HP Loodables 5.26 | Write the source code below for LED2.< program, void main (void) { setup()7 ir program idx k t Por v } Build your LED2.¢ code 527 ‘Draw cireuit for LED2.c program and simulate them in Proteus. 6 [Task Build C program to perform task below. Design its circuit in Proteus. State your observations. a) Make Port D produce SV. Use bit addressable instructions. b) Make pin RB7, RBS, RB3 and RBI ON and other Port B pins OFF. Use byte addressable instruction, ©) Make REO, RAI, RB2, RC3 and RD4 HIGH, 7 | RESULT 8 | DISCUSSION 9 | CONCLUSION Appendix A include #define_XTAL_FREQ 640000001 void setup(void); void delay(unsigned int x); void main (void) semup(); ‘Your program start here /Your program end here BAHAGIAN INI JANGAN KACAU :) void setup(void) ANSELA = 0000000000; 200000000, 100000000: ‘ob00000000: ANSELE = 0600000000; VREFCONO = 0610110000; // Fixed Voltage Reference is enabled, x4 (4.096V) ADCONI = 0600110000; (0001 10000=4.096V 0b00100000=2,048V 0'00000000=Vadd ADCON? = 0610000011. 1x00; 1x00; 1x00; LATD = 0x00; LATE = 0x00, void delay(unsigned int x) for(:x>0; |_delay_ms(1) static void interrupt ISR(void)

You might also like