-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainxc16_header.h
149 lines (116 loc) · 5.93 KB
/
mainxc16_header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* Microchip Technology Inc. and its subsidiaries. You may use this software
* and any derivatives exclusively with Microchip products.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
* WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
* IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
* ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
* TERMS.
*/
/*
* File:
* Author:
* Comments:
* Revision history:
*/
// This is a guard condition so that contents of this file are not included
// more than once.
//#ifndef XC_HEADER_TEMPLATE_H
//#define XC_HEADER_TEMPLATE_H
#ifndef MAINXC16_HEADER_H
#define MAINXC16_HEADER_H
//#pragma once
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// DSPIC33FJ128GP802 Configuration Bit Settings
// 'C' source line config statements
// FBS /**/
#pragma config BWRP = WRPROTECT_OFF // Boot Segment Write Protect (Boot Segment may be written)
#pragma config BSS = NO_FLASH // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
#pragma config RBS = NO_RAM // Boot Segment RAM Protection (No Boot RAM)
// FSS
#pragma config SWRP = WRPROTECT_OFF // Secure Segment Program Write Protect (Secure segment may be written)
#pragma config SSS = NO_FLASH // Secure Segment Program Flash Code Protection (No Secure Segment)
#pragma config RSS = NO_RAM // Secure Segment Data RAM Protection (No Secure RAM)
// FGS
#pragma config GWRP = OFF // General Code Segment Write Protect (User program memory is not write-protected)
#pragma config GSS = OFF // General Segment Code Protection (User program memory is not code-protected)
// FOSCSEL
#pragma config FNOSC = FRC //FRCPLL // Internal Fast RC (FRC) //=PRI// Oscillator Mode (Primary Oscillator (XT, HS, EC)) //åñòü åùå PRIPLL Fosc with PLL.
#pragma config IESO = OFF // Internal External Switch Over Mode OFF-(Start-up device with FRC, then automatically switch to user-selected oscillator source when ready)
// FOSC
#pragma config POSCMD = NONE// // Primary Oscillator Source (HS Oscillator Mode)
#pragma config OSCIOFNC = OFF // OSC2 Pin Function (OSC2 pin has clock out function)
#pragma config IOL1WAY = OFF // Peripheral Pin Select Configuration (Allow Only One Re-configuration)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor (Clock switching is enabled, Fail-Safe Clock Monitor is disabled) - ýòî êàê ðàç ïîìîãëî, ïåðåêëþ÷åíèþ ãåíåðàòîðà. //ðàíüøå áûë CSDCMD
// FWDT
#pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler (1:32,768)
#pragma config WDTPRE = PR128 // WDT Prescaler (1:128)
#pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software)
// FPOR
#pragma config FPWRT = PWR128 // POR Timer Value (128ms)
#pragma config ALTI2C = OFF // Alternate I2C pins (I2C mapped to SDA1/SCL1 pins)
// FICD
#pragma config ICS = PGD2 // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is Disabled)
/**/
//#define _XTAL_FREQ 55000000
#define _XTAL_FREQ 16000000
//#define _XTAL_FREQ 4000000
#include <xc.h> // include processor files - each processor file is guarded.
//#include <libpic30.h>
#include <adc.h>
#include <spi.h>
#include <uart.h>
#include <timer.h>
#include <pps.h>
//#include "LIBs/GeneralElectronix16bit_osm.h"
#include "LIBs/ads8681_for16bitmcu_osm.h"
//#include <stdio.h>
//#include <stdlib.h>
////---------------------------------//My macros//---------------------------------/
//#define osm_ConvertADC1() ( AD1CON1bits.SAMP = 0 /* clear SAMP bit to start conversion */)
//#define osm_SetChanADC1(channel0andVrefN) (AD1CHS0 = channel0andVrefN)
//#define osm_BusyADC1() (!AD1CON1bits.DONE) //Çàðàáîòàåò ëè? Äà!
#define osm_Timer3ON() (T3CONbits.TON = 1)
#define osm_Timer3OFF() (T3CONbits.TON = 0)
////---------------------------------/////////////---------------------------------/
// TODO Insert appropriate #include <>
// TODO Insert C++ class definitions if appropriate
// TODO Insert declarations
// Comment a function and leverage automatic documentation with slash star star
/**
<p><b>Function prototype:</b></p>
<p><b>Summary:</b></p>
<p><b>Description:</b></p>
<p><b>Precondition:</b></p>
<p><b>Parameters:</b></p>
<p><b>Returns:</b></p>
<p><b>Example:</b></p>
<code>
</code>
<p><b>Remarks:</b></p>
*/
// TODO Insert declarations or function prototypes (right here) to leverage
// live documentation
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// TODO If C++ is being used, regular C code needs function names to have C
// linkage so the functions can be used by the c code.
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* XC_HEADER_TEMPLATE_H */