online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "step.h" int main () { printf ("Hello World"); int arr[2][10] = { {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, {20, 10, 10, 10, 22, 22, 22, 22, 22, 30} }; int *ptr = &arr[0][0]; return 0; } void FillSmoothPointSection (int *temperature, int *currentStep) { // Smooth-point array handling int index; int iLastTemperature; int iPercent; if (Scanner.SmoothPoints.iSizeLastMaxSamples == 0 && Scanner.SmoothPoints.iSizeSectionSamples == 0) { // initial write to first cell of max array WriteToScannerSamplesArray (temperature, currentStep); return; } // Check scanner step and temperature sample consistency index = Scanner.SmoothPoints.iSizeLastMaxSamples + Scanner.SmoothPoints.iSizeSectionSamples - 1; // index last value if (index >= STEP_MOTOR_MAX_POSITION) { // Error index - out of the scanning range return; } // temperature last value iLastTemperature = Scanner.SmoothPoints.SmoothPoints[index].iTemperature; iPercent = (iLastTemperature / 100); // default 1 if (abs (temperature - iLastTemperature) < iPercent) { WriteToScannerSamplesArray (temperature, currentStep); if (Scanner.SmoothPoints.iSizeLastMaxSamples != 0 && Scanner.SmoothPoints.iSizeSectionSamples > Scanner.SmoothPoints.iSizeLastMaxSamples) { // overwrite a max section with a new long one for (index = 0; index < Scanner.SmoothPoints.iSizeSectionSamples; index++) { // overwrite to start array Scanner.SmoothPoints.SmoothPoints[index].iTemperature = Scanner.SmoothPoints.SmoothPoints[Scanner.SmoothPoints. iSizeLastMaxSamples + index].iTemperature; Scanner.SmoothPoints.SmoothPoints[index].iNumberStep = Scanner.SmoothPoints.SmoothPoints[Scanner.SmoothPoints. iSizeLastMaxSamples + index].iNumberStep; } Scanner.SmoothPoints.iSizeLastMaxSamples = 0; } return; } } void WriteToScannerSamplesArray(int temperature, int currentStep) { int index = Scanner.SmoothPoints.iSizeLastMaxSamples + Scanner.SmoothPoints.iSizeSectionSamples; Scanner.SmoothPoints.SmoothPoints[index].iTemperature = temperature; Scanner.SmoothPoints.SmoothPoints[index].iNumberStep = currentStep; Scanner.SmoothPoints.iSizeSectionSamples++; }
#ifndef STEPMOTOR_H_ #define STEPMOTOR_H_ // ECCTL1 ( ECAP Control Reg 1) //========================== // CAPxPOL bits #define EC_RISING 0x0 #define EC_FALLING 0x1 // CTRRSTx bits #define EC_ABS_MODE 0x0 #define EC_DELTA_MODE 0x1 // PRESCALE bits #define EC_BYPASS 0x0 #define EC_DIV1 0x0 #define EC_DIV2 0x1 #define EC_DIV4 0x2 #define EC_DIV6 0x3 #define EC_DIV8 0x4 #define EC_DIV10 0x5 // ECCTL2 ( ECAP Control Reg 2) //========================== // CONT/ONESHOT bit #define EC_CONTINUOUS 0x0 #define EC_ONESHOT 0x1 // STOPVALUE bit #define EC_EVENT1 0x0 #define EC_EVENT2 0x1 #define EC_EVENT3 0x2 #define EC_EVENT4 0x3 // RE-ARM bit #define EC_ARM 0x1 // TSCTRSTOP bit #define EC_FREEZE 0x0 #define EC_RUN 0x1 // SYNCO_SEL bit #define EC_SYNCIN 0x0 #define EC_CTR_PRD 0x1 #define EC_SYNCO_DIS 0x2 // CAP/APWM mode bit #define EC_CAP_MODE 0x0 #define EC_APWM_MODE 0x1 // APWMPOL bit #define EC_ACTV_HI 0x0 #define EC_ACTV_LO 0x1 // Generic #define EC_DISABLE 0x0 #define EC_ENABLE 0x1 #define EC_FORCE 0x1 #define STEP_MOTOR_RUN_TO_LS 1 #define STEP_MOTOR_RUN_FROM_LS 0 #define STEP_MOTOR_MAX_STEPS_INIT 6400 #define STEP_MOTOR_MAX_POSITION 800 #define STEP_MOTOR_BASE_POSITION 400 // STEP_MOTOR_MAX_POSITION / 2 #define STEP_MOTOR_NONE_POSITION 0 #define STEP_MOTOR_VELOCITY_10HZ 9000000 // f(cpu) = 90 MHz #define STEP_MOTOR_VELOCITY_20HZ 4500000 // f(cpu) = 90 MHz #define STEP_MOTOR_VELOCITY_50HZ 1800000 // f(cpu) = 90 MHz #define STEP_MOTOR_VELOCITY_100HZ 900000 // f(cpu) = 90 MHz #define STEP_MOTOR_VELOCITY_200HZ 450000 // f(cpu) = 90 MHz #define STEP_MOTOR_VELOCITY_400HZ 225000 // f(cpu) = 90 MHz #define STEP_MOTOR_PULSE_1MS 45000 #define STEP_MOTOR_MIN_SECTION_SIZE 5 #define MAX_PROGRAM_POINTERS 30 #define SCANNER_START_INIT TRUE #define SCANNER_START_WORK FALSE #define SCANNER_DELAY_ON_OFF_LASER 50000 enum STEP_MOTOR_MODE { STEP_MOTOR_WAIT_COMMAND, STEP_MOTOR_START_INIT, STEP_MOTOR_TO_LS, STEP_MOTOR_EXIT_FROM_LS, STEP_MOTOR_TO_BASE, STEP_MOTOR_TO_PROXIMATE, STEP_MOTOR_TO_ABSOLUT, STEP_MOTOR_TO_MAX }; enum SCANNER_COMMAND { SCANNER_COMMAND_IDLE, SCANNER_COMMAND_INIT, SCANNER_COMMAND_HOT_POINT, SCANNER_COMMAND_PENDULUM, SCANNER_COMMAND_ONE_SHOT, SCANNER_COMMAND_PROGRAM_POINT }; // Command from PULT enum SCANNER_USER_COMMAND { SCANNER_USER_COMMAND_WAIT, SCANNER_USER_COMMAND_STEPER_MOTOR, SCANNER_USER_COMMAND_SET_VIRTUAL_POINT, SCANNER_USER_COMMAND_START_SCANNING, SCANNER_USER_COMMAND_BLINK_LASER, SCANNER_USER_COMMAND_ON_LASER }; enum SCANNER_STATE_MACHINE { SCANNER_STATE_MACHINE_IDLE, SCANNER_STATE_MACHINE_STOP, // for INIT SCANNER_STATE_MACHINE_INIT, SCANNER_STATE_MACHINE_INIT_RUN_TO_LEFT, SCANNER_STATE_MACHINE_INIT_WAIT_TO_LEFT, SCANNER_STATE_MACHINE_INIT_RUN_TO_MAX, SCANNER_STATE_MACHINE_INIT_WAIT_TO_MAX, SCANNER_STATE_MACHINE_INIT_RUN_TO_BASE, SCANNER_STATE_MACHINE_INIT_WAIT_TO_BASE, // for Blink Laser SCANNER_STATE_MACHINE_BLINK_LASER_START, SCANNER_STATE_MACHINE_BLINK_LASER_OFF, SCANNER_STATE_MACHINE_BLINK_LASER_DELAY, SCANNER_STATE_MACHINE_BLINK_LASER_ON, // for HOT_POINT SCANNER_STATE_MACHINE_HOT_POINT_START, SCANNER_STATE_MACHINE_HOT_POINT_CHANGE_PARAMETERS, SCANNER_STATE_MACHINE_HOT_POINT_DALAY_START, SCANNER_STATE_MACHINE_HOT_POINT_RUN_TO_FIRST_POINT, SCANNER_STATE_MACHINE_HOT_POINT_WAIT_FIRST_POSITION, SCANNER_STATE_MACHINE_HOT_POINT_RUN_SCANNING, SCANNER_STATE_MACHINE_HOT_POINT_WAIT_STOP_SCANNING, SCANNER_STATE_MACHINE_HOT_POINT_SEARCH_POINTER, SCANNER_STATE_MACHINE_HOT_POINT_WAIT_TO_POINTER, SCANNER_STATE_MACHINE_HOT_POINT_END, // for Repeat HOT_POINT SCANNER_STATE_MACHINE_REPEAT_HOT_POINT_CHECK_OUT_OF_RANGE, SCANNER_STATE_MACHINE_REPEAT_HOT_POINT_WAIT_LEFT_POINT, SCANNER_STATE_MACHINE_REPEAT_HOT_POINT_RUN_SCANNING, SCANNER_STATE_MACHINE_REPEAT_HOT_POINT_WAIT_STOP_SCANNING, SCANNER_STATE_MACHINE_REPEAT_HOT_POINT_SEARCH_POINTER, SCANNER_STATE_MACHINE_REPEAT_HOT_POINT_WAIT_TO_POINTER, // for PENDULUM SCANNER_STATE_MACHINE_PENDULUM_START, SCANNER_STATE_MACHINE_PENDULUM_RUN_TO_LEFT, SCANNER_STATE_MACHINE_PENDULUM_WAIT_TO_LEFT, SCANNER_STATE_MACHINE_PENDULUM_DELAY_TO_LOOP, SCANNER_STATE_MACHINE_PENDULUM_NEW_POSITION, SCANNER_STATE_MACHINE_PENDULUM_WAIT_STOP_SCANNING, SCANNER_STATE_MACHINE_PENDULUM_WAITE_PAUSE, SCANNER_STATE_MACHINE_PENDULUM_END, // for ONE_SHOT SCANNER_STATE_MACHINE_ONE_SHOT_START, SCANNER_STATE_MACHINE_ONE_SHOT_RUN_TO_LEFT, SCANNER_STATE_MACHINE_ONE_SHOT_WAIT_TO_LEFT, SCANNER_STATE_MACHINE_ONE_SHOT_NEW_POSITION, SCANNER_STATE_MACHINE_ONE_SHOT_WAIT_STOP_STEP, SCANNER_STATE_MACHINE_ONE_SHOT_WAIT_PAUSE, SCANNER_STATE_MACHINE_ONE_SHOT_RETURN_TO_LEFT, SCANNER_STATE_MACHINE_ONE_SHOT_END, // for PROGRAM_POINT SCANNER_STATE_MACHINE_PROGRAM_POINT_START, SCANNER_STATE_MACHINE_PROGRAM_POINT_RUN_TO_LEFT, SCANNER_STATE_MACHINE_PROGRAM_POINT_WAIT_TO_LEFT, SCANNER_STATE_MACHINE_PROGRAM_POINT_NEW_POSITION, SCANNER_STATE_MACHINE_PROGRAM_POINT_WAIT_STOP_STEP, SCANNER_STATE_MACHINE_PROGRAM_POINT_WAIT_POUSE, SCANNER_STATE_MACHINE_PROGRAM_POINT_RETURN_TO_LEFT, SCANNER_STATE_MACHINE_PROGRAM_POINT_END }; struct STEP_MOTION_CONTROL_BITS { int CHANGE_PARAMETERS :1; int START :1; int DIR :1; int LOOP_MEASUREMENT :1; int START_SCANNING :1; int START_DRY_CONTACT :1; int START_PC :1; int START_SWITCH :1; int START_FIRST :1; int START_TO_ROGHT :1; int START_REQUEST_COM1:1; int SCANNING_MODE :4; int rsvd :1; }; union STEP_MOTOR_CONTROL { int all; struct STEP_MOTION_CONTROL_BITS bit; }; struct STEP_MOTION_STATUS_BITS { int READY :1; int RUN :1; int INIT :1; int ERROR :1; int START_FIRST :1; // for Pendulum mode int OUT_OF_RANGE :1; int TEMPERATURE :1; int FULL_CYCLE_PENDULUM :1; int COUNTER_OUT_OF_RANGE :4; int COUNTER_TEMPERATURE :4; }; union STEP_MOTOR_STATUS { int all; struct STEP_MOTION_STATUS_BITS bit; }; struct STEP_MOTOR { int uiCommand; int uiCommandUser; int uiDelayOnOffLaser; int uiTempLeftPointer; int uiTempRigthPointer; int iCurrentPosition; int iLimitSwitchPosition; int iMaxPosition; int iBasePosition; int iTargetPosition; int iSmoothPointer; int uiCounterStepToLS; union STEP_MOTOR_CONTROL Control; union STEP_MOTOR_STATUS StatusCommand; union STEP_MOTOR_STATUS Status; }; struct SCANNER_PROGRAM_POINT_BITS { int START :1; int READY :1; int BREAK :1; int RUN_TO_LEFT :1; int NEW_POINTS :1; int COUNTER_INSTANCE :11; }; union SCANNER_PROGRAM_POINT_STATUS { int all; struct SCANNER_PROGRAM_POINT_BITS bit; }; struct SCANNER_SMOOTH_POINTERS_SAMPLES { int iTemperature; int iNumberStep; }; struct SCANNER_SMOOTH_POINTERS { int iSizeSectionSamples; int iSizeLastMaxSamples; struct SCANNER_SMOOTH_POINTERS_SAMPLES SmoothPoints[STEP_MOTOR_MAX_POSITION]; }; struct REAPID_HOT_POINT { int CurentPoint; int NewLeftPoint; int NewRoghtPoint; int CounterOutOfRange; }; struct SCANNER { // New parametrs for HOT POINT mode int MeasuretmentStatus; int uiCodeTauHotPoint; int iSigmaHotPoint; unsigned char ucMoveShiftHotPoint; union STEP_MOTOR_CONTROL Control; struct SCANNER_SMOOTH_POINTERS_SAMPLES PointerMax; /* Array of measurements for each position. */ union SCANNER_PROGRAM_POINT_STATUS ProgramPointStatus; struct SCANNER_SMOOTH_POINTERS SmoothPoints; struct REAPID_HOT_POINT ReapidHotPoint; }; extern struct STEP_MOTOR StepMotor; extern struct SCANNER Scanner; #endif /* STEPMOTOR_H_ */

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue