Subversion Repositories Code-Repo

Compare Revisions

No changes between revisions

Ignore whitespace Rev 333 → Rev 342

/PIC Projects/PICX_12F1840_Pulse_Generator/DEFINES.h
0,0 → 1,27
#ifndef DEFINES_H
#define DEFINES_H
 
#include <xc.h>
#include "stdint.h"
 
// UART TX on pin 7
#define UART_TX_TRIS TRISAbits.TRISA0
// UART RX on pin 6
#define UART_RX_TRIS TRISAbits.TRISA1
 
// CCP1 on pin 5
#define CCP1_TRIS TRISAbits.TRISA2
#define CCP1_LAT LATAbits.LATA2
 
// IOC on pin 4
#define IOC_TRIS TRISAbits.TRISA3
#define IOC_PORT PORTAbits.RA3
#define IOC_IOCAP IOCAPbits.IOCAP3
#define IOC_IOCAN IOCANbits.IOCAN3
#define IOC_IOCAF IOCAFbits.IOCAF3
 
// Oscillator on pins 2-3
#define _XTAL_FREQ 20000000
 
#endif /* DEFINES_H */
 
/PIC Projects/PICX_12F1840_Pulse_Generator/EUSART.c.c
0,0 → 1,103
#include "DEFINES.h"
#include "EUSART.h"
#include "INTERRUPTS.h"
 
static volatile uint8_t txBuffer[UART_TX_BUFFER_SIZE];
static volatile uint8_t txBufferSize = 0;
static volatile uint8_t txBufferIndex = 0;
 
static volatile uint8_t rxBuffer[UART_RX_BUFFER_SIZE];
static volatile uint8_t rxBufferSize = 0;
static volatile uint8_t rxBufferIndex = 0;
 
void UART_Init() {
UART_TX_TRIS = 0;
UART_RX_TRIS = 1;
 
BAUDCONbits.BRG16 = 0; // 8-bit baud rate generation
SPBRG = 64; // Baud rate of 19.2k
TXSTAbits.BRGH = 1; // High speed mode
 
TXSTAbits.SYNC = 0; // Async mode
RCSTAbits.SPEN = 1; // Serial port enable
 
TXSTAbits.TX9 = 0; // 8 bit transmission
RCSTAbits.RX9 = 0; // 8 bit reception
 
TXSTAbits.TXEN = 1; // Transmission enabled
RCSTAbits.CREN = 1; // Reception enabled
 
PIE1bits.TXIE = 0; // TX interrupt starts disabled
PIE1bits.RCIE = 1; // RX interrupt starts enabled
}
 
void UART_Write(uint8_t *msg, uint8_t length) {
// Check to make sure there is enough space in buffer for message
length = (length > UART_TX_BUFFER_SIZE) ? UART_TX_BUFFER_SIZE : length;
// Wait for previous message to finish sending
while (PIE1bits.TXIE);
 
txBufferSize = length;
txBufferIndex = 1;
for (uint8_t i = 0; i < length; i++) {
txBuffer[i] = msg[i];
}
TXREG = txBuffer[0];
PIE1bits.TXIE = 1;
}
 
void UART_TX_Interrupt_Handler() {
if (txBufferIndex != txBufferSize) {
// Transmit next byte in the buffer
TXREG = txBuffer[txBufferIndex];
txBufferIndex++;
} else {
// Wait for last byte to finish sending
while (!TXSTAbits.TRMT);
PIE1bits.TXIE = 0;
txBufferSize = 0;
txBufferIndex = 0;
}
}
 
void UART_RX_Interrupt_Handler() {
if (PIR1bits.RCIF) {
uint8_t c = RCREG;
 
// Store received byte into buffer and increment write location
rxBuffer[rxBufferIndex] = c;
if (rxBufferIndex == UART_RX_BUFFER_SIZE - 1) {
rxBufferIndex = 0;
} else {
rxBufferIndex++;
}
 
// Increment received byte count
if (rxBufferSize < UART_RX_BUFFER_SIZE) {
rxBufferSize++;
}
}
 
// If UART overrun is detected, reset module
if (RCSTAbits.OERR) {
TXSTAbits.TXEN = 0;
RCSTAbits.CREN = 0;
RCSTAbits.CREN = 1;
}
}
 
uint8_t UART_Read(uint8_t *buffer) {
// Return values in RX buffer
uint8_t size = rxBufferSize;
for (uint8_t i = 0; i < size; i++) {
buffer[i] = rxBuffer[i];
}
 
return size;
}
 
void UART_Reset_RX() {
rxBufferIndex = 0;
rxBufferSize = 0;
}
/PIC Projects/PICX_12F1840_Pulse_Generator/EUSART.h
0,0 → 1,15
#ifndef EUSART_H
#define EUSART_H
 
#define UART_TX_BUFFER_SIZE 32
#define UART_RX_BUFFER_SIZE 32
 
void UART_Init();
void UART_Write(uint8_t *msg, uint8_t length);
uint8_t UART_Read(uint8_t *buffer);
void UART_Reset_RX();
void UART_TX_Interrupt_Handler();
void UART_RX_Interrupt_Handler();
 
#endif /* EUSART_H */
 
/PIC Projects/PICX_12F1840_Pulse_Generator/INTERRUPTS.c
0,0 → 1,39
#include "DEFINES.h"
#include "INTERRUPTS.h"
#include "IOC.h"
#include "EUSART.h"
 
void Interrupt_Enable() {
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
}
 
void Interrupt_Disable() {
INTCONbits.GIE = 0;
INTCONbits.PEIE = 0;
}
 
void interrupt InterruptHandler(void) {
 
// Check for an IOC interrupt
if (INTCONbits.IOCIF) {
IOC_Interrupt_Handler();
INTCONbits.IOCIF = 0;
return;
}
 
// Check to see if we have an interrupt on USART1 RX
if (PIR1bits.RCIF) {
UART_RX_Interrupt_Handler();
PIR1bits.RCIF = 0;
return;
}
 
// Check to see if we have an interrupt on USART1 TX
if (PIR1bits.TXIF) {
UART_TX_Interrupt_Handler();
// PIR1bits.TXIF = 0;
return;
}
 
}
/PIC Projects/PICX_12F1840_Pulse_Generator/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 InterruptHandler(void);
 
#endif
/PIC Projects/PICX_12F1840_Pulse_Generator/IOC.c
0,0 → 1,23
#include "DEFINES.h"
#include "IOC.h"
#include "PWM.h"
 
void IOC_Init() {
// Enable global IOC interrupt
INTCONbits.IOCIE = 1;
 
IOC_TRIS = 1;
 
// Enable IOC on rising edge only
IOC_IOCAP = 0;
IOC_IOCAN = 1;
}
 
void IOC_Interrupt_Handler() {
// Transmit the saved pattern
if (IOC_IOCAF)
PWM_Transmit_Pattern();
 
// Clear all status flags
IOC_IOCAF = 0;
}
/PIC Projects/PICX_12F1840_Pulse_Generator/IOC.h
0,0 → 1,8
#ifndef IOC_H
#define IOC_H
 
void IOC_Init();
void IOC_Interrupt_Handler();
 
#endif /* IOC_H */
 
/PIC Projects/PICX_12F1840_Pulse_Generator/Makefile
0,0 → 1,113
#
# 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...
# WARNING: the IDE does not call this target since it takes a long time to
# simply run make. Instead, the IDE removes the configuration directories
# under build and dist directly without calling make.
# This target is left here so people can do a clean when running a clean
# outside the IDE.
 
.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 Projects/PICX_12F1840_Pulse_Generator/PWM.c
0,0 → 1,355
#include "PWM.h"
#include "INTERRUPTS.h"
 
static volatile uint8_t computedFrequency = 0;
static volatile uint8_t computedDutyCycleHigh_UpperByte = 0;
static volatile uint8_t computedDutyCycleHigh_LowerBits = 0;
static volatile uint8_t computedDutyCycleLow_UpperByte = 0;
static volatile uint8_t computedDutyCycleLow_LowerBits = 0;
static volatile uint8_t savedDutyCycleHigh = PWM_DEFAULT_HIGH_CYCLE;
static volatile uint8_t savedDutyCycleLow = PWM_DEFAULT_LOW_CYCLE;
static volatile uint16_t savedPattern = 0xAAAA;
 
