Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
152 Kevin 1
#include <xc.h>
2
#include <delays.h>
3
#include <stdio.h>
4
#include "defines.h"
5
#include "uart.h"
6
 
7
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">
8
/* --------------------------- Configuration Bits --------------------------- */
9
/* CONFIG1L @ 0x1FFF8 */
10
#pragma config CFGPLLEN = ON        // Enable PLL on startup
11
#pragma config PLLDIV = 3           // Set PPL prescaler to 3 (to get 4MHz)
12
#pragma config WDTEN = OFF          // Turn off watchdog timer
13
#pragma config STVREN = OFF         // Stack overflow/underflow reset disabled
14
#pragma config XINST = OFF          // Turn off extended instruction set
15
 
16
/* CONFIG1H @ 0x1FFF9 */
17
#pragma config CP0 = OFF            // Program memory is not code-protected
18
 
19
/* CONFIG2L @ 0x1FFFA */
20
#pragma config CLKOEC = OFF         // CLKO output disabled on RA6 pin
21
#pragma config SOSCSEL = LOW        // Low Power T1OSC/SOSC circuit selected
22
#pragma config IESO = ON            // Internal external oscillator switch over disabled
23
#pragma config OSC = HSPLL          // Use external oscillator (101)
24
#pragma config FCMEN = OFF          // Fail-safe clock monitor disabled
25
 
26
/* CONFIG2H @ 0x1FFFB */
27
#pragma config WDTPS = 1            // Watchdog postscaler of 1:1
28
 
29
/* CONFIG3L @ 0x1FFFC */
30
#pragma config RTCOSC = T1OSCREF    // RTCC uses T1OSC/T1CKI
31
#pragma config DSBOREN = ON         // Deep sleep BOR enabled
32
#pragma config DSWDTPS = M2         // Deep sleep watchdog postscaler of 1:2 (36m)
33
#pragma config DSWDTEN = OFF        // Deep sleep watchdog timer disabled
34
#pragma config DSWDTOSC = INTOSCREF  // DSWDT clock select uses INTRC
35
 
36
/* CONFIG3H @ 0x1FFFD */
37
#pragma config PLLSEL = PLL96       // Use 96MHz PLL 4MHz -> 96MHz / 2 = 48MHz
38
#pragma config ADCSEL = BIT12       // 12-bit ADC
39
#pragma config MSSP7B_EN = MSK7     // 7-bit address masking mode
40
#pragma config IOL1WAY = OFF        // IOLOCK bit can be set and cleared as needed
41
 
42
/* CONFIG4L @ 0x1FFFE */
43
#pragma config WPCFG = ON           // Configuration words page protected
44
 
45
/* CONFIG4H @ 0x1FFFF */
46
#pragma config WPEND = PAGE_WPFP    // Pages WPFP<6:0> through Configuration Words erase/write protected
47
#pragma config WPDIS = OFF          // WPFP<6:0>/WPEND region ignored
48
/* -------------------------------------------------------------------------- */
49
// </editor-fold>
50
 
51
#if  defined(_TEST_UART)
52
int main() {
53
    char buffer[100];
54
    buffer[0] = 1;
55
    unsigned char length = 12345;
56
    unsigned char buffer[100];
57
    float f = 3.1415;
58
 
59
    /* --------------------- Oscillator Configuration --------------------- */
60
    //    OSCTUNEbits.PLLEN = 1;          // Enable 4x PLL
61
    OSCCONbits.IRCF = 0b111; // Set INTOSC postscaler to 8MHz
62
    OSCCONbits.SCS = 0b00; // Use 96MHz PLL as primary clock source
63
    /* -------------------------------------------------------------------- */
64
 
65
    // Set all ports as digial I/O
66
    ANCON0 = 0xFF;
67
    ANCON1 = 0x1F;
68
 
69
    UART1_Init(); // Initialize the UART handler code
70
 
71
//    interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
72
//    interrupt_init(); // Initialize the interrupt priorities
73
 
74
//    DBG_PRINT_MAIN("\r\nBegin Program\r\n");
75
//    DBG_PRINT_MAIN("%d\r\n", length);
76
//    printf("asf\r\n");
77
 
78
    while (1) {
79
 
80
//        length = UART1_Read_Buffer((unsigned char *) buffer);
81
//        if (length != 0) {
82
//            UART1_WriteB((char *) buffer, length);
83
//        }
84
//
85
//        Delay10KTCYx(255);
86
//        Delay10KTCYx(255);
87
    }
88
}
89
#elif defined(_TEST_I2C_MASTER)
90
int main() {
91
    char buffer[100];
92
    buffer[0] = 1;
93
}
94
#else
95
int main() {
96
    char buffer[255];
97
    char buffer1[255];
98
    char buffer2[255];
99
    char buffer3[255];
100
    char buffer4[255];
101
    char buffer5[255];
102
    char buffer6[255];
103
    char buffer7[255];
104
    char buffer8[255];
105
    char buffer9[255];
106
    char buffer10[255];
107
    char buffer11[255];
108
    char buffer12[100];
109
    char buffer13[100];
110
    char buffer14[50];
111
    char buffer15[50];
112
    char buffer16[50];
113
    char buffer17[40];
114
    char buffer18[20];
115
    buffer[0] = 1;
116
    buffer1[0] = 1;
117
    buffer2[0] = 1;
118
    buffer3[0] = 1;
119
    buffer4[0] = 1;
120
    buffer5[0] = 1;
121
    buffer6[0] = 1;
122
    buffer7[0] = 1;
123
    buffer8[0] = 1;
124
    buffer9[0] = 1;
125
    buffer10[0] = 1;
126
    buffer11[0] = 1;
127
    buffer12[0] = 1;
128
    buffer13[0] = 1;
129
    buffer14[0] = 1;
130
    buffer15[0] = 1;
131
    buffer16[0] = 1;
132
    buffer17[0] = 1;
133
    buffer18[0] = 1;
134
}
135
#endif
136
 
137
void putch(char data) {
138
    while (!TXIF)
139
        continue;
140
    TXREG = data;
141
}