Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 271 → Rev 272

/PIC Stuff/PICX_12F1840/base_INTERRUPTS.h
File deleted
/PIC Stuff/PICX_12F1840/funclist
File deleted
\ No newline at end of file
/PIC Stuff/PICX_12F1840/main.c
File deleted
/PIC Stuff/PICX_12F1840/base_CPS.c
File deleted
\ No newline at end of file
/PIC Stuff/PICX_12F1840/base_UART.h
File deleted
/PIC Stuff/PICX_12F1840/base_PWM.c
File deleted
/PIC Stuff/PICX_12F1840/defines.h
File deleted
/PIC Stuff/PICX_12F1840/base_CPS.h
File deleted
/PIC Stuff/PICX_12F1840/base_INTERRUPTS.c
File deleted
/PIC Stuff/PICX_12F1840/base_PWM.h
File deleted
/PIC Stuff/PICX_12F1840/nbproject/configurations.xml
File deleted
/PIC Stuff/PICX_12F1840/nbproject/Makefile-impl.mk
File deleted
/PIC Stuff/PICX_12F1840/nbproject/Package-default.bash
File deleted
/PIC Stuff/PICX_12F1840/nbproject/Makefile-genesis.properties
File deleted
/PIC Stuff/PICX_12F1840/nbproject/project.xml
File deleted
/PIC Stuff/PICX_12F1840/nbproject/Makefile-default.mk
File deleted
/PIC Stuff/PICX_12F1840/nbproject/Makefile-local-default.mk
File deleted
/PIC Stuff/PICX_12F1840/nbproject/Makefile-variables.mk
File deleted
/PIC Stuff/PICX_12F1840/Makefile
File deleted
/PIC Stuff/PICX_12F1840/base_UART.c
File deleted
\ No newline at end of file
/PIC Stuff/PICX_12F1840_CPS/base_CPS.c
0,0 → 1,131
#include <xc.h>
#include "defines.h"
#include "base_CPS.h"
 
static CPS_DATA *cps_data_p;
 
void CPS_Init(CPS_DATA* data) {
cps_data_p = data;
for (char i = 0; i < 4; i++) {
cps_data_p->btn_pressed[i] = 0;
cps_data_p->btn_last_value[i] = 0;
cps_data_p->btn_avg_value[i] = 0;
cps_data_p->btn_pct_value[i] = 0;
}
 
/* Initialize port direction */
CPS_0_TRIS = 1;
CPS_1_TRIS = 1;
 
/* Initialize FVR for the upper threshold (Ref+) */
FVRCONbits.CDAFVR = 0b01; // Gain of 1x (1.024V)
FVRCONbits.FVREN = 1; // Enable FVR module
 
/* Initialize DAC for the lower threshold (Ref-) to Vss */
DACCON0bits.DACEN = 0; // Disable DAC
DACCON0bits.DACLPS = 0; // Negative reference source selected
DACCON0bits.DACOE = 0; // Output not routed to DACOUT pin
DACCON0bits.DACPSS = 0b00; // Vss used as positive source
// DACCON0bits.DACNSS = 0; // Vss used as negative source
// Output voltage formula:
// V_out = ((V_source+ - V_source-) * (DACR / 32)) + V_source-
DACCON1bits.DACR = 0b00000; // Voltage output set to 0v
 
// /* Initialize DAC for the lower threshold (Ref-) to variable setting */
// DACCON0bits.DACEN = 1; // Enable DAC
// DACCON0bits.DACLPS = 1; // Positive reference source selected
// DACCON0bits.DACOE = 0; // Output not routed to DACOUT pin
// DACCON0bits.DACPSS = 0b10; // FVR buffer2 used as positive source
//// DACCON0bits.DACNSS = 0; // Vss used as negative source
// // Output voltage formula:
// // V_out = ((V_source+ - V_source-) * (DACR / 32)) + V_source-
// DACCON1bits.DACR = 0b10000; // Voltage output set to 0.512v
 
/* Initialize Timer 0 */
OPTION_REGbits.TMR0CS = 0; // Clock source is FOSC/4
OPTION_REGbits.PSA = 0; // Prescaler enabled
OPTION_REGbits.PS = 0b111; // Prescaler of 1:256
 
/* Initialize Timer 1 */
T1CONbits.TMR1CS = 0b11; // Clock source is Capacitive Sensing Oscillator
T1CONbits.T1CKPS = 0b00; // 1:1 Prescale value
T1GCONbits.TMR1GE = 1; // Counting is controlled by the gate function
T1GCONbits.T1GPOL = 1; // Gate is active high
T1GCONbits.T1GTM = 1; // Gate toggle mode is enabled
T1GCONbits.T1GSPM = 0; // Gate single-pulse mode is disabled
T1GCONbits.T1GSS = 0b01; // Gate source is Timer 0 overflow
T1CONbits.TMR1ON = 1; // Enables timer 1
 
/* Initialize CPS Module */
CPSCON0bits.CPSRM = 1; // DAC and FVR used for Vref- and Vref+
CPSCON0bits.CPSRNG = 0b11; // Osc in high range (100uA)
CPSCON0bits.T0XCS = 0; // Timer 0 clock runs at FOSC/4
CPSCON1bits.CPSCH = 0b00; // Channel 0 (CPS0)
cps_data_p->channel = 0;
CPSCON0bits.CPSON = 1; // CPS module is enabled
 
/* Initialize timer interrupts and clear timers */
INTCONbits.TMR0IE = 1; // Timer 0 interrupt enabled
PIE1bits.TMR1IE = 0; // Timer 1 interrupt disabled
CPS_Reset();
}
 
void CPS_Timer_0_Interrupt_Handler() {
unsigned int value = TMR1;
long percent;
 
if (value < 10) {
return;
}
 
// Calculate percentage change
percent = (long)cps_data_p->btn_avg_value[cps_data_p->channel]-(long)value;
if (percent < 0)
percent = 0;
else {
percent *= 100;
percent /= cps_data_p->btn_avg_value[cps_data_p->channel];
}
 
cps_data_p->btn_last_value[cps_data_p->channel] = value;
cps_data_p->btn_pct_value[cps_data_p->channel] = percent;
 
if (percent < CPS_PCT_OFF) {
// Calculate average
cps_data_p->btn_avg_value[cps_data_p->channel] =
cps_data_p->btn_avg_value[cps_data_p->channel] +
((long)value - (long)cps_data_p->btn_avg_value[cps_data_p->channel])
/CPS_AVG_COUNT;
// Set flag to indicate that button is not pressed
cps_data_p->btn_pressed[cps_data_p->channel] = 0;
} else if (percent > CPS_PCT_ON) {
// Set flag to indicate that button was pressed
cps_data_p->btn_pressed[cps_data_p->channel] = 1;
}
 
cps_data_p->channel = cps_data_p->channel + 1;
if (cps_data_p->channel == CPS_NUM_CHANNELS)
cps_data_p->channel = 0;
CPSCON1bits.CPSCH = cps_data_p->channel;
 
CPS_Reset();
}
 
void CPS_Reset() {
TMR1 = 0;
TMR0 = 0;
}
 
void CPS_Enable() {
INTCONbits.TMR0IE = 1; // Timer 0 interrupt enabled
T1CONbits.TMR1ON = 1;
CPSCON0bits.CPSON = 1;
CPS_Reset();
}
 
void CPS_Disable() {
INTCONbits.TMR0IE = 0;
CPSCON0bits.CPSON = 0;
T1CONbits.TMR1ON = 0;
}
/PIC Stuff/PICX_12F1840_CPS/base_CPS.h
0,0 → 1,30
#ifndef CPS_H
#define CPS_H
 
// Size of rolling average buffer
#define CPS_AVG_COUNT 16
 
// Number of capacitance button inputs
#define CPS_NUM_CHANNELS 2
 
// Percentage of capacitance change to register button press
#define CPS_PCT_ON 10
#define CPS_PCT_OFF 8
 
typedef struct {
char channel;
char btn_pressed[4];
unsigned int btn_last_value[4];
unsigned int btn_avg_value[4];
char btn_pct_value[4];
} CPS_DATA;
 
void CPS_Init(CPS_DATA *data);
void CPS_Timer_0_Interrupt_Handler(void);
void CPS_Reset(void);
 
void CPS_Enable(void);
void CPS_Disable(void);
 
#endif
 
/PIC Stuff/PICX_12F1840_CPS/funclist
0,0 → 1,15
___awdiv: CODE, 633 0 84
___aldiv: CODE, 397 0 130
_CPS_Reset: CODE, 942 0 5
_PWM_Set_Width: CODE, 871 0 46
_main: CODE, 717 0 54
_Interrupt_Enable: CODE, 956 0 3
_InterruptHandler: CODE, 4 0 30
___lmul: CODE, 824 0 47
__initialization: CODE, 952 0 1
_CPS_Timer_0_Interrupt_Handler: CODE, 36 0 361
i1_CPS_Reset: CODE, 947 0 5
_CPS_Init: CODE, 527 0 106
_PWM_Init: CODE, 917 0 25
_UART_Send_Interrupt_Handler: CODE, 771 0 53
Total: 950
/PIC Stuff/PICX_12F1840_CPS/nbproject/Makefile-default.mk
0,0 → 1,204
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
 
 
# Include project Makefile
ifeq "${IGNORE_LOCAL}" "TRUE"
# do not include local makefile. User is passing all local related variables already
else
include Makefile
# Include makefile containing local settings
ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk"
include nbproject/Makefile-local-default.mk
endif
endif
 
# Environment
MKDIR=gnumkdir -p
RM=rm -f
MV=mv
CP=cp
 
# Macros
CND_CONF=default
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
IMAGE_TYPE=debug
OUTPUT_SUFFIX=elf
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
else
IMAGE_TYPE=production
OUTPUT_SUFFIX=hex
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
endif
 
# Object Directory
OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
 
# Distribution Directory
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
 
# Source Files Quoted if spaced
SOURCEFILES_QUOTED_IF_SPACED=main.c base_INTERRUPTS.c base_UART.c base_CPS.c base_PWM.c
 
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.p1 ${OBJECTDIR}/base_INTERRUPTS.p1 ${OBJECTDIR}/base_UART.p1 ${OBJECTDIR}/base_CPS.p1 ${OBJECTDIR}/base_PWM.p1
POSSIBLE_DEPFILES=${OBJECTDIR}/main.p1.d ${OBJECTDIR}/base_INTERRUPTS.p1.d ${OBJECTDIR}/base_UART.p1.d ${OBJECTDIR}/base_CPS.p1.d ${OBJECTDIR}/base_PWM.p1.d
 
# Object Files
OBJECTFILES=${OBJECTDIR}/main.p1 ${OBJECTDIR}/base_INTERRUPTS.p1 ${OBJECTDIR}/base_UART.p1 ${OBJECTDIR}/base_CPS.p1 ${OBJECTDIR}/base_PWM.p1
 
# Source Files
SOURCEFILES=main.c base_INTERRUPTS.c base_UART.c base_CPS.c base_PWM.c
 
 
CFLAGS=
ASFLAGS=
LDLIBSOPTIONS=
 
############# Tool locations ##########################################
# If you copy a project from one host to another, the path where the #
# compiler is installed may be different. #
# If you open this project with MPLAB X in the new host, this #
# makefile will be regenerated and the paths will be corrected. #
#######################################################################
# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build
FIXDEPS=fixDeps
 
.build-conf: ${BUILD_SUBPROJECTS}
${MAKE} ${MAKE_OPTIONS} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
 
MP_PROCESSOR_OPTION=12F1840
# ------------------------------------------------------------------------------------
# Rules for buildStep: compile
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/main.p1.d
@${RM} ${OBJECTDIR}/main.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/main.p1 main.c
@-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d
@${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_INTERRUPTS.p1: base_INTERRUPTS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_INTERRUPTS.p1 base_INTERRUPTS.c
@-${MV} ${OBJECTDIR}/base_INTERRUPTS.d ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_INTERRUPTS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_UART.p1: base_UART.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_UART.p1.d
@${RM} ${OBJECTDIR}/base_UART.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_UART.p1 base_UART.c
@-${MV} ${OBJECTDIR}/base_UART.d ${OBJECTDIR}/base_UART.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_UART.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_CPS.p1: base_CPS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_CPS.p1.d
@${RM} ${OBJECTDIR}/base_CPS.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_CPS.p1 base_CPS.c
@-${MV} ${OBJECTDIR}/base_CPS.d ${OBJECTDIR}/base_CPS.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_CPS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_PWM.p1: base_PWM.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_PWM.p1.d
@${RM} ${OBJECTDIR}/base_PWM.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_PWM.p1 base_PWM.c
@-${MV} ${OBJECTDIR}/base_PWM.d ${OBJECTDIR}/base_PWM.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_PWM.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
else
${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/main.p1.d
@${RM} ${OBJECTDIR}/main.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/main.p1 main.c
@-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d
@${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_INTERRUPTS.p1: base_INTERRUPTS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_INTERRUPTS.p1 base_INTERRUPTS.c
@-${MV} ${OBJECTDIR}/base_INTERRUPTS.d ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_INTERRUPTS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_UART.p1: base_UART.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_UART.p1.d
@${RM} ${OBJECTDIR}/base_UART.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_UART.p1 base_UART.c
@-${MV} ${OBJECTDIR}/base_UART.d ${OBJECTDIR}/base_UART.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_UART.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_CPS.p1: base_CPS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_CPS.p1.d
@${RM} ${OBJECTDIR}/base_CPS.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_CPS.p1 base_CPS.c
@-${MV} ${OBJECTDIR}/base_CPS.d ${OBJECTDIR}/base_CPS.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_CPS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_PWM.p1: base_PWM.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_PWM.p1.d
@${RM} ${OBJECTDIR}/base_PWM.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -o${OBJECTDIR}/base_PWM.p1 base_PWM.c
@-${MV} ${OBJECTDIR}/base_PWM.d ${OBJECTDIR}/base_PWM.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_PWM.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
endif
 
# ------------------------------------------------------------------------------------
# Rules for buildStep: assemble
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
else
endif
 
# ------------------------------------------------------------------------------------
# Rules for buildStep: link
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CC} $(MP_EXTRA_LD_PRE) --chip=$(MP_PROCESSOR_OPTION) -G -mdist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.map -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" --ram=default,-160-16f -odist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
@${RM} dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.hex
else
dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CC} $(MP_EXTRA_LD_PRE) --chip=$(MP_PROCESSOR_OPTION) -G -mdist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.map --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -odist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
endif
 
 
# Subprojects
.build-subprojects:
 
 
# Subprojects
.clean-subprojects:
 
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r build/default
${RM} -r dist/default
 
# Enable dependency checking
.dep.inc: .depcheck-impl
 
DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES})
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
/PIC Stuff/PICX_12F1840_CPS/nbproject/Makefile-genesis.properties
0,0 → 1,8
#
#Mon Mar 10 16:56:28 EDT 2014
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v1.20\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1f98a0eed69cb2a45c12981fa9470927
default.languagetoolchain.version=1.20
host.platform=windows
conf.ids=default
default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=52258db7536b2d1fec300cefc7ed9230
/PIC Stuff/PICX_12F1840_CPS/nbproject/Makefile-impl.mk
0,0 → 1,69
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
 
 
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
 
 
# Project Name
PROJECTNAME=PICX_12F1840_CPS
 
