Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] Redo the LED blink code, this time using for loops to generate the delays

Status
Not open for further replies.

kvega24

Newbie level 1
Joined
Feb 25, 2020
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
9
Redo the LED blink code, this time using for loops to generate the delays, instead of calling the delay function. How do I change the code to use for loops to create delays?

Code:
// CONFIG 

#pragma config FOSC = HS     // Oscillator Selection bits (RC oscillator) 

#pragma config WDTE = OFF       // Watchdog Timer (WDT enabled) 

#pragma config PWRTE = OFF      // Power-up Timer Enable bit (Power-up Timer is disabled) 

#pragma config CP = OFF         // Code Protection bit (Code protection disabled) 

 

#include < stdio.h > 

#include < xc.h > 

 

 

#define LED RA0 

#define _XTAL_FREQ 20000000 

void main() 

{ 

  TRISA = 0; 

 LED = 1; 

   while(1) 

{ 

   __delay_ms(500); 

  LED =0; 

   __delay_ms(500); 

   LED=1; 

   } 

}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top