Can anyone please advise?
I am modifying some code that I was send for a clock timer. The original code activated a solenoid every minute. I have added code to activate a solenoid every second as well. My additional code is towards the bottom, highlighted in yellow. I am using an existing element of code in this, if (WDTticks >= WDticksPerSecond), but get the error that this is undeclared. In the original build, there were no errors.
I have pasted the code below, along with the error. Can anyone guide me as to what Ihave done wrong?
Thank you.
/*
* ======== Standard MSP430 includes ========
*/
#include <msp430.h>
/*
* ======== Grace related includes ========
*/
/*#include <ti/mcu/msp430/Grace.h> This is the original entry
*/
#include <ti/mcu/msp430/csl/CSL.h> // Imported from project
/*
* ======== Definitions and variables ========
*/
#define RedLED (BIT0) // Red LED on the LaunchPad (LEDs used during debug)
#define GreenLED (BIT6) // Green LED on the LaunchPad
#define Coil (BIT2) // Port 1 Bit 2 is high-active to the base of an NPN coil driver transistor
#define TestMode (BIT3) // Jumper to ground puts the circuit into Test Mode
// Test Mode runs the coil at a faster than normal rate to check out a newly-built clock
#define WDticksPerSecond 64 // Number of Watchdog Timer ticks (interrupts) per second
// The coil is initially turned on at partial power, then power is increased in increments every 15.2 mS to 100% power.
// Total on time is 155 mS and average power is 85%.
#define PWM_bump 25 // incremental PWM value (2.5%)
#define PWM_init 700 // initial PWM value (70% power)
#define PWM_full 1000 // full power PWM value 100%
#define Finger_Tapper // THIS IS NEWLY ADDED
unsigned int WDTticks = 0; // count of Watchdog Timer (interval timer) interrupt service calls
unsigned int seconds = 0; // elapsed seconds counted from WDTticks
unsigned int PWM; // percent of time to turn on the coil. 1000 = 100%.
void WDTISRHandler(void)
{
/*
// If the Port Selection Register bit is active, the Timer A2 PWM output is connected to the port pin and the coil is on.
*/
if (P1SEL & Coil) // is the coil on or off?
{
// The coil is on - ramp up the PWM percentage at each Watchdog Timer tick
CCR1 += PWM_bump; //increase the PWM percent a modest amount
if (CCR1 >= PWM_full) // are we at full power?
{
P1SEL &= ~Coil; // yes, turn off the coil
}
}
WDTticks++; // count the number of Watchdog Timer ticks to keep basic time
if (WDTticks >= WDticksPerSecond)
{
seconds++; // count seconds
// once per minute in Normal mode, once per second in Test mode
if ((seconds >= 60) | (((P1IN & TestMode) == 0) & (seconds)) )
{
seconds = 0; // reset the seconds count
CCR1 = PWM_init; // set the PWM to initial value
P1SEL |= Coil; // turn the coil on
}
WDTticks = 0; // reset the Watchdog Timer ticks counter
}
}
// THIS IS NEWLY ADDED
if (WDTticks >= WDticksPerSecond)
{
Finger_Tapper = 1 // EACH SECOND SETS THIS VARIABLE TO 1. THIS IS THEN USED TO ACTIVATE A SOLENOID
}
If (Finger_Tapper =1)
{
P1SEL |= Coil; // turn the coil on
}
Finger_Tapper = 0
}
}
//END OF NEWLY ADDED CODE
/*
* ======== main ========
*/
int main(int argc, char *argv[])
{
CSL_init(); // Activate Grace-generated configuration
_BIS_SR(LPM0_bits); // Enter Low-power mode and wait for interrupts
return (0);
}
**** Build of configuration Debug for project Test ****
"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
making ../src/grace/grace.lib ...
gmake[1]: Entering directory `C:/Users/James/workspace_v6_1/Test/src/grace'
gmake[1]: Nothing to be done for `all'.
gmake[1]: Leaving directory `C:/Users/James/workspace_v6_1/Test/src/grace'
'Building file: ../main.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.4/bin/cl430" -vmsp --abi=eabi --use_hw_mpy=none --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.4/include" --advice:power=all -g --define=__MSP430G2211__ --diag_warning=225 --display_error_number --diag_wrap=off --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" --cmd_file="./configPkg/compiler.opt" "../main.c"
"../main.c", line 70: error #171: expected a declaration
At end of source: warning #12-D: parsing restarts here after previous syntax error
1 error detected in the compilation of "../main.c".
>> Compilation failure
gmake: *** [main.obj] Error 1
gmake: Target `all' not remade because of errors.
**** Build Finished ****