Skip to content

Instantly share code, notes, and snippets.

@d-boz-wtwh
Created October 22, 2019 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d-boz-wtwh/5398f37999ca8549e4a33c441f70db93 to your computer and use it in GitHub Desktop.
Save d-boz-wtwh/5398f37999ca8549e4a33c441f70db93 to your computer and use it in GitHub Desktop.
Microcontroller Projects
/*
* File: code.c
* Author: Usman Ali Butt
* Property off: www.microcontroller-project.com
* Created on 19 March, 2017, 3:38 PM
*/
// PIC16F877 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG
#pragma config FOSC = EXTRC // Oscillator Selection bits (RC oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config CP = OFF // FLASH Program Memory Code Protection bits (Code protection off)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = ON // Low Voltage In-Circuit Serial Programming Enable bit
//(RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF // Data EE Memory Code Protection (Code Protection off)
// FLASH Program Memory Write Enable (Unprotected program memory may be written to by EECON control)
#pragma config WRT = ON
#include <stdio.h>
#include <stdlib.h>
#include <pic16f877.h>
int ramloc1 @ 0x70; //Reserve ram address for variable ramloc1
int ramloc2 @ 0x71; //Reserve ram address for variable ramloc2
int ramloc3 @ 0x72; //Reserve ram address for variable ramloc3
int main(int argc, char** argv) {//Program memory Address specified
ramloc1=0x45; //Store hex value all ram address 0x70
ramloc2=0x22; //Store hex value all ram address 0x71
ramloc3=0x34; //Store hex value all ram address 0x72
for(int i=0;i<1000;i++){
for(int j=0;j<10000;j++);
}
return (EXIT_SUCCESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment