Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify your program so that it performs the following: 1. set up port F so that

ID: 3591820 • Letter: M

Question

Modify your program so that it performs the following:
1. set up port F so that RF00 and RF01 are outputs and all the other pins on port F are inputs.
2. enable the weak pull up resistor for RE00.
3. turn on LD4 and turn o LD5.
4. wait until the button is pressed.
5. wait until the button is relased.
6. call the delay subroutine. Note this changes $t9.
7. toggle the state of LD4. (In other words, if LD4 is on, then turn it o ; if LD4 is o , then turn it on.)
8. go back to step 4.

Note: you might need some of the information in Appendix A, extracted from the PIC32 Family Reference Manual (TRISx, PORTx & LATx). Also, you might need to recall that you can use the la pseudo-instruction to load the address from a label into a register, and the li pseudo-instruction to load a constant into a register. For example:
la $t0, TRISA
li $t1, 0x1234FFFF

Explanation / Answer

P1SEL &= ~BIT2;   // i/o function selected, 0

P1DIR &= ~BIT2;   // input mode (P1.2), 0

P1OUT |= BIT2;    // select pull-up mode

P1REN |= BIT2; // enable internal pull up, 1

Now, when you have a look at the users manual (http://focus.ti.com/lit/ug/slau144e/slau144e.pdf) - chapter 8 - you will find the details:

PxSEL --> configure the function of the I/O

PxDIR --> selects INPUT or OUTPUT mode

PxOUT --> If the pin’s pullup/down resistor is enabled, the corresponding bit in the PxOUT register selects pull-up or pull-down.
Bit = 0: The pin is pulled down
Bit = 1: The pin is pulled up

PxREN --> Each bit in each PxREN register enables or disables the pullup/pulldown resistor of the corresponding I/O pin. The corresponding bit in the PxOUT register selects if the pin is pulled up or pulled down.
Bit = 0: Pullup/pulldown resistor disabled
Bit = 1: Pullup/pulldown resistor enabled

Now, have a look at the MSP430 device data sheet (MSP430F2274 in my example, http://focus.ti.com/lit/ds/symlink/msp430f2274.pdf, page 57): P1.2/TA1 --> I/O selcted = P1.2 (P1SEL.BIT2 = 0), P1.2 is in input mode (P1DIR.BIT2 = 0), Pull-Ups were disabled (P1OUT.BIT2 and P1REN.BIT2 = 0).

Rgds
aBUGSworstnightmare

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote