Skip to content

Commit ce521f7

Browse files
author
srinivasa K R
committed
MPAE-7470 : Project is added to BB repo
1 parent 50bd3a3 commit ce521f7

File tree

24 files changed

+23588
-0
lines changed

24 files changed

+23588
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#
2+
# There exist several targets which are by default empty and which can be
3+
# used for execution of your targets. These targets are usually executed
4+
# before and after some main targets. They are:
5+
#
6+
# .build-pre: called before 'build' target
7+
# .build-post: called after 'build' target
8+
# .clean-pre: called before 'clean' target
9+
# .clean-post: called after 'clean' target
10+
# .clobber-pre: called before 'clobber' target
11+
# .clobber-post: called after 'clobber' target
12+
# .all-pre: called before 'all' target
13+
# .all-post: called after 'all' target
14+
# .help-pre: called before 'help' target
15+
# .help-post: called after 'help' target
16+
#
17+
# Targets beginning with '.' are not intended to be called on their own.
18+
#
19+
# Main targets can be executed directly, and they are:
20+
#
21+
# build build a specific configuration
22+
# clean remove built files from a configuration
23+
# clobber remove all built files
24+
# all build all configurations
25+
# help print help mesage
26+
#
27+
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28+
# .help-impl are implemented in nbproject/makefile-impl.mk.
29+
#
30+
# Available make variables:
31+
#
32+
# CND_BASEDIR base directory for relative paths
33+
# CND_DISTDIR default top distribution directory (build artifacts)
34+
# CND_BUILDDIR default top build directory (object files, ...)
35+
# CONF name of current configuration
36+
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
37+
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
38+
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
39+
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
40+
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
41+
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
42+
#
43+
# NOCDDL
44+
45+
46+
# Environment
47+
MKDIR=mkdir
48+
CP=cp
49+
CCADMIN=CCadmin
50+
RANLIB=ranlib
51+
52+
53+
# build
54+
build: .build-post
55+
56+
.build-pre:
57+
# Add your pre 'build' code here...
58+
59+
.build-post: .build-impl
60+
# Add your post 'build' code here...
61+
62+
63+
# clean
64+
clean: .clean-post
65+
66+
.clean-pre:
67+
# Add your pre 'clean' code here...
68+
# WARNING: the IDE does not call this target since it takes a long time to
69+
# simply run make. Instead, the IDE removes the configuration directories
70+
# under build and dist directly without calling make.
71+
# This target is left here so people can do a clean when running a clean
72+
# outside the IDE.
73+
74+
.clean-post: .clean-impl
75+
# Add your post 'clean' code here...
76+
77+
78+
# clobber
79+
clobber: .clobber-post
80+
81+
.clobber-pre:
82+
# Add your pre 'clobber' code here...
83+
84+
.clobber-post: .clobber-impl
85+
# Add your post 'clobber' code here...
86+
87+
88+
# all
89+
all: .all-post
90+
91+
.all-pre:
92+
# Add your pre 'all' code here...
93+
94+
.all-post: .all-impl
95+
# Add your post 'all' code here...
96+
97+
98+
# help
99+
help: .help-post
100+
101+
.help-pre:
102+
# Add your pre 'help' code here...
103+
104+
.help-post: .help-impl
105+
# Add your post 'help' code here...
106+
107+
108+
109+
# include project implementation makefile
110+
include nbproject/Makefile-impl.mk
111+
112+
# include project make variables
113+
include nbproject/Makefile-variables.mk
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#include "application.h"
2+
3+
void ADCC_SetChannel(adcc_channel_t channel) {
4+
// select the A/D channel
5+
ADPCH = channel;
6+
}
7+
8+
void ApplicationTask (void) {
9+
// change the ADCC modes based on button press
10+
switch(count) {
11+
case BASIC_MODE:
12+
if(!basicModeInit) {
13+
// stop the timer and configure it to 10ms for ADC auto conversion
14+
TMR0_StopTimer();
15+
TMR0_Reload(TIMER0_10ms);
16+
// turn off both LEDs
17+
LED_D3_SetLow();
18+
LED_D2_SetLow();
19+
// initialize ADC in basic mode with potentiometer as input
20+
ADCC_Initialize_BasicMode();
21+
ADCC_SetChannel(POT_DATA);
22+
// start Timer which in turn starts ADC conversion
23+
TMR0_StartTimer();
24+
basicModeInit = true;
25+
} else {
26+
// if ADC conversion is ready, print the data on serial port
27+
if(adcReadyFlag) {
28+
adcReadyFlag = false;
29+
printf ("Basic Mode - ADRES=%d \r\n", ADRES);
30+
}
31+
}
32+
break;
33+
case AVG_MODE:
34+
if(!avgModeInit) {
35+
// stop the timer
36+
TMR0_StopTimer();
37+
// turn on LED 1
38+
LED_D3_SetLow();
39+
LED_D2_SetHigh();
40+
// initialize ADC in average mode with potentiometer as input
41+
ADCC_Initialize_AverageMode();
42+
ADCC_SetChannel(POT_DATA);
43+
// start Timer which in turn starts ADC conversion
44+
TMR0_StartTimer();
45+
avgModeInit = true;
46+
basicModeInit = false;
47+
} else {
48+
// if ADC value is within threshold limits, print the actual value
49+
if(adcReadyFlag) {
50+
adcReadyFlag = false;
51+
printf ("AVG Mode - ADFLT=%d \r\n", ADFLTR);
52+
}
53+
// check if upper threshold is crossed
54+
if(ADCC_HasErrorCrossedUpperThreshold()) {
55+
printf ("AVG Mode - ADFLT=%d - SP=%d - UT=%d - UT Crossed\r\n", ADFLTR,ADSTPT,ADUTH);
56+
// check if lower threshold is crossed
57+
} else if(ADCC_HasErrorCrossedLowerThreshold()) {
58+
printf ("AVG Mode - ADFLT=%d - SP=%d - LT=%d - LT Crossed\r\n", ADFLTR,ADSTPT,ADLTH);
59+
}
60+
}
61+
break;
62+
case BURST_AVG_MODE:
63+
if(!burstAvgModeInit) {
64+
// stop the timer
65+
TMR0_StopTimer();
66+
// turn on LED 2
67+
LED_D3_SetHigh();
68+
LED_D2_SetLow();
69+
// initialize ADC in burst average mode with potentiometer as input
70+
ADCC_Initialize_BurstAverageMode();
71+
ADCC_SetChannel(POT_DATA);
72+
// start Timer which in turn starts ADC conversion
73+
TMR0_StartTimer();
74+
burstAvgModeInit = true;
75+
avgModeInit = false;
76+
} else {
77+
// if ADC value is within threshold limits, print the actual value
78+
if(adcReadyFlag) {
79+
adcReadyFlag = false;
80+
printf ("Burst AVG Mode - ADFLT=%d \r\n", ADFLTR);
81+
}
82+
// check if upper threshold is crossed
83+
if(ADCC_HasErrorCrossedUpperThreshold()) {
84+
printf ("Burst AVG Mode - ADFLT=%d - SP=%d - UT=%d - UT Crossed\r\n", ADFLTR,ADSTPT,ADUTH);
85+
// check if lower threshold is crossed
86+
} else if(ADCC_HasErrorCrossedLowerThreshold()) {
87+
printf ("Burst AVG Mode - ADFLT=%d - SP=%d - LT=%d - LT Crossed\r\n", ADFLTR,ADSTPT,ADLTH);
88+
}
89+
}
90+
break;
91+
case LPF_MODE:
92+
if(!lpfModeInit) {
93+
// stop the timer and configure it to 1ms for ADC auto conversion
94+
TMR0_StopTimer();
95+
TMR0_Reload(TIMER0_1ms);
96+
// turn on both LEDs
97+
LED_D3_SetHigh();
98+
LED_D2_SetHigh();
99+
// initialize ADC in low pass filter mode with DC offset having noise as input
100+
ADCC_Initialize_LowPassFilterMode();
101+
ADCC_SetChannel(FG_DATA);
102+
// start Timer which in turn starts ADC conversion
103+
TMR0_StartTimer();
104+
lpfModeInit = true;
105+
burstAvgModeInit = false;
106+
} else {
107+
// send the low pass filter value to the data visualizer
108+
if(adcReadyFlag) {
109+
adcReadyFlag = false;
110+
EUSART1_Write(0x03);
111+
EUSART1_Write(ADRESL); // Visualizer reads low byte first
112+
EUSART1_Write(ADRESH); // Then reads the high byte// These are commands sent to the Data Visualizer, 0x03 = Start
113+
EUSART1_Write(ADFLTRL); // Visualizer reads low byte first
114+
EUSART1_Write(ADFLTRH); // Then reads the high byte
115+
EUSART1_Write(0xFC); // Stop command
116+
}
117+
}
118+
break;
119+
default:
120+
count = BASIC_MODE;
121+
lpfModeInit = false;
122+
break;
123+
}
124+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* File: application.h
3+
* Author: I16092
4+
*
5+
* Created on May 22, 2018, 7:54 PM
6+
*/
7+
8+
#ifndef APPLICATION_H
9+
#define APPLICATION_H
10+
11+
#include "mcc_generated_files/pin_manager.h"
12+
#include "mcc_generated_files/tmr0.h"
13+
#include "mcc_generated_files/eusart1.h"
14+
#include "mcc_generated_files/adcc.h"
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
21+
// global variables
22+
volatile uint8_t count = 0;
23+
volatile bool adcReadyFlag = false;
24+
volatile bool basicModeInit = false;
25+
volatile bool avgModeInit = false;
26+
volatile bool burstAvgModeInit = false;
27+
volatile bool lpfModeInit = false;
28+
29+
// #define
30+
#define BASIC_MODE 0
31+
#define AVG_MODE 1
32+
#define BURST_AVG_MODE 2
33+
#define LPF_MODE 3
34+
35+
#define TIMER0_10ms 0x13
36+
#define TIMER0_1ms 0x01
37+
38+
// set the analog channel for ADCC
39+
void ADCC_SetChannel(adcc_channel_t channel);
40+
41+
// application task
42+
void ApplicationTask(void);
43+
44+
45+
#ifdef __cplusplus
46+
}
47+
#endif
48+
49+
#endif /* APPLICATION_H */
50+

0 commit comments

Comments
 (0)