Question: Example Code: #include xc . h / / CW 1 : FLASH CONFIGURATION WORD 1 #pragma config ICS = PGx 1 #pragma config

Example Code:
#include "xc.h"
// CW1: FLASH CONFIGURATION WORD 1
#pragma config ICS = PGx1
#pragma config FWDTEN = OFF
#pragma config GWRP = OFF
#pragma config GCP = OFF
#pragma config JTAGEN = OFF
// CW2: FLASH CONFIGURATION WORD 2
#pragma config I2C1SEL = PRI
#pragma config IOL1WAY = OFF
#pragma config OSCIOFNC = ON
#pragma config FCKSM = CSECME
#pragma config FNOSC = FRCPLL
void setup(void)
{
AD1PCFG =0x9fff; //sets all pins to digital I/O
TRISA =0b0000000000011111; //set port A to inputs,
TRISB =0b0000000000000011; //and port B to outputs
LATA =0xffff; //Set all of port A to HIGH
LATB =0xffff; //and all of port B to HIGH
CLKDIVbits.RCDIV =0; //Set RCDIV=1:1(default 2:1)32MHz or FCY/2=16M
}
void delay(void){
int curCount =0;
while(curCount 40000)
{
curCount++;
}
}
int main(void){
setup();
LATB =0x7FFF; //This will turn on the most significant LED
while(1){
// Execute repeatedly forever and ever and ever and ever ...
delay(); //This pauses execution so the shifts are visible
LATB = LATB >>1; //This shifts the LATB register
LATB |=0x8000;
}
return 0;
}
however, the example code only outputs RB14-12 on the circuit, not RB15. Modify the example code to implement a bouncing LED. Use shifting (both >> and ) and masking operations to illuminate the LEDs in this pattern: RB15->RB14->RB13->RB12->RB13->RB14->RB15... This pattern should repeat indefinitely. Please help me figure out this code. I am having a hard time getting this code to shift and light up the LEDs invidually like the pattern. I would really appreciate it! PS. I have also attached a image of what the circuit would look like
Example Code: #include " xc . h " / / CW 1 :

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!