Question: I'm suppose to use C programing to replace the _delay_cycles(250000); with for loops that produce thett exact same function. I tried to midify the code,
I'm suppose to use C programing to replace the _delay_cycles(250000); with for loops that produce thett exact same function. I tried to midify the code, by calling the function TimeDelay() which is suppose to replace the _delay_cycles(250000) with for loops. However when I connect the micontroller to my computer and compile the program the LEDs don't light up, which is something the happended with the _delay_cycles(250000). Can someone help me? My main.c code is below
#include
#include "LED.h"
#define TRUE 1
// Function prototypes
void ConfigureClockModule(void);
void main(void)
{
unsigned int delay=250;
unsigned int resolution=250;
// Stop the watchdog timer, and configure the clock module.
WDTCTL = WDTPW + WDTHOLD;
ConfigureClockModule();
InitializeLEDPortPins();
// Infinite loop
while (TRUE)
{
TURN_ON_LED1;
TURN_ON_LED2;
// Wait for approximately 1/4 second
TimeDelay(delay,resolution);
TURN_OFF_LED1;
TURN_OFF_LED2;
// Wait for approximately 1/4 second
TimeDelay(delay,resolution);
}
}
void TimeDelay(unsigned int delay, unsigned int resolution){
int i,j;
// Wait for approximately 1/4 second
for(i=0; i for(j=0; j } } void ConfigureClockModule(void) { // Configure Digitally Controlled Oscillator (DCO) using factory calibrations. DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
