-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.c
More file actions
52 lines (43 loc) · 1.34 KB
/
Copy pathmain.c
File metadata and controls
52 lines (43 loc) · 1.34 KB
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
/*
* main.c
*
* Created on: 21/03/2018
* Author: Joao Luis Torre Manso
* University: Minho
*/
#include <string.h>
#include "System/inc/System.h"
#include "SAPF/inc/SAPF_Control.h"
volatile Uint16 timer0_flag = 0;
volatile Uint16 xInt3_flag = 0;
volatile Uint16 pre_charge_flag = 0; //-> optional
volatile unsigned char rx_data = 0;
volatile int16 enable = 0;
volatile Uint16 error = ALL_OK; //-> optional
volatile Uint16 detectedError = ALL_OK; //-> optional
void main(void)
{
ConfigSystem();
CpuTimer0Regs.TCR.bit.TSS = 0; //Start Timer0
GpioDataRegs.GPBSET.bit.GPIO48 = 1;
GpioDataRegs.GPBCLEAR.bit.GPIO49 = 1;
memset((void*)DC_Voltage, 0, BUFFERSIZE);
memset((void*)Grid_Voltage, 0, BUFFERSIZE >> 0x01);
ClearStructVariables();
Calculation_KI_Max();
ADC1_WakeUpSignal();
for(;;){
if(timer0_flag){
timer0_flag = 0;
ADC1_StartConversionSignal();
}
if(xInt3_flag){
xInt3_flag = 0;
ADC1_SaveData();
}
//Check if there is no error and the enable triggered by the error is different of -1 (enable value to interrupt the PWM pulses)
if(error == ALL_OK && enable != -1){
SAPFControl();
}
}
}