Guys I made this program for ATtiny85 with SpenceKonde/ATTinyCore, in the complication no error is indicated. Just a few warnings. What are these.
warning: unused parameter 'pin' [-Wunused-parameter]
inline void DebugPulse(uint8_t pin, uint8_t count)
warning: unused parameter 'pin' [-Wunused-parameter]
inline void DebugPulse(uint8_t pin, uint8_t count)
warning: always_inline function might not be inlinable [-Wattributes]
void SoftwareSerial::setRxIntMsk(bool enable)
warning: always_inline function might not be inlinable [-Wattributes]
void SoftwareSerial::recv()
I go to Proteus and do the simulation and I don't know why the simulation always pauses on that line.
I've been wondering all day what's going on.
Until in the Arduino IDE I disabled the LTO option (1.6.11 + Only), when I compile again the same warning appears, but the program in proteus runs without any pause.
Whenever there was a pause in Proteus, breakpoint software quickly appeared in the footer, but there is no breakpoint placed in the program.
This is the code
#include <SoftwareSerial.h>
#define SERIAL_TX PINB0
#define SERIAL_RX PINB1
int ADC1 = A1;
int ConvertValue = 0; // Variable to store the converted value of ADC0
int PowerValue = 0; // Variable to store the power value
int PreviousPowerValue = 0; // Variable to store the previous power value
unsigned long ADCTime = 0; //Time for reading the analog input
unsigned long SerialTime = 0; //Time for serial communication with the HMI
// Variables for analog reading smoothing
const int NReadings = 20; // Number of samples for smoothing. The higher the more smoothing and slow to react
int Reads[NLreads]; // Array with 20 indexes
int Index = 0; // Current index value
long Total = 0; // Value of sums of readings
int Average = 0; // Average of readings
SoftwareSerial mySerial(SERIAL_RX, SERIAL_TX);
void setup() {
// put your setup code here, to run once:
pinMode(PINB2, INPUT); // AN0 input (PB2 - Pin 7)
pinMode(PINB1, INPUT); // RX input (PB1 - Pin 6)
pinMode(PINB0, OUTPUT); // TX output (PB0 - Pin 5)
mySerial.begin(9600); //Start serial communication with baud rate = 9600
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
if (millis() >= ADCTTime + 20) { // Reads the analog input every 20ms
ADCTime = millis();
ConvertValue = analogRead(ADC1); // Read the analog input
//Power Reading Smoothing
Total = Total - Readings[Index];
Readings[Index] = ConvertedValue;
Total = Total + Reads[Index];
Index = Index + 1;
if (Index >= NReadings) {
Index = 0;
}
Average = Total / NReadings;
PowerValue = map(Average, 0, 1023, 0, 100); // Remaps a number from one range to another
PowerValue = constrain(PowerValue, 0, 100); // Constrain a number to fall within a range
}
if ((millis() >= ADCTime + 200) && (PowerValue != PreviousPowerValue)) { // Performs serial communication every 200ms with changes in the power value
TimeSerial = millis();
PreviousPowerValue = PowerValue;
mySerial.print(PowerValue);
}
}