void PWM_Init() {
// Initialize CCP1 / Timer 2
CCP1_TRIS = 1; // PWM output starts disabled
CCP1CONbits.P1M = 0b00; // Single output, P1A modulated only
CCP1CONbits.CCP1M = 0b1100; // PWM Mode, P1A active-high, P1B active-high
PIR1bits.TMR2IF = 0; // Clear Timer 2 interrupt flag
TMR2 = 0x0;
 
Set_PWM_Frequency(PWM_DEFAULT_FREQ);
Set_PWM_Duty_Cycle(PWM_DEFAULT_HIGH_CYCLE, PWM_DEFAULT_LOW_CYCLE);
}
 
void Set_PWM_Frequency(uint32_t frequency) {
// Timer 2 clocked at FOSC/4 (20 Mhz)
// Prescaler 1:1 = minimum frequency of 19,532 Hz
// Prescaler 1:4 = minimum frequency of 4,883 Hz
// Prescaler 1:16 = minimum frequency of 1,221 Hz
// Prescaler 1:64 = minimum frequency of 306 Hz
 
// PWM Period = [PR2 + 1] * 4 * TOSC * Prescale
// = [PR2 + 1] * 4 * (1/FOSC) * Prescale
// = ([PR2 + 1] * 4 * Prescale) / FOSC
// PWM Freq = 1/(PWM Period)
// = 1/(PR2 + 1) * 1/4 * FOSC * 1/Prescale)
// = FOSC / ([PR2 + 1] * 4 * Prescale)
// PR2 = (FOSC / [(PWM Freq) * 4 * Presccale]) - 1
 
uint8_t preScaleValue;
if (frequency > 19532) {
preScaleValue = 1;
T2CONbits.T2CKPS = 0b00;
} else if (frequency > 4883) {
preScaleValue = 4;
T2CONbits.T2CKPS = 0b01;
} else if (frequency > 1221) {
preScaleValue = 16;
T2CONbits.T2CKPS = 0b10;
} else {
preScaleValue = 64;
T2CONbits.T2CKPS = 0b11;
}
 
uint32_t tmp = frequency * 4 * preScaleValue;
computedFrequency = (_XTAL_FREQ / tmp) - 1;
 
// Updated duty cycle
Set_PWM_Duty_Cycle(savedDutyCycleHigh, savedDutyCycleLow);
}
 
void Set_PWM_Duty_Cycle(uint8_t highPercent, uint8_t lowPercent) {
// Duty cycle specified by 10 bit value in CCPR1L:DC1B<1:0>
savedDutyCycleHigh = highPercent;
savedDutyCycleLow = lowPercent;
 
// Compute values to store in register
uint32_t highValue = (computedFrequency + 1) * 4;
highValue *= highPercent;
highValue /= 100;
computedDutyCycleHigh_LowerBits = highValue & 0x3;
computedDutyCycleHigh_UpperByte = (highValue >> 2) & 0xFF;
 
uint32_t lowValue = (computedFrequency + 1) * 4;
lowValue *= lowPercent;
lowValue /= 100;
computedDutyCycleLow_LowerBits = lowValue & 0x3;
computedDutyCycleLow_UpperByte = (lowValue >> 2) & 0xFF;
}
 
void Set_PWM_Pattern(uint16_t pattern) {
savedPattern = pattern;
}
 
void PWM_Transmit_Pattern() {
// Set PWM frequency pre-computed values
PR2 = computedFrequency;
 
// Set duty cycle to 0%
CCP1CONbits.DC1B = 0b00;
CCPR1L = 0x00;
 
// Start timer and wait for it to rollover to latch duty cycle value
T2CONbits.TMR2ON = 1;
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
CCP1_TRIS = 0;
 
// Bit 15
if (savedPattern & 0x8000) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
/* The above section of code disassembles to the following assembly code
* According to the instruction set table, this should take 22 cycles to execute
* 22 cycles corresponds to a maximum of ~227.272 kHz PWM frequency
* If higher PWM frequency is needed, DC1B can be omitted for lower duty cycle accuracy
! if (pattern & 0x8000) {
0x26: BTFSS 0x72, 0x7
0x27: GOTO 0x34
! CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
0x28: MOVLB 0x0
0x29: MOVF computedDutyCycleHigh_LowerBits, W
0x2A: MOVWF 0x73
0x2B: SWAPF 0x73, F
0x2C: MOVLB 0x5
0x2D: MOVF CCP1CON, W
0x2E: XORWF 0x2F3, W
0x2F: ANDLW 0xCF
0x30: XORWF 0x2F3, W
0x31: MOVWF CCP1CON
! CCPR1L = computedDutyCycleHigh_UpperByte;
0x32: MOVF computedDutyCycleHigh_UpperByte, W
0x33: GOTO 0x41
! } else {
! CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
0x34: MOVLB 0x0
0x35: MOVF computedDutyCycleLow_LowerBits, W
0x36: MOVWF 0x73
0x37: SWAPF 0x73, F
0x38: MOVLB 0x5
0x39: MOVF CCP1CON, W
0x3A: XORWF 0x2F3, W
0x3B: ANDLW 0xCF
0x3C: XORWF 0x2F3, W
0x3D: MOVWF CCP1CON
! CCPR1L = computedDutyCycleLow_UpperByte;
0x3E: MOVLB 0x0
0x3F: MOVF computedDutyCycleLow_UpperByte, W
0x40: MOVLB 0x5
0x41: MOVWF CCPR1
! }
! while (!PIR1bits.TMR2IF);
0x42: MOVLB 0x0
0x43: BTFSS PIR1, 0x1
0x44: GOTO 0x42
! PIR1bits.TMR2IF = 0;
0x45: BCF PIR1, 0x1
 
* If DC1B is ignored, the disassembly is as follows:
* According to the instruction set table, this should take 14 cycles to execute
* 14 cycles corresponds to a maximum of ~357.142 kHz PWM frequency
! // Bit 15
! if (pattern & 0x8000) {
0x26: BTFSS 0x72, 0x7
0x27: GOTO 0x2A
! CCPR1L = computedDutyCycleHigh_UpperByte;
0x28: MOVF computedDutyCycleHigh_UpperByte, W
0x29: GOTO 0x2C
! } else {
! CCPR1L = computedDutyCycleLow_UpperByte;
0x2A: MOVLB 0x0
0x2B: MOVF computedDutyCycleLow_UpperByte, W
0x2C: MOVLB 0x5
0x2D: MOVWF CCPR1
! }
! while (!PIR1bits.TMR2IF);
0x2E: MOVLB 0x0
0x2F: BTFSS PIR1, 0x1
0x30: GOTO 0x2E
! PIR1bits.TMR2IF = 0;
0x31: BCF PIR1, 0x1
*/
 
// Bit 14
if (savedPattern & 0x4000) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 13
if (savedPattern & 0x2000) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 12
if (savedPattern & 0x1000) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 11
if (savedPattern & 0x0800) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 10
if (savedPattern & 0x0400) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 9
if (savedPattern & 0x0200) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 8
if (savedPattern & 0x0100) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 7
if (savedPattern & 0x0080) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 6
if (savedPattern & 0x0040) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 5
if (savedPattern & 0x0020) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 4
if (savedPattern & 0x0010) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 3
if (savedPattern & 0x0008) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 2
if (savedPattern & 0x0004) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 1
if (savedPattern & 0x0002) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Bit 0
if (savedPattern & 0x0001) {
CCP1CONbits.DC1B = computedDutyCycleHigh_LowerBits;
CCPR1L = computedDutyCycleHigh_UpperByte;
} else {
CCP1CONbits.DC1B = computedDutyCycleLow_LowerBits;
CCPR1L = computedDutyCycleLow_UpperByte;
}
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
 
// Set next duty cycle to 0% (idle line low)
CCP1CONbits.DC1B = 0b00;
CCPR1L = 0x00;
 
// Wait for timer to rollover, then turn off timer
while (!PIR1bits.TMR2IF);
PIR1bits.TMR2IF = 0;
T2CONbits.TMR2ON = 0;
TMR2 = 0x0;
}
/PIC Projects/PICX_12F1840_Pulse_Generator/PWM.h
0,0 → 1,17
#ifndef PWM_H
#define PWM_H
 
