Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| learn:courses:microprocessor-io-lab-1a:start [2017/03/15 17:17] – [3.1. Hardware] Martha | learn:courses:microprocessor-io-lab-1a:start [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Lab 1a: Microprocessor IO ====== | ====== Lab 1a: Microprocessor IO ====== | ||
| + | [[{}/ | ||
| == Download This Document == | == Download This Document == | ||
| - | * {{ : | + | {{ : |
| Line 21: | Line 22: | ||
| ===== 3. Equipment List ===== | ===== 3. Equipment List ===== | ||
| ==== 3.1. Hardware ==== | ==== 3.1. Hardware ==== | ||
| - | | + | |
| - | | + | |
| - | | + | |
| In addition, we suggest the following instruments: | In addition, we suggest the following instruments: | ||
| - | | + | |
| ==== 3.2. Software: ==== | ==== 3.2. Software: ==== | ||
| The following programs must be installed on your development work station: | The following programs must be installed on your development work station: | ||
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| ---- | ---- | ||
| - | ===== 4. Takeaways ===== | + | ===== 4. Project |
| - Know how to generate a microprocessor development project using MPLAB X. | - Know how to generate a microprocessor development project using MPLAB X. | ||
| - Know how to configure the Microchip PIC32 processor pins as either digital inputs or outputs. | - Know how to configure the Microchip PIC32 processor pins as either digital inputs or outputs. | ||
| Line 45: | Line 46: | ||
| ===== 5. Fundamental Concepts ===== | ===== 5. Fundamental Concepts ===== | ||
| - | This lab focuses on control of PIC32MX370 | + | This lab focuses on control of PIC32MX370 |
| ---- | ---- | ||
| ===== 6. Problem Statement ===== | ===== 6. Problem Statement ===== | ||
| - | In this lab, you will be using specified switches to turn specified | + | In this lab, you will turn the RED, BLUE, and GREEN colors of the tri-color LED8 either on or off using SW0, SW1, and SW2, respectively. |
| ---- | ---- | ||
| Line 56: | Line 57: | ||
| ===== 7. Background Information ===== | ===== 7. Background Information ===== | ||
| ==== 7.1. Control Registers ==== | ==== 7.1. Control Registers ==== | ||
| - | In this lab, we will make use of the TRISx, LATx, and PORTx control registers. TRISx registers simply control the data direction flow through port I/O pins, e.g., whether a PORTx I/O pin is an input or an output. If the data direction bit is a “1”, then the corresponding PORTx I/O pin is an input, and vice versa. | + | In this lab, we will make use of the TRISx, LATx, and PORTx control registers. TRISx registers simply control the data direction flow through port I/O pins, e.g., whether a PORTx I/O pin is an input or an output. If the data direction bit is a “1,” then the corresponding PORTx I/O pin is an input, and vice versa. |
| - | LATx registers (PORTx data latch) hold data written to port I/O pins. A write to a LATx register latches data to the corresponding port I/O pins and those I/O port pins configured as outputs are updated. A read from a LATx resister reads the data held in the PORTx data latch, not directly from the port I/O pins (this distinction will come into play in [[https:// | + | LATx registers (PORTx data latch) hold data written to port I/O pins. A write to a LATx register latches data to the corresponding port I/O pins and those I/O port pins configured as outputs are updated. A read from a LATx resister reads the data held in the PORTx data latch, not directly from the port I/O pins (this distinction will come into play in [[/ |
| - | PORTx registers are the registers that allow I/O pins to be accessed. A write to a PORTx register writes to the corresponding LATx register (PORTx data latch) and those I/O port pins configured as outputs are updated. This is effectively the same as writing to a LATx register. A read from a PORTx register reads the synchronized signal applied to the post I/O pins. | + | PORTx registers are the registers that allow I/O pins to be accessed. A write to a PORTx register writes to the corresponding LATx register (PORTx data latch) and those I/O port pins configured as outputs are updated. This is effectively the same as writing to a LATx register. A read from a PORTx register reads the synchronized signal applied to the port I/O pins. |
| ==== 7.2. Configuring the PIC32 for Digital Inputs ==== | ==== 7.2. Configuring the PIC32 for Digital Inputs ==== | ||
| - | As noted from Appendix E, Table E.1 in the Unit 1 description, | + | As noted from Appendix E Table E.1 in the Unit 1 description, |
| ---- | ---- | ||
| - | ==== Listing 7.1. Instructions for Setting Analog Inputs to be Digital Inputs | + | ==== Listing 7.1. Instructions for Setting Analog Inputs to be Digital Inputs |
| < | < | ||
| TRISBbits.TRISB9 | TRISBbits.TRISB9 | ||
| Line 79: | Line 80: | ||
| ---- | ---- | ||
| - | If multiple | + | If multiple |
| ---- | ---- | ||
| Line 91: | Line 92: | ||
| ---- | ---- | ||
| - | Note: If the instruction | + | Note: If the instruction TRISB = 0b0000111000000000; |
| - | If the peripheral library function is used, the statement | + | If the peripheral library function is used, the statement PORTSetPinsDigitalIn(IOPORT_B, |
| - | Other PIC IO pins that serve solely as digital inputs require only the instruction to set the appropriate TRIS bit. For example, to program the PIC32 to an input for SW0, initialize using the statement | + | Other PIC I/O pins that serve solely as digital inputs require only the instruction to set the appropriate TRIS bit. For example, to program the PIC32 to an input for SW0, initialize using the statement TRISFbits.TRISF3 = 1;. |
| - | Figure A.1 shows that seven of the switches (SW0 through SW6) are isolated from the PIC32 processor | + | Figure A.1 shows that seven of the switches (SW0 through SW6) are isolated from the PIC32 processor |
| + | |||
| ==== 7.3. Configuring the PIC32 for Digital Outputs ==== | ==== 7.3. Configuring the PIC32 for Digital Outputs ==== | ||
| - | Figure A.2 shows the portion of the Basys MX3 schematic for connection to the tri-color LED. The corresponding PIC32 pins connected to the tri-color LED must be configured as outputs. If output pins are analog capable, they must be set for digital mode operation as described above. | + | Figure A.2 shows the portion of the Basys MX3 schematic for connection to the tri-color LED. The corresponding PIC32 pins connected to the tri-color LED must be configured as outputs. If output pins are analog capable, they must be set for digital mode operation as described above. |
| ---- | ---- | ||
| Line 106: | Line 108: | ||
| ===== 8. Lab 1a ===== | ===== 8. Lab 1a ===== | ||
| ==== 8.1. Requirements ==== | ==== 8.1. Requirements ==== | ||
| - | This exercise uses the Basys MX3 switches SW0 through SW2 to control the red, blue, and green LEDs on the tri-colored LED labeled LED8 according to the following rules (referring | + | This exercise uses the Basys MX3 switches SW0 through SW2 to control the red, blue, and green LEDs on the tri-colored LED labeled LED8 according to the following rules (refer to the schematic diagrams in Appendix A of this lab for additional details): |
| - SW0 is to turn the RED color of LED8 on or off. | - SW0 is to turn the RED color of LED8 on or off. | ||
| - SW1 is to turn the BLUE color of LED8 on or off. | - SW1 is to turn the BLUE color of LED8 on or off. | ||
| - SW2 is to turn the GREEN color of LED8 on or off. | - SW2 is to turn the GREEN color of LED8 on or off. | ||
| - All switch combinations are allowable. | - All switch combinations are allowable. | ||
| + | |||
| ==== 8.2. Design Phase ==== | ==== 8.2. Design Phase ==== | ||
| Line 166: | Line 169: | ||
| ====== Appendix A: Schematic Drawings ====== | ====== Appendix A: Schematic Drawings ====== | ||
| - | {{ : | + | {{ : |
| //Figure A.1. Slide switch schematic diagram.// | //Figure A.1. Slide switch schematic diagram.// | ||
| - | {{ : | + | {{ : |
| //Figure A.2. Schematic of PIC32 interconnection with the Tri-color LED.// | //Figure A.2. Schematic of PIC32 interconnection with the Tri-color LED.// | ||
| - | {{ : | + | {{ : |
| //Figure A.3. Basys MX3 LEDs.// | //Figure A.3. Basys MX3 LEDs.// | ||
| Line 190: | Line 193: | ||
| - The run section must contain an infinite software loop that, under no condition, must ever end. Typically this infinite loop is written as for(;;){ … } or while(1){ …}. The embedded application executes from the infinite loop or from interrupts that preempt this loop. | - The run section must contain an infinite software loop that, under no condition, must ever end. Typically this infinite loop is written as for(;;){ … } or while(1){ …}. The embedded application executes from the infinite loop or from interrupts that preempt this loop. | ||
| + | ---- | ||
| + | |||
| + | [[{}/ | ||
| + | [[{}/ | ||

