ELE2303 WORKSHOP 2 – C on the PIC18, MPLABX AND XC8 Demo section How to setup PICSimLab on MPLABX, set up a project, compile and test on PICSimLab Problem section 1. Install the PICSimLab plugin in MPLABX Create your own project for a PIC18F4620 processor Set the TRISD register for PORTD as outputs Include a main program with an endless loop Declare a variable c and increment it each loop Store the value of c to LATD and test on the PICSimLab 2. Set the TRISB register for PORTB as inputs Set the TRISD register for PORTD as outputs Include a main program with an endless loop Read the value of PORTB into c and store it to LATD and test on the PICSimLab (Try testing the code above using the built-in simulator) 3. Set the TRISB register for PORTB as inputs Set the TRISD register for PORTD as outputs Include a main program with an endless loop Test PORTB bit 0 and if = 1 toggle the value in LATD and test on the PICSimLab Homework section Create a new project, for the PIC18F4620 processor. Select the PICSimLab Simulator (for debugging) Write and test a program on the PICSimLab simulator which:  Declares any variables you require  Initialises any variables required and the port directions as o portB bits 0 to 3 as inputs, 4 to 7 as outputs o portD as outputs, portA bits 2 to 5 as outputs (they enable displays)  enters an endless loop – each time around the loop  read the state of portB bits 0 to 3, write them to latchB bits 4 to 7  write a value to latchD to show the digit ‘5’ on the 7 segment displays o control latchA outputs to enable each display one at a time  clear the display