#include "DEFINES.h"
 
#define PWM_DEFAULT_FREQ 50000
#define PWM_DEFAULT_HIGH_CYCLE 80
#define PWM_DEFAULT_LOW_CYCLE 20
 
void PWM_Init();
void Set_PWM_Frequency(uint32_t frequency);
void Set_PWM_Duty_Cycle(uint8_t highPercent, uint8_t lowPercent);
void Set_PWM_Pattern(uint16_t pattern);
void PWM_Transmit_Pattern();
 
#endif /* PWM_H */
 
/PIC Projects/PICX_12F1840_Pulse_Generator/funclist
0,0 → 1,20
_IOC_Interrupt_Handler: CODE, 1756 0 8
_UART_Read: CODE, 1633 0 33
_IOC_Init: CODE, 1771 0 7
_UART_Init: CODE, 1725 0 18
_UART_Reset_RX: CODE, 1790 0 4
_main: CODE, 621 0 398
_Interrupt_Enable: CODE, 1794 0 3
_Set_PWM_Frequency: CODE, 1236 0 158
_Set_PWM_Duty_Cycle: CODE, 1019 0 217
_InterruptHandler: CODE, 4 0 29
___lmul: CODE, 1542 0 48
_UART_TX_Interrupt_Handler: CODE, 1698 0 27
__initialization: CODE, 35 0 44
_Set_PWM_Pattern: CODE, 1764 0 7
___lldiv: CODE, 1394 0 83
_PWM_Transmit_Pattern: CODE, 83 0 538
_UART_RX_Interrupt_Handler: CODE, 1590 0 43
_UART_Write: CODE, 1477 0 65
_PWM_Init: CODE, 1666 0 32
Total: 1762
/PIC Projects/PICX_12F1840_Pulse_Generator/l.obj
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/PIC Projects/PICX_12F1840_Pulse_Generator/l.obj
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/PIC Projects/PICX_12F1840_Pulse_Generator/main.c
0,0 → 1,120
#include "DEFINES.h"
#include "INTERRUPTS.h"
#include "PWM.h"
#include "IOC.h"
#include "EUSART.h"
 
// <editor-fold defaultstate="collapsed" desc="Configuration Registers">
// CONFIG1
#pragma config FOSC = HS // Oscillator Selection (HS Oscillator, High-speed crystal/resonator connected between OSC1 and OSC2 pins)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = OFF // Internal/External Switchover (Internal/External Switchover mode is disabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)
 
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
// </editor-fold>
 