# Active Configuration
DEFAULTCONF=default
CONF=${DEFAULTCONF}
 
# All Configurations
ALLCONFS=default
 
 
# build
.build-impl: .build-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
 
 
# clean
.clean-impl: .clean-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
 
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean
 
 
 
# all
.all-impl: .all-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build
 
 
 
# dependency checking support
.depcheck-impl:
# @echo "# This code depends on make tool being used" >.dep.inc
# @if [ -n "${MAKE_VERSION}" ]; then \
# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
# echo "include \$${DEPFILES}" >>.dep.inc; \
# echo "endif" >>.dep.inc; \
# else \
# echo ".KEEP_STATE:" >>.dep.inc; \
# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
# fi
/PIC Stuff/PICX_12F1840_CPS/nbproject/Makefile-local-default.mk
0,0 → 1,37
#
# Generated Makefile - do not edit!
#
#
# This file contains information about the location of compilers and other tools.
# If you commmit this file into your revision control server, you will be able to
# to checkout the project and build it from the command line with make. However,
# if more than one person works on the same project, then this file might show
# conflicts since different users are bound to have compilers in different places.
# In that case you might choose to not commit this file and let MPLAB X recreate this file
# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
# least once so the file gets created and the project can be built. Finally, you can also
# avoid using this file at all if you are only building from the command line with make.
# You can invoke make with the values of the macros:
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
SHELL=cmd.exe
PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.7.0_25-windows-x64\java-windows/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="C:\Program Files (x86)\Microchip\xc8\v1.20\bin\xc8.exe"
# MP_CPPC is not defined
# MP_BC is not defined
# MP_AS is not defined
# MP_LD is not defined
# MP_AR is not defined
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="C:\Program Files (x86)\Microchip\xc8\v1.20\bin"
# MP_CPPC_DIR is not defined
# MP_BC_DIR is not defined
# MP_AS_DIR is not defined
# MP_LD_DIR is not defined
# MP_AR_DIR is not defined
# MP_BC_DIR is not defined
/PIC Stuff/PICX_12F1840_CPS/nbproject/Makefile-variables.mk
0,0 → 1,13
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
# default configuration
CND_ARTIFACT_DIR_default=dist/default/production
CND_ARTIFACT_NAME_default=PICX_12F1840_CPS.production.hex
CND_ARTIFACT_PATH_default=dist/default/production/PICX_12F1840_CPS.production.hex
CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package
CND_PACKAGE_NAME_default=picx12f1840cps.tar
CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/picx12f1840cps.tar
/PIC Stuff/PICX_12F1840_CPS/nbproject/Package-default.bash
0,0 → 1,73
#!/bin/bash -x
 
#
# Generated - do not edit!
#
 
# Macros
TOP=`pwd`
CND_CONF=default
CND_DISTDIR=dist
TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
OUTPUT_BASENAME=PICX_12F1840_CPS.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
PACKAGE_TOP_DIR=picx12f1840cps/
 
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
 
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/package
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}
 
