Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 151 → Rev 152

/PIC Stuff/PICX_27J13/main.c
0,0 → 1,141
#include <xc.h>
#include <delays.h>
#include <stdio.h>
#include "defines.h"
#include "uart.h"
 
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">
/* --------------------------- Configuration Bits --------------------------- */
/* CONFIG1L @ 0x1FFF8 */
#pragma config CFGPLLEN = ON // Enable PLL on startup
#pragma config PLLDIV = 3 // Set PPL prescaler to 3 (to get 4MHz)
#pragma config WDTEN = OFF // Turn off watchdog timer
#pragma config STVREN = OFF // Stack overflow/underflow reset disabled
#pragma config XINST = OFF // Turn off extended instruction set
 
/* CONFIG1H @ 0x1FFF9 */
#pragma config CP0 = OFF // Program memory is not code-protected
 
/* CONFIG2L @ 0x1FFFA */
#pragma config CLKOEC = OFF // CLKO output disabled on RA6 pin
#pragma config SOSCSEL = LOW // Low Power T1OSC/SOSC circuit selected
#pragma config IESO = ON // Internal external oscillator switch over disabled
#pragma config OSC = HSPLL // Use external oscillator (101)
#pragma config FCMEN = OFF // Fail-safe clock monitor disabled
 
/* CONFIG2H @ 0x1FFFB */
#pragma config WDTPS = 1 // Watchdog postscaler of 1:1
 
/* CONFIG3L @ 0x1FFFC */
#pragma config RTCOSC = T1OSCREF // RTCC uses T1OSC/T1CKI
#pragma config DSBOREN = ON // Deep sleep BOR enabled
#pragma config DSWDTPS = M2 // Deep sleep watchdog postscaler of 1:2 (36m)
#pragma config DSWDTEN = OFF // Deep sleep watchdog timer disabled
#pragma config DSWDTOSC = INTOSCREF // DSWDT clock select uses INTRC
 
/* CONFIG3H @ 0x1FFFD */
#pragma config PLLSEL = PLL96 // Use 96MHz PLL 4MHz -> 96MHz / 2 = 48MHz
#pragma config ADCSEL = BIT12 // 12-bit ADC
#pragma config MSSP7B_EN = MSK7 // 7-bit address masking mode
#pragma config IOL1WAY = OFF // IOLOCK bit can be set and cleared as needed
 
/* CONFIG4L @ 0x1FFFE */
#pragma config WPCFG = ON // Configuration words page protected
 
/* CONFIG4H @ 0x1FFFF */
#pragma config WPEND = PAGE_WPFP // Pages WPFP<6:0> through Configuration Words erase/write protected
#pragma config WPDIS = OFF // WPFP<6:0>/WPEND region ignored
/* -------------------------------------------------------------------------- */
// </editor-fold>
 
#if defined(_TEST_UART)
int main() {
char buffer[100];
buffer[0] = 1;
unsigned char length = 12345;
unsigned char buffer[100];
float f = 3.1415;
 
/* --------------------- Oscillator Configuration --------------------- */
// OSCTUNEbits.PLLEN = 1; // Enable 4x PLL
OSCCONbits.IRCF = 0b111; // Set INTOSC postscaler to 8MHz
OSCCONbits.SCS = 0b00; // Use 96MHz PLL as primary clock source
/* -------------------------------------------------------------------- */
 
// Set all ports as digial I/O
ANCON0 = 0xFF;
ANCON1 = 0x1F;
 
UART1_Init(); // Initialize the UART handler code
 
// interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
// interrupt_init(); // Initialize the interrupt priorities
 
// DBG_PRINT_MAIN("\r\nBegin Program\r\n");
// DBG_PRINT_MAIN("%d\r\n", length);
// printf("asf\r\n");
 
while (1) {
 
// length = UART1_Read_Buffer((unsigned char *) buffer);
// if (length != 0) {
// UART1_WriteB((char *) buffer, length);
// }
//
// Delay10KTCYx(255);
// Delay10KTCYx(255);
}
}
#elif defined(_TEST_I2C_MASTER)
int main() {
char buffer[100];
buffer[0] = 1;
}
#else
int main() {
char buffer[255];
char buffer1[255];
char buffer2[255];
char buffer3[255];
char buffer4[255];
char buffer5[255];
char buffer6[255];
char buffer7[255];
char buffer8[255];
char buffer9[255];
char buffer10[255];
char buffer11[255];
char buffer12[100];
char buffer13[100];
char buffer14[50];
char buffer15[50];
char buffer16[50];
char buffer17[40];
char buffer18[20];
buffer[0] = 1;
buffer1[0] = 1;
buffer2[0] = 1;
buffer3[0] = 1;
buffer4[0] = 1;
buffer5[0] = 1;
buffer6[0] = 1;
buffer7[0] = 1;
buffer8[0] = 1;
buffer9[0] = 1;
buffer10[0] = 1;
buffer11[0] = 1;
buffer12[0] = 1;
buffer13[0] = 1;
buffer14[0] = 1;
buffer15[0] = 1;
buffer16[0] = 1;
buffer17[0] = 1;
buffer18[0] = 1;
}
#endif
 
void putch(char data) {
while (!TXIF)
continue;
TXREG = data;
}