int main() {
// Initialize oscillator to external crystal (20Mhz)
OSCCONbits.SCS = 0b00;
OSCCONbits.SPLLEN = 0b0;
OSCCONbits.IRCF = 0b1111;
 
// Set all pins to digital I/O
ANSELA = 0x00;
// Disable pull-ups
OPTION_REGbits.nWPUEN = 1;
WPUA = 0x0;
 
// Configure alternate pin function register
APFCONbits.RXDTSEL = 0; // RX on RA1
APFCONbits.TXCKSEL = 0; // TX on RA0
APFCONbits.CCP1SEL = 0; // CCP1 on RA2
// Delay for a bit to ensure oscillator has started
__delay_ms(10);
 
// Configure and enable interrupts
Interrupt_Enable();
 
// Configure and enable peripherals
PWM_Init();
IOC_Init();
UART_Init();
 
uint8_t recvBuffer[32];
uint8_t txOk[] = "Ok!\n";
uint8_t txError[] = "Error!\n";
 
/* Protocol format as follows:
* Byte 0 = OPCODE
* 0x1 = Set frequency
* Bytes 1-4 = 32 bit unsigned value
* 0x2 = Set duty cycle
* Byte 1 = 8 bit unsigned value (high value)
* Byte 2 = 8 bit unsigned value (low value)
* 0x3 = Set pattern
* Bytes 1-2 = 16 bit pattern (transmits MSB first)
* Everything else = nop
*/
 
while(1) {
uint8_t recvBytes = UART_Read(recvBuffer);
if (recvBytes != 0) {
// Process op-code for setting frequency
if (recvBuffer[0] == 0x1 && recvBytes == 5) {
uint32_t byte0 = recvBuffer[1];
byte0 <<= 24;
uint32_t byte1 = recvBuffer[2];
byte1 <<= 16;
uint32_t byte2 = recvBuffer[3];
byte2 <<= 8;
uint32_t freq = 0;
freq |= byte0;
freq |= byte1;
freq |= byte2;
freq |= recvBuffer[4];
// Ensure that received value falls within working bounds
if (freq >= 20000 && freq <= 200000) {
Set_PWM_Frequency(freq);
UART_Write(txOk, 4);
} else {
UART_Write(txError, 7);
}
UART_Reset_RX();
} else if (recvBuffer[0] == 0x2 && recvBytes == 3) {
// Ensure that received value falls within working bounds
if (recvBuffer[1] <= 100 && recvBuffer[2] <= 100) {
Set_PWM_Duty_Cycle(recvBuffer[1], recvBuffer[2]);
UART_Write(txOk, 4);
} else {
UART_Write(txError, 7);
}
UART_Reset_RX();
} else if (recvBuffer[0] == 0x3 && recvBytes == 3) {
uint16_t byte0 = recvBuffer[1];
byte0 <<= 8;
uint16_t pattern = 0;
pattern |= byte0;
pattern |= recvBuffer[2];
Set_PWM_Pattern(pattern);
UART_Reset_RX();
UART_Write(txOk, 4);
} else if (recvBuffer[0] == 0x0 || recvBuffer[0] > 0x03 || recvBytes > 5) {
UART_Reset_RX();
}
}
}
 
}
/PIC Projects/PICX_12F1840_Pulse_Generator/nbproject/Makefile-default.mk
0,0 → 1,207
#
# 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_Pulse_Generator.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
else
IMAGE_TYPE=production
OUTPUT_SUFFIX=hex
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_Pulse_Generator.${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 PWM.c IOC.c INTERRUPTS.c EUSART.c.c
 
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.p1 ${OBJECTDIR}/PWM.p1 ${OBJECTDIR}/IOC.p1 ${OBJECTDIR}/INTERRUPTS.p1 ${OBJECTDIR}/EUSART.c.p1
POSSIBLE_DEPFILES=${OBJECTDIR}/main.p1.d ${OBJECTDIR}/PWM.p1.d ${OBJECTDIR}/IOC.p1.d ${OBJECTDIR}/INTERRUPTS.p1.d ${OBJECTDIR}/EUSART.c.p1.d
 
# Object Files
OBJECTFILES=${OBJECTDIR}/main.p1 ${OBJECTDIR}/PWM.p1 ${OBJECTDIR}/IOC.p1 ${OBJECTDIR}/INTERRUPTS.p1 ${OBJECTDIR}/EUSART.c.p1
 
# Source Files
SOURCEFILES=main.c PWM.c IOC.c INTERRUPTS.c EUSART.c.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}
ifneq ($(INFORMATION_MESSAGE), )
@echo $(INFORMATION_MESSAGE)
endif
${MAKE} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_Pulse_Generator.${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:multilocs --stack=compiled:auto:auto "--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}/PWM.p1: PWM.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/PWM.p1.d
@${RM} ${OBJECTDIR}/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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/PWM.p1 PWM.c
@-${MV} ${OBJECTDIR}/PWM.d ${OBJECTDIR}/PWM.p1.d
@${FIXDEPS} ${OBJECTDIR}/PWM.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/IOC.p1: IOC.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/IOC.p1.d
@${RM} ${OBJECTDIR}/IOC.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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/IOC.p1 IOC.c
@-${MV} ${OBJECTDIR}/IOC.d ${OBJECTDIR}/IOC.p1.d
@${FIXDEPS} ${OBJECTDIR}/IOC.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/INTERRUPTS.p1: INTERRUPTS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/INTERRUPTS.p1.d
@${RM} ${OBJECTDIR}/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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/INTERRUPTS.p1 INTERRUPTS.c
@-${MV} ${OBJECTDIR}/INTERRUPTS.d ${OBJECTDIR}/INTERRUPTS.p1.d
@${FIXDEPS} ${OBJECTDIR}/INTERRUPTS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/EUSART.c.p1: EUSART.c.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/EUSART.c.p1.d
@${RM} ${OBJECTDIR}/EUSART.c.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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/EUSART.c.p1 EUSART.c.c
@-${MV} ${OBJECTDIR}/EUSART.c.d ${OBJECTDIR}/EUSART.c.p1.d
@${FIXDEPS} ${OBJECTDIR}/EUSART.c.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:multilocs --stack=compiled:auto:auto "--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}/PWM.p1: PWM.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/PWM.p1.d
@${RM} ${OBJECTDIR}/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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/PWM.p1 PWM.c
@-${MV} ${OBJECTDIR}/PWM.d ${OBJECTDIR}/PWM.p1.d
@${FIXDEPS} ${OBJECTDIR}/PWM.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/IOC.p1: IOC.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/IOC.p1.d
@${RM} ${OBJECTDIR}/IOC.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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/IOC.p1 IOC.c
@-${MV} ${OBJECTDIR}/IOC.d ${OBJECTDIR}/IOC.p1.d
@${FIXDEPS} ${OBJECTDIR}/IOC.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/INTERRUPTS.p1: INTERRUPTS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/INTERRUPTS.p1.d
@${RM} ${OBJECTDIR}/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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/INTERRUPTS.p1 INTERRUPTS.c
@-${MV} ${OBJECTDIR}/INTERRUPTS.d ${OBJECTDIR}/INTERRUPTS.p1.d
@${FIXDEPS} ${OBJECTDIR}/INTERRUPTS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/EUSART.c.p1: EUSART.c.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/EUSART.c.p1.d
@${RM} ${OBJECTDIR}/EUSART.c.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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -o${OBJECTDIR}/EUSART.c.p1 EUSART.c.c
@-${MV} ${OBJECTDIR}/EUSART.c.d ${OBJECTDIR}/EUSART.c.p1.d
@${FIXDEPS} ${OBJECTDIR}/EUSART.c.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_Pulse_Generator.${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_Pulse_Generator.${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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" --ram=default,-160-16f -odist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_Pulse_Generator.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
@${RM} dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_Pulse_Generator.${IMAGE_TYPE}.hex
else
dist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_Pulse_Generator.${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_Pulse_Generator.${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:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -odist/${CND_CONF}/${IMAGE_TYPE}/PICX_12F1840_Pulse_Generator.${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 Projects/PICX_12F1840_Pulse_Generator/nbproject/Makefile-genesis.properties
0,0 → 1,8
#
#Thu Dec 25 22:06:48 EST 2014
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v1.33\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=f654f11d585cacf70b570c49f2939b4c
default.languagetoolchain.version=1.33
host.platform=windows
conf.ids=default
default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=4e74752607bed54c97e500c96f68559c
/PIC Projects/PICX_12F1840_Pulse_Generator/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_Pulse_Generator
 
# 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 Projects/PICX_12F1840_Pulse_Generator/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_67/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="C:\Program Files (x86)\Microchip\xc8\v1.33\bin\xc8.exe"
# MP_CPPC is not defined
# MP_BC is not defined
MP_AS="C:\Program Files (x86)\Microchip\xc8\v1.33\bin\xc8.exe"
# 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.33\bin"
# MP_CPPC_DIR is not defined
# MP_BC_DIR is not defined
MP_AS_DIR="C:\Program Files (x86)\Microchip\xc8\v1.33\bin"
# MP_LD_DIR is not defined
# MP_AR_DIR is not defined
# MP_BC_DIR is not defined
/PIC Projects/PICX_12F1840_Pulse_Generator/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_Pulse_Generator.production.hex
CND_ARTIFACT_PATH_default=dist/default/production/PICX_12F1840_Pulse_Generator.production.hex
CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package
CND_PACKAGE_NAME_default=picx12f1840pulsegenerator.tar
CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/picx12f1840pulsegenerator.tar
/PIC Projects/PICX_12F1840_Pulse_Generator/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_Pulse_Generator.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
OUTPUT_BASENAME=PICX_12F1840_Pulse_Generator.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
PACKAGE_TOP_DIR=picx12f1840pulsegenerator/
 
# 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}/picx12f1840pulsegenerator/bin
copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
 
 
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/package/picx12f1840pulsegenerator.tar
cd ${TMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/picx12f1840pulsegenerator.tar *
checkReturnCode
 
# Cleanup
cd "${TOP}"
rm -rf ${TMPDIR}
/PIC Projects/PICX_12F1840_Pulse_Generator/nbproject/configurations.xml
0,0 → 1,183
<?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>DEFINES.h</itemPath>
<itemPath>PWM.h</itemPath>
<itemPath>IOC.h</itemPath>
<itemPath>INTERRUPTS.h</itemPath>
<itemPath>EUSART.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>PWM.c</itemPath>
<itemPath>IOC.c</itemPath>
<itemPath>INTERRUPTS.c</itemPath>
<itemPath>EUSART.c.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.33</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
<linkerLibItems>
</linkerLibItems>
</linkerTool>
<archiverTool>
</archiverTool>
<loading>
<useAlternateLoadableFile>false</useAlternateLoadableFile>
<parseOnProdLoad>true</parseOnProdLoad>
<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-invariant-enable" value="false"/>
<property key="optimization-invariant-value" value="16"/>
<property key="optimization-level" value="9"/>
<property key="optimization-set" value="default"/>
<property key="optimization-speed" value="true"/>
<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="true"/>
<property key="memories.configurationmemory" value="true"/>
<property key="memories.configurationmemory2" value="true"/>
<property key="memories.dataflash" value="true"/>
<property key="memories.eeprom" value="true"/>
<property key="memories.flashdata" value="true"/>
<property key="memories.id" value="true"/>
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.end" value="0xfff"/>
<property key="memories.programmemory.partition2" value="true"/>
<property key="memories.programmemory.partition2.end"
value="${memories.programmemory.partition2.end.value}"/>
<property key="memories.programmemory.partition2.start"
value="${memories.programmemory.partition2.start.value}"/>
<property key="memories.programmemory.start" value="0x0"/>
<property key="poweroptions.powerenable" value="true"/>
<property key="programmertogo.imagename" value=""/>
<property key="programoptions.donoteraseauxmem" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.pgmspeed" value="2"/>
<property key="programoptions.preservedataflash" value="false"/>
<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.programcalmem" value="false"/>
<property key="programoptions.programuserotp" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VPPFirst"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="5.0"/>
</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 Projects/PICX_12F1840_Pulse_Generator/nbproject/private/SuppressibleMessageMemo.properties
0,0 → 1,3
#
#Tue Dec 23 16:56:45 EST 2014
pk3/CHECK_4_HIGH_VOLTAGE_VPP=true
/PIC Projects/PICX_12F1840_Pulse_Generator/nbproject/private/configurations.xml
0,0 → 1,25
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<projectmakefile>Makefile</projectmakefile>
<defaultConf>0</defaultConf>
<confs>
<conf name="default" type="2">
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>900A:=&lt;rev>0002:=&lt;man>Microchip Technology Inc.:=&lt;prod>PICkit 3:=&lt;sn>BUR114189291:=&lt;drv>x:=&lt;xpt>h:=end</platformToolSN>
<languageToolchainDir>C:\Program Files (x86)\Microchip\xc8\v1.33\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>
</mdbdebugger>
<runprofile version="6">
<args></args>
<rundir></rundir>
<buildfirst>true</buildfirst>
<console-type>0</console-type>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>
/PIC Projects/PICX_12F1840_Pulse_Generator/nbproject/private/private.properties
--- nbproject/private/private.xml (nonexistent)
+++ nbproject/private/private.xml (revision 342)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?><project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
/PIC Projects/PICX_12F1840_Pulse_Generator/nbproject/project.properties
--- nbproject/project.xml (nonexistent)
+++ nbproject/project.xml (revision 342)
@@ -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_Pulse_Generator</name>
+ <creation-uuid>495ff268-917c-471d-9732-acf0852821c2</creation-uuid>
+ <make-project-type>0</make-project-type>
+ <c-extensions>c</c-extensions>
+ <cpp-extensions/>
+ <header-extensions>h</header-extensions>
+ <asminc-extensions/>
+ <sourceEncoding>ISO-8859-1</sourceEncoding>
+ <make-dep-projects/>
+ </data>
+ </configuration>
+</project>