Question: #include / * * * * * * * * * * * * * * * * * * * * * * *

#include
/**************************************************************
** Author: Ronald Kikoyo
*
* Program Title: Course Project
*
*
* Microprocessor B
*
*Spring
*
*
***************************************************************/
void delay_50ms(void)
{
const int D50ms =1150; // Declare a Constant for 50 ms Delay
int i;
for (i =0; i < D50ms; i++);
return;
}
// PIC24HJ32GP202 Configuration Bit Settings
// FBS
#pragma config BWRP = WRPROTECT_OFF // Boot Segment Write Protect (Boot Segment may be written)
#pragma config BSS = NO_FLASH // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
// FGS
#pragma config GWRP = OFF // General Code Segment Write Protect (User program memory is not write-protected)
#pragma config GSS = OFF // General Segment Code Protection (User program memory is not code-protected)
// FOSCSEL
#pragma config FNOSC = FRC // Oscillator Mode (Internal Fast RC (FRC))
#pragma config IESO = OFF // Internal External Switch Over Mode (Start-up device with user-selected oscillator source)
// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Source (Primary Oscillator Disabled)
#pragma config OSCIOFNC = ON // OSC2 Pin Function (OSC2 pin has digital I/O function)
#pragma config IOL1WAY = OFF // Peripheral Pin Select Configuration (Allow Multiple Re-configurations)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor (Both Clock Switching and Fail-Safe Clock Monitor are disabled)
// FWDT
#pragma config WDTPOST = PS512// Watchdog Timer Postscaler (1:512)
#pragma config WDTPRE = PR128// WDT Prescaler (1:128)
#pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software)
// FPOR
#pragma config FPWRT = PWR16// POR Timer Value (16ms)
#pragma config ALTI2C = OFF // Alternate I2C pins (I2C mapped to SDA1/SCL1 pins)
// FICD
#pragma config ICS = PGD1// Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is Disabled)
/************** END --- Configuration Word *********************/
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#define _XTAL_FREQ 20000000//Specify the XTAL crystall FREQ
/*******Sequence blink*******/
sblink(int get)//Function definition with "get" as parameter
{
for (int i=0; i<=15 && _RB0==0; i++)
{
PORTB = get << i; //LED move Left Sequence
delay_50ms();
}
for (int i=7; i>=0 && _RB0==0; i--)
{
PORTB = get << i; //LED move Left Sequence
delay_50ms();
}
}
/*******MAIN Function*******/
void main()//The main function
{
_TRISB0=1; //Instruct the MCU that the PORTB pin 0 is used as input for button.
TRISB =0x00; //Instruct the MCU that all pins are output
LATB=0x00; //Initialize all pins to 0
_RBPU=0b00000000;//Enable pull up R on port B
while(1)//Get into the Infinite While loop
{
if (_RB13==0)
{
sblink(2); //FUNCTION CALL 1 with parameter 1
sblink(14); //FUNCTION CALL 3 with parameter 3
sblink(13); //FUNCTION CALL 7 with parameter 7
sblink(12); //FUNCTION CALL 4 with parameter 15
while(_RB13==0)//If button is still pressed
{
LATB=0xFFF; //Turn ON all LEDs
}
}
}
}
what i am missing ,i am using a pic24HJ32GP202

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!