# Copy files and create directories and links
cd "${TOP}"
makeDirectory ${TMPDIR}/picx12f1840cps/bin
copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
 
 
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/package/picx12f1840cps.tar
cd ${TMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/picx12f1840cps.tar *
checkReturnCode
 
# Cleanup
cd "${TOP}"
rm -rf ${TMPDIR}
/PIC Stuff/PICX_12F1840_CPS/nbproject/configurations.xml
0,0 → 1,167
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<logicalFolder name="root" displayName="root" projectFiles="true">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>base_INTERRUPTS.h</itemPath>
<itemPath>base_UART.h</itemPath>
<itemPath>defines.h</itemPath>
<itemPath>base_CPS.h</itemPath>
<itemPath>base_PWM.h</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
projectFiles="true">
</logicalFolder>
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>base_INTERRUPTS.c</itemPath>
<itemPath>base_UART.c</itemPath>
<itemPath>base_CPS.c</itemPath>
<itemPath>base_PWM.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false">
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="default" type="2">
<toolsSet>
<developmentServer>localhost</developmentServer>
<targetDevice>PIC12F1840</targetDevice>
<targetHeader></targetHeader>
<targetPluginBoard></targetPluginBoard>
<platformTool>PICkit3PlatformTool</platformTool>
<languageToolchain>XC8</languageToolchain>
<languageToolchainVersion>1.20</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
<linkerLibItems>
</linkerLibItems>
</linkerTool>
<loading>
<useAlternateLoadableFile>false</useAlternateLoadableFile>
<alternateLoadableFile></alternateLoadableFile>
</loading>
</compileType>
<makeCustomizationType>
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
<makeCustomizationPreStep></makeCustomizationPreStep>
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
<makeCustomizationPostStep></makeCustomizationPostStep>
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
</makeCustomizationType>
<HI-TECH-COMP>
<property key="asmlist" value="true"/>
<property key="define-macros" value=""/>
<property key="extra-include-directories" value=""/>
<property key="identifier-length" value="255"/>
<property key="operation-mode" value="free"/>
<property key="opt-xc8-compiler-strict_ansi" value="false"/>
<property key="optimization-assembler" value="true"/>
<property key="optimization-assembler-files" value="true"/>
<property key="optimization-debug" value="false"/>
<property key="optimization-global" value="true"/>
<property key="optimization-level" value="9"/>
<property key="optimization-set" value="default"/>
<property key="optimization-speed" value="false"/>
<property key="preprocess-assembler" value="true"/>
<property key="undefine-macros" value=""/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="verbose" value="false"/>
<property key="warning-level" value="0"/>
<property key="what-to-do" value="ignore"/>
</HI-TECH-COMP>
<HI-TECH-LINK>
<property key="additional-options-checksum" value=""/>
<property key="additional-options-code-offset" value=""/>
<property key="additional-options-command-line" value=""/>
<property key="additional-options-errata" value=""/>
<property key="additional-options-extend-address" value="false"/>
<property key="additional-options-trace-type" value=""/>
<property key="additional-options-use-response-files" value="false"/>
<property key="backup-reset-condition-flags" value="false"/>
<property key="calibrate-oscillator" value="true"/>
<property key="calibrate-oscillator-value" value=""/>
<property key="clear-bss" value="true"/>
<property key="code-model-external" value="wordwrite"/>
<property key="code-model-rom" value=""/>
<property key="create-html-files" value="false"/>
<property key="data-model-ram" value=""/>
<property key="data-model-size-of-double" value="24"/>
<property key="data-model-size-of-float" value="24"/>
<property key="display-class-usage" value="false"/>
<property key="display-hex-usage" value="false"/>
<property key="display-overall-usage" value="true"/>
<property key="display-psect-usage" value="false"/>
<property key="fill-flash-options-addr" value=""/>
<property key="fill-flash-options-const" value=""/>
<property key="fill-flash-options-how" value="0"/>
<property key="fill-flash-options-inc-const" value="1"/>
<property key="fill-flash-options-increment" value=""/>
<property key="fill-flash-options-seq" value=""/>
<property key="fill-flash-options-what" value="0"/>
<property key="format-hex-file-for-download" value="false"/>
<property key="initialize-data" value="true"/>
<property key="keep-generated-startup.as" value="false"/>
<property key="link-in-c-library" value="true"/>
<property key="link-in-peripheral-library" value="true"/>
<property key="managed-stack" value="false"/>
<property key="opt-xc8-linker-file" value="false"/>
<property key="opt-xc8-linker-link_startup" value="false"/>
<property key="opt-xc8-linker-serial" value=""/>
<property key="program-the-device-with-default-config-words" value="true"/>
</HI-TECH-LINK>
<PICkit3PlatformTool>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze Peripherals" value="true"/>
<property key="SecureSegment.SegmentProgramming" value="FullChipProgramming"/>
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="false"/>
<property key="memories.configurationmemory" value="false"/>
<property key="memories.eeprom" value="false"/>
<property key="memories.flashdata" value="true"/>
<property key="memories.id" value="false"/>
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.end" value="0xfff"/>
<property key="memories.programmemory.start" value="0x0"/>
<property key="poweroptions.powerenable" value="false"/>
<property key="programmertogo.imagename" value=""/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.pgmspeed" value="2"/>
<property key="programoptions.preserveeeprom" value="false"/>
<property key="programoptions.preserveprogramrange" value="false"/>
<property key="programoptions.preserveprogramrange.end" value="0xfff"/>
<property key="programoptions.preserveprogramrange.start" value="0x0"/>
<property key="programoptions.preserveuserid" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.5"/>
</PICkit3PlatformTool>
<XC8-config-global>
<property key="advanced-elf" value="true"/>
<property key="output-file-format" value="-mcof,+elf"/>
<property key="stack-size-high" value="auto"/>
<property key="stack-size-low" value="auto"/>
<property key="stack-size-main" value="auto"/>
<property key="stack-type" value="compiled"/>
</XC8-config-global>
</conf>
</confs>
</configurationDescriptor>
/PIC Stuff/PICX_12F1840_CPS/nbproject/project.xml
0,0 → 1,16
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>PICX_12F1840_CPS</name>
<creation-uuid>7fe93e92-3ae3-42d5-9338-2afa3dbfcf6b</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions>h</header-extensions>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<asminc-extensions/>
<make-dep-projects/>
</data>
</configuration>
</project>
/PIC Stuff/PICX_12F1840_CPS/nbproject/project.properties
--- PICX_12F1840_CPS/Makefile (nonexistent)
+++ PICX_12F1840_CPS/Makefile (revision 272)
@@ -0,0 +1,108 @@
+#
+# There exist several targets which are by default empty and which can be
+# used for execution of your targets. These targets are usually executed
+# before and after some main targets. They are:
+#
+# .build-pre: called before 'build' target
+# .build-post: called after 'build' target
+# .clean-pre: called before 'clean' target
+# .clean-post: called after 'clean' target
+# .clobber-pre: called before 'clobber' target
+# .clobber-post: called after 'clobber' target
+# .all-pre: called before 'all' target
+# .all-post: called after 'all' target
+# .help-pre: called before 'help' target
+# .help-post: called after 'help' target
+#
+# Targets beginning with '.' are not intended to be called on their own.
+#
+# Main targets can be executed directly, and they are:
+#
+# build build a specific configuration
+# clean remove built files from a configuration
+# clobber remove all built files
+# all build all configurations
+# help print help mesage
+#
+# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
+# .help-impl are implemented in nbproject/makefile-impl.mk.
+#
+# Available make variables:
+#
+# CND_BASEDIR base directory for relative paths
+# CND_DISTDIR default top distribution directory (build artifacts)
+# CND_BUILDDIR default top build directory (object files, ...)
+# CONF name of current configuration
+# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
+# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
+# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
+# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
+# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
+# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
+#
+# NOCDDL
+
+
+# Environment
+MKDIR=mkdir
+CP=cp
+CCADMIN=CCadmin
+RANLIB=ranlib
+
+
+# build
+build: .build-post
+
+.build-pre:
+# Add your pre 'build' code here...
+
+.build-post: .build-impl
+# Add your post 'build' code here...
+
+
+# clean
+clean: .clean-post
+
+.clean-pre:
+# Add your pre 'clean' code here...
+
+.clean-post: .clean-impl
+# Add your post 'clean' code here...
+
+
+# clobber
+clobber: .clobber-post
+
+.clobber-pre:
+# Add your pre 'clobber' code here...
+
+.clobber-post: .clobber-impl
+# Add your post 'clobber' code here...
+
+
+# all
+all: .all-post
+
+.all-pre:
+# Add your pre 'all' code here...
+
+.all-post: .all-impl
+# Add your post 'all' code here...
+
+
+# help
+help: .help-post
+
+.help-pre:
+# Add your pre 'help' code here...
+
+.help-post: .help-impl
+# Add your post 'help' code here...
+
+
+
+# include project implementation makefile
+include nbproject/Makefile-impl.mk
+
+# include project make variables
+include nbproject/Makefile-variables.mk
/PIC Stuff/PICX_12F1840_CPS/base_INTERRUPTS.c
0,0 → 1,55
#include <xc.h>
#include "defines.h"
#include "base_INTERRUPTS.h"
#include "base_UART.h"
#include "base_CPS.h"
 
void Interrupt_Enable() {
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
}
 
void Interrupt_Disable() {
INTCONbits.GIE = 0;
INTCONbits.PEIE = 0;
}
 
void interrupt InterruptHandler(void) {
char tmr0_rollover = 0;
// Check to see if we have an interrupt on Timer 0 (CPS)
if (INTCONbits.TMR0IF) {
CPS_Timer_0_Interrupt_Handler();
INTCONbits.TMR0IF = 0;
}
// // Check to see if we have an I2C interrupt
// if (PIR1bits.SSPIF) {
// I2C_Interrupt_Handler();
// PIR1bits.SSPIF = 0;
// }
 
#ifndef UART_TX_ONLY
// Check to see if we have an interrupt on USART1 RX
if (PIR1bits.RCIF) {
UART_Recv_Interrupt_Handler();
PIR1bits.RCIF = 0;
if (INTCONbits.TMR0IF)
tmr0_rollover = 1;
}
#endif
 
// Check to see if we have an interrupt on USART1 TX
if (PIR1bits.TXIF) {
UART_Send_Interrupt_Handler();
// PIR1bits.TXIF = 0;
if (INTCONbits.TMR0IF)
tmr0_rollover = 1;
}
 
// If Timer 0 rolls over while servicing another interrupt handler,
// reset the timers as the sample will be inaccurate.
if (tmr0_rollover) {
CPS_Reset();
}
}
/PIC Stuff/PICX_12F1840_CPS/base_INTERRUPTS.h
0,0 → 1,12
#ifndef INTERRUPTS_H
#define INTERRUPTS_H
 
// Enable all interrupts (high and low priority)
void Interrupt_Enable(void);
 
// Disable all interrupts (high and low priority)
void Interrupt_Disable(void);
 
void interrupt InterruptHandlerHigh(void);
 
#endif
/PIC Stuff/PICX_12F1840_CPS/base_PWM.c
0,0 → 1,33
#include <xc.h>
#include "defines.h"
#include "base_PWM.h"
 
void PWM_Init() {
// Output pin initially blocked
PWM_TRIS = 1;
 
/* Initialize PWM module */
PR2 = 0xF9; // 4ms @ 16MHz
CCP1CONbits.P1M = 0b00; // Single output, P1A modulated only
CCP1CONbits.CCP1M = 0b1100; // PWM mode, P1A active-high, P1B active-high
 
// Idle the output till width is specified
CCPR1L = 0x00;
CCP1CONbits.DC1B = 0b00;
 
/* Initialize Timer 2 */
PIR1bits.TMR2IF = 0; // Clear the interrupt flag for Timer 2
T2CONbits.T2CKPS = 0b11; // Set a prescaler of 64
T2CONbits.TMR2ON = 1; // Enable the timer
 
// Wait for the timer to overflow before enabling output
while (!PIR1bits.TMR2IF);
PWM_TRIS = 0;
}
 
void PWM_Set_Width(int width_us) {
// Set the pulse duration to the requested width
int value = width_us / 4;
CCPR1L = value >> 2;
CCP1CONbits.DC1B = value;
}
/PIC Stuff/PICX_12F1840_CPS/base_PWM.h
0,0 → 1,12
#ifndef PWM_H
#define PWM_H
 
#define PWM_Width_Min 510
#define PWM_Width_Max 2300
#define PWM_Width_Mid 1350
 
void PWM_Init(void);
 
void PWM_Set_Width(int width_us);
 
#endif
/PIC Stuff/PICX_12F1840_CPS/base_UART.c
0,0 → 1,137
#include <xc.h>
#include "defines.h"
#include "base_UART.h"
 
static UART_DATA *uart_data_p;
 
void UART_Init(UART_DATA *data) {
uart_data_p = data;
 
UART_TX_TRIS = 0; // Tx pin set to output
#ifndef UART_TX_ONLY
UART_RX_TRIS = 1; // Rx pin set to input
#endif
LATAbits.LATA0 = 1; // Keep the line high at start
 
BAUDCONbits.BRG16 = 0; // 8-bit baud rate generator
SPBRGL = 25; // Set UART speed to 38400 baud
TXSTAbits.BRGH = 1; // High speed mode
 
TXSTAbits.SYNC = 0; // Async mode
RCSTAbits.SPEN = 1; // Serial port enable
 
TXSTAbits.TX9 = 0; // 8 bit transmission
 
TXSTAbits.TXEN = 1; // Transmission enabled
 
PIE1bits.TXIE = 0; // Disable TX interrupt
#ifndef UART_TX_ONLY
RCSTAbits.RX9 = 0; // 8 bit reception
RCSTAbits.CREN = 1; // Enables receiver
PIE1bits.RCIE = 1; // Enable RX interrupt
 
// Initialize the buffer that holds UART messages
uart_data_p->buffer_in_read_ind = 0;
uart_data_p->buffer_in_write_ind = 0;
uart_data_p->buffer_in_len = 0;
uart_data_p->buffer_in_len_tmp = 0;
#else
RCSTAbits.CREN = 0;
#endif
uart_data_p->buffer_out_ind = 0;
uart_data_p->buffer_out_len = 0;
}
 
void UART_Send_Interrupt_Handler() {
// Put remaining data in TSR for transmit
if (uart_data_p->buffer_out_ind != uart_data_p->buffer_out_len) {
TXREG = uart_data_p->buffer_out[uart_data_p->buffer_out_ind];
uart_data_p->buffer_out_ind++;
} else {
while (!TXSTAbits.TRMT); // Wait for last byte to finish sending
PIE1bits.TXIE = 0;
uart_data_p->buffer_out_ind = 0;
uart_data_p->buffer_out_len = 0;
}
}
 
void UART_Write(const char *string, char length) {
while (PIE1bits.TXIE); // Wait for previous message to finish sending
uart_data_p->buffer_out_len = length;
uart_data_p->buffer_out_ind = 1;
for (char i = 0; i < length; i++) {
uart_data_p->buffer_out[i] = string[i];
}
TXREG = uart_data_p->buffer_out[0]; // Put first byte in TSR
PIE1bits.TXIE = 1;
}
 
void UART_WriteD(const char* string, char length) {
PIE1bits.TXIE = 1;
for (char i = 0; i < length; i++) {
TXREG = string[i];
NOP();
while (!PIR1bits.TXIF);
}
PIE1bits.TXIE = 0;
}
 
#ifndef UART_TX_ONLY
void UART_Recv_Interrupt_Handler() {
if (PIR1bits.RCIF) { // Check if data receive flag is set
char c = RCREG;
 
// Save received data into buffer
uart_data_p->buffer_in[uart_data_p->buffer_in_write_ind] = c;
if (uart_data_p->buffer_in_write_ind == MAXUARTBUF - 1) {
uart_data_p->buffer_in_write_ind = 0;
} else {
uart_data_p->buffer_in_write_ind++;
}
 
// Store the last MAXUARTBUF values entered
if (uart_data_p->buffer_in_len_tmp < MAXUARTBUF) {
uart_data_p->buffer_in_len_tmp++;
} else {
if (uart_data_p->buffer_in_read_ind == MAXUARTBUF - 1) {
uart_data_p->buffer_in_read_ind = 0;
} else {
uart_data_p->buffer_in_read_ind++;
}
}
 
// Update buffer size upon receiving newline (0x0D)
if (c == UART_BREAK_CHAR) {
uart_data_p->buffer_in_len = uart_data_p->buffer_in_len_tmp;
uart_data_p->buffer_in_len_tmp = 0;
}
}
 
if (RCSTAbits.OERR == 1) {
// We've overrun the USART and must reset
TXSTAbits.TXEN = 0; // Kill anything currently sending
RCSTAbits.CREN = 0; // Reset UART1
RCSTAbits.CREN = 1;
}
}
 
char UART_Buffer_Len() {
return uart_data_p->buffer_in_len;
}
 
/* Reader interface to the UART buffer, returns the number of bytes read */
char UART_Read_Buffer(char *buffer) {
char i = 0;
while (uart_data_p->buffer_in_len != 0) {
buffer[i] = uart_data_p->buffer_in[uart_data_p->buffer_in_read_ind];
i++;
if (uart_data_p->buffer_in_read_ind == MAXUARTBUF - 1) {
uart_data_p->buffer_in_read_ind = 0;
} else {
uart_data_p->buffer_in_read_ind++;
}
uart_data_p->buffer_in_len--;
}
return i;
}
#endif
/PIC Stuff/PICX_12F1840_CPS/base_UART.h
0,0 → 1,33
#ifndef UART_H
#define UART_H
 
#define UART_TX_ONLY
 
#define UART_BUFFER_SIZE 32
#define UART_BREAK_CHAR 0x0D
 
typedef struct {
#ifndef UART_TX_ONLY
char buffer_in[UART_BUFFER_SIZE];
volatile char buffer_in_read_ind;
volatile char buffer_in_write_ind;
volatile char buffer_in_len;
volatile char buffer_in_len_tmp;
#endif
 
volatile char buffer_out[UART_BUFFER_SIZE];
volatile char buffer_out_ind;
volatile char buffer_out_len;
} UART_DATA;
 
void UART_Init(UART_DATA *data);
void UART_Send_Interrupt_Handler(void);
void UART_Write(const char *string, char length);
void UART_WriteD(const char *string, char length);
#ifndef UART_TX_ONLY
void UART_Recv_Interrupt_Handler(void);
char UART_Buffer_Len(void);
char UART_Read_Buffer(char *buffer);
#endif
 
#endif
/PIC Stuff/PICX_12F1840_CPS/defines.h
0,0 → 1,18
#ifndef DEFINES_H
#define DEFINES_H
 
// Preprocessor define for __delay_ms() and __delay_us()
#define _XTAL_FREQ 32000000
 
#define CPS_0_TRIS TRISAbits.TRISA0
#define CPS_1_TRIS TRISAbits.TRISA1
 
#define LED_TRIS TRISAbits.TRISA2
#define LED_LAT LATAbits.LATA2
 
#define UART_TX_TRIS TRISAbits.TRISA4
 
#define PWM_TRIS TRISAbits.TRISA5
 
#endif /* DEFINES_H */
 
/PIC Stuff/PICX_12F1840_CPS/main.c
0,0 → 1,87
#include <xc.h>
#include "defines.h"
#include "base_INTERRUPTS.h"
//#include "base_UART.h"
#include "base_CPS.h"
#include "base_PWM.h"
 
// <editor-fold defaultstate="collapsed" desc="Configuration Registers">
/* Config Register CONFIGL @ 0x8007 */
#pragma config CPD = OFF // Data memory code protection is disabled
#pragma config BOREN = OFF // Brown-out Reset disabled
#pragma config IESO = OFF // Internal/External Switchover mode is disabled
#pragma config FOSC = INTOSC // INTOSC oscillator: I/O function on CLKIN pin
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor is disabled
#pragma config MCLRE = ON // MCLR/VPP pin function is MCLR
#pragma config WDTE = OFF // WDT disabled
#pragma config CP = OFF // Program memory code protection is disabled
#pragma config PWRTE = OFF // PWRT disabled
#pragma config CLKOUTEN = OFF // CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
 
/* Config Register CONFIG2 @ 0x8008 */
#pragma config PLLEN = OFF // 4x PLL disabled
#pragma config WRT = OFF // Write protection off
#pragma config STVREN = OFF // Stack Overflow or Underflow will not cause a Reset
#pragma config BORV = HI // Brown-out Reset Voltage (Vbor), high trip point selected.
#pragma config LVP = OFF // High-voltage on MCLR/VPP must be used for programming
// </editor-fold>
 
int main() {
 
// Oscillator configuration (16Mhz HFINTOSC)
OSCCONbits.SCS = 0b00;
OSCCONbits.IRCF = 0b1111;
ANSELA = 0x00; // All pins set to digital I/O
APFCONbits.CCP1SEL = 1; // Switch CCP1 from RA2 to RA5
APFCONbits.TXCKSEL = 1; // Switch TX/CK from RA0 to RA4
APFCONbits.RXDTSEL = 1; // Switch RX/DT from RA1 to RA5
 
/* Set pins as analog */
/* 0x01 = ANSA0 (RA0)
* 0x02 = ANSA1 (RA1)
* 0x04 = ANSA2 (RA2)
* 0x10 = ANSA4 (RA4) */
ANSELA = 0x03;
Interrupt_Enable();
 
// UART_DATA uart_data;
// UART_Init(&uart_data);
 
CPS_DATA cps_data;
CPS_Init(&cps_data);
 
PWM_Init();
// char msg[] = "Begin Program\n";
// UART_Write(msg, 14);
 
LED_TRIS = 0;
 
while(1) {
// __delay_ms(10);
 
// unsigned int value = cps_data.btn_last_value[cps_data.channel];
// unsigned int avg = cps_data.btn_avg_value[cps_data.channel];
// unsigned char output[9];
// output[0] = cps_data.channel;
// output[1] = 0;
// output[2] = value >> 8;
// output[3] = value;
// output[4] = 0;
// output[5] = avg >> 8;
// output[6] = avg;
// output[7] = 0;
// output[8] = cps_data.btn_pct_value[cps_data.channel];
// UART_WriteD(output, 9);
 
if (cps_data.btn_pressed[0] || cps_data.btn_pressed[1]) {
LED_LAT = 1;
PWM_Set_Width(1350);
} else {
LED_LAT = 0;
PWM_Set_Width(800);
}
}
}