Skip to content

Instantly share code, notes, and snippets.

@marioIncandeza
marioIncandeza / finalProject.c
Last active December 6, 2015 22:20
Final Project for Microprocessors
//Final Project for EENG 3040
//Patient Position
//Mike Johnson & Lindsey Erps
//December 2015
#include <xc.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
// CONFIG1
@marioIncandeza
marioIncandeza / lab9.c
Created October 23, 2015 01:05
PWM Motor Control with TMR2 on RC2
// PIC16F887 Configuration Bit Settings
#include <xc.h>
// CONFIG1
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
@marioIncandeza
marioIncandeza / twinkle.c
Last active October 11, 2015 04:39
My first C program
// PIC16F887 Configuration Bit Settings
// 'C' source line config statements
#define _XTAL_FREQ 4000000
#include <xc.h>
#include <stdlib.h>
#include <stdio.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
;This code checks to see which button is pressed on the 4x4 keypad and displays it on an LCD
;It formats the numbers like a phone number and dials after 10 entries
;hardware request:SW S4 ON ,S6 ON,S5 5-6 bits ON,the others OFF
;******************************************************
;PIC Configuration for PIC16F887
#include "p16F887.inc"
; CONFIG1
@marioIncandeza
marioIncandeza / stopwatch.asm
Last active January 18, 2019 19:25
Code for a stopwatch for a PIC16F887 microcontroller
;******************************************************
;PIC Configuration for PIC16F887
#include "p16F887.inc"
; CONFIG1
; __config 0x2032
__CONFIG _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_ON & _CPD_ON & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF & _LVP_OFF
; CONFIG2
; __config 0x3FFF
__CONFIG _CONFIG2, _BOR4V_BOR40V & _WRT_OFF
ORG 000H
GOTO INIT
ORG 004H
GOTO TMR0ISR
INIT
WCOPY EQU 70H ;Since the upper 16 bytes of all GPR banks are common in the PIC16F882/883/884/886/887,
STATCOPY EQU 71H ;temporary holding registers, W_TEMP and STATUS_TEMP, should be placed in here.
;These 16 locations do not require banking and therefore, make it easier to context save and restore.
ORG 000H
GOTO INITIALIZE
ORG 004H
GOTO INCREMENTER
INITIALIZE
BCF STATUS,RP0
BCF STATUS,RP1
@marioIncandeza
marioIncandeza / firstDelay.asm
Last active September 14, 2015 17:57
Delay Subroutine for PIC16F887
;Delay subroutine that lasts approximately 0.01 seconds
CALL WAIT ;2
WAIT
MOVLW 0DH
MOVWF OCOUNT
MOVLW 0FFH
MOVWF ICOUNT ;4
@marioIncandeza
marioIncandeza / lab3EENG3040.ASM
Last active September 10, 2015 22:09
Microcontrollers Lab 3
;******************************************************
;PIC Configuration for PIC16F887
#include "p16F887.inc"
; CONFIG1
; __config 0x2032
__CONFIG _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_ON & _CPD_ON & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF & _LVP_OFF
; CONFIG2
; __config 0x3FFF
__CONFIG _CONFIG2, _BOR4V_BOR40V & _WRT_OFF