root/RF_BT_Tail/mcc_generated_files/pwm3.c

Revision 244, 4.4 kB (checked in by phil, 4 years ago)

added initial Tail Source Package

Line 
1 /**
2   PWM3 Generated Driver File
3
4   @Company
5     Microchip Technology Inc.
6
7   @File Name
8     pwm3.c
9
10   @Summary
11     This is the generated driver implementation file for the PWM3 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12
13   @Description
14     This header file provides implementations for driver APIs for PWM3.
15     Generation Information :
16         Product Revision  :  PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17         Device            :  PIC16F1579
18         Driver Version    :  2.01
19     The generated drivers are tested against the following:
20         Compiler          :  XC8 1.45 or later
21         MPLAB             :  MPLAB X 4.15
22 */
23
24 /*
25     (c) 2018 Microchip Technology Inc. and its subsidiaries.
26    
27     Subject to your compliance with these terms, you may use Microchip software and any
28     derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29     license terms applicable to your use of third party software (including open source software) that
30     may accompany Microchip software.
31    
32     THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33     EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34     IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35     FOR A PARTICULAR PURPOSE.
36    
37     IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38     INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39     WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40     HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41     THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42     CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43     OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44     SOFTWARE.
45 */
46
47 /**
48   Section: Included Files
49 */
50
51 #include <xc.h>
52 #include "pwm3.h"
53
54 /**
55   Section: PWM3 APIs
56 */
57
58 void PWM3_Initialize(void)
59 {
60     // set the PWM3 to the options selected in the User Interface
61
62      //PHIE disabled; DCIE disabled; OFIE disabled; PRIE disabled;
63     PWM3INTE = 0x00;
64
65      //PHIF cleared; OFIF cleared; DCIF cleared; PRIF cleared;
66     PWM3INTF = 0x00;
67
68      //PS No_Prescalar; CS FOSC;
69     PWM3CLKCON = 0x00;
70
71      //LDS LD1_trigger; LDT disabled; LDA do_not_load;
72     PWM3LDCON = 0x00;
73
74      //OFM independent_run; OFS OF1_match; OFO match_incrementing;
75     PWM3OFCON = 0x00;
76
77      //PWM3PHH 0;
78     PWM3PHH = 0x00;
79
80      //PWM3PHL 0;
81     PWM3PHL = 0x00;
82
83      //PWM3DCH 0;
84     PWM3DCH = 0x00;
85
86      //PWM3DCL 80;
87     PWM3DCL = 0x50;
88
89      //PWM3PRH 31;
90     PWM3PRH = 0x1F;
91
92      //PWM3PRL 64;
93     PWM3PRL = 0x40;
94
95      //PWM3OFH 0;
96     PWM3OFH = 0x00;
97
98      //PWM3OFL 1;
99     PWM3OFL = 0x01;
100
101      //PWM3TMRH 0;
102     PWM3TMRH = 0x00;
103
104      //PWM3TMRL 0;
105     PWM3TMRL = 0x00;
106
107      //MODE standard_PWM; POL active_hi; EN enabled;
108     PWM3CON = 0x80;
109
110 }   
111
112
113 void PWM3_Start(void)
114 {
115     PWM3CONbits.EN = 1;         
116 }
117
118 void PWM3_Stop(void)
119 {
120     PWM3CONbits.EN = 0;         
121 }
122
123 bool PWM3_CheckOutputStatus(void)
124 {
125     return (PWM3CONbits.OUT);           
126 }
127
128 void PWM3_LoadBufferSet(void)
129 {
130     PWM3LDCONbits.LDA = 1;             
131 }
132
133 void PWM3_PhaseSet(uint16_t phaseCount)
134 {
135     PWM3PHH = (phaseCount>>8);        //writing 8 MSBs to PWMPHH register
136     PWM3PHL = (phaseCount);           //writing 8 LSBs to PWMPHL register
137 }
138
139 void PWM3_DutyCycleSet(uint16_t dutyCycleCount)
140 {
141     PWM3DCH = (dutyCycleCount>>8);      //writing 8 MSBs to PWMDCH register
142     PWM3DCL = (dutyCycleCount); //writing 8 LSBs to PWMDCL register             
143 }
144
145 void PWM3_PeriodSet(uint16_t periodCount)
146 {
147     PWM3PRH = (periodCount>>8); //writing 8 MSBs to PWMPRH register
148     PWM3PRL = (periodCount);    //writing 8 LSBs to PWMPRL register             
149 }
150
151 void PWM3_OffsetSet(uint16_t offsetCount)
152 {
153     PWM3OFH = (offsetCount>>8); //writing 8 MSBs to PWMOFH register
154     PWM3OFL = (offsetCount);    //writing 8 LSBs to PWMOFL register             
155 }
156
157 uint16_t PWM3_TimerCountGet(void)
158 {
159     return ((uint16_t)((PWM3TMRH<<8) | PWM3TMRL));                     
160 }
161
162 bool PWM3_IsOffsetMatchOccured(void)
163 {
164     return (PWM3INTFbits.OFIF);         
165 }
166
167 bool PWM3_IsPhaseMatchOccured(void)
168 {
169     return (PWM3INTFbits.PHIF);
170 }
171
172 bool PWM3_IsDutyCycleMatchOccured(void)
173 {
174     return (PWM3INTFbits.DCIF);         
175 }
176
177 bool PWM3_IsPeriodMatchOccured(void)
178 {
179     return (PWM3INTFbits.PRIF);         
180 }
181
182 /**
183  End of File
184 */
185
186
Note: See TracBrowser for help on using the browser.