I'm writing program in Microchip Studio to control DC 6V engine (graupner 400 max 4,0A) using RC radio receiver. I'm using Attiny 2313A with F_CPU 16 MHz.
RC receiver sends PWM signal to MCU on PD2 pin.
MCU must sends PWM signal to PINs PB3 + PB2 Engine turn left PB4 + PC5 Engine turn right
To control motor I would like to generate a PWM signal with a frequency of 1 kHz.
Below is my program and errors during compilation. Thanks a lot!
#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 16000000L
#define A PB3
#define D PB2
#define B PB4
#define C PD5
//Fast PWM
void PWM_100p_PRZOD()
{
TCCR0A = (1<<COM0A1) | (1 << WGM02) | (1 << WGM01) | (1 << WGM00);
TCCR1A = (1<<COM1A1) | (1 << WGM12) | (1 << WGM10);
OCR0A= 255;
OCR1A= 65535;
}
void PWM_0p_TYL()
{
TCCR0B = (1<<COM0B1) | (1 << WGM02) | (1 << WGM01) | (1 << WGM00) | (1 << CS01);
TCCR1B = (1<<COM1B1) | (1 << WGM12) | (1 << WGM10);
OCR0B= 0;
OCR1B= 0;
}
int main(void)
{
DDRB |= (1 << DDB2) | (1 << DDB3) | (1 << DDB4);
DDRD |= (1 << DDD5);
PORTB &= ~((1 << A) | (1 << D) | (1 << B));
PORTD &= ~(1 << C);
DDRD &= ~(1 << PD2);
PORTD &= ~(1 << PD2);
while(1)
{
PWM_100p_PRZOD();
_delay_ms(100);
}
return 0;
}
}
_delay_ms(100);
}
return 0;
}
errors
'ADMUX' undeclared (first use in this function)
'REFS0' undeclared (first use in this function)
'ADCSRA' undeclared (first use in this function)
'ADEN' undeclared (first use in this function)
'ADPS2' undeclared (first use in this function)
'ADPS1' undeclared (first use in this function)
'ADPS0' undeclared (first use in this function)
'ADMUX' undeclared (first use in this function)
'ADCSRA' undeclared (first use in this function)
'ADSC' undeclared (first use in this function)
'ADC' undeclared (first use in this function)
#error "Attempt to include more than one <avr/ioXXX.h> file."
#warning "F_CPU not defined for <util/delay.h>" [-Wcpp]
recipe for target 'main

You probably have the project properties set incorrectly. Select Project > Properties and check the Device setting. The programmer is a separate application that is only launched from the IDE and its settings can be completely different from the project being compiled. Therefore, mentioning it when searching for the causes of a compilation error is completely irrelevant.
I test compile your code a I get totally different errors