write a program that uses the on-board switches (pic32mm curiosity development board) to control
LED1 and LED2 as described below:
• Initially, both LEDs blink simultaneously, changing approximately every ½ second.
• Pressing S1 at any point should toggle whether the LEDs are blinking. Pressing
the switch the first time pauses blinking; pressing it again restarts blinking.
o When paused, one or both LEDs may be off, depending on the mode of
operation described below.
• Pressing S2 should change between four modes of operation, which are:
1. LEDs blinking simultaneously
2. LEDs alternating—when one is on, the other is off
3. Only LED1 blinking, with LED2 paused (either on or off)
4. Only LED2 blinking, with LED1 paused (either on or off)
Repeated presses of S2 should cycle between the modes in the order above (1,
2, 3, then 4). After leaving mode 4, the program should return to mode 1.
the code so for as follow:
#include
main:
sw zero, TRISA ## TRISA = 0 --> all PORTA bits = output
sw zero, ANSELA ## ANSELA = 0 --> all PORTA bits digital
sw zero, TRISC ## TRISC = 0 --> all PORTC bits = output
sw zero, ANSELC ## ANSELC = 0 --> all PORTC bits digital
li t0, _PORTA_RA0_MASK ## t0 = 0x00000001 --> control LED1
li t2, _PORTC_RC9_MASK ## t1 = 0x00000200 --> control LED2
li t4, _PORTB_RB7_MASK ## t4 = 0x00000080 --> saved state of S1
li t6, _PORTB_RB13_MASK ## t6 = 0x00002000 --> saved state of S2
sw t0, LATASET
sw t2, LATCSET
toggle:
li t1, 0x003FFFFF ## Set delay counter
## Toggles LED about every 1.5 seconds
d1:
addi t1, t1, -1 ## Decrement counter
bne t1, zero, d1 ## and continue doing that until we hit 0
nop
sw t0, LATAINV
sw t2, LATCINV
j toggle ## Reset delay counter and start again
nop
Hi!
I am an Electronic engineer, microcontroller, C programming expert having past experiences with arduino, pic, AVR, chipkit and Texas instruments microcontrollers
I am waiting for you over the chat.
Thank you!