Ich werde nicht Ihre Zeit verschwenden, und posten Sie einfach den Code zusammen mit der ErklärungServos nicht richtig auf AVR läuft
#define F_CPU 8000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
int main(void){
sei(); //Enable interrupts
DDRB = (1 << PORTB3);//Set pin P3 as an output and other pins as inputs
//PORTB = 0xff;
DDRA = (1 << PORTA7);//Set pin A7 as an output and other pins as inputs
//PORTA = (1 << PORTA7);
TCCR0 = (1 << WGM00) | (1 << WGM01) | (1 << COM01);//Enable PWM, and configure Timer
TIMSK = (1 << TOIE0);//Enabling an interrupt
OCR0 = 255;//Setting comparison value for the Output compare unit
TCCR0 |= (0b110 << CS00);//Selecting the clock as the falling edge on a certain pin
while(1){
/*
* The portion of the code creates a square wave with a period of 39 us, which means that the falling edge occurs at a period of 78us, and since the output period of
* the PWM is 50Hz for a servo, that fits perfectly (1/(79*10^-6 * 256) ~ 50), but for some reason, the servo doesn't move...*/
PORTA ^= (1<< PORT7);
_delay_us(39);
}
}
Also, was ist das Problem ?? Ich habe nicht wirklich ein Oszilloskop, um die Frequenz zu messen, also bitte mich nicht, das zu tun, aber eine merkwürdige Sache, die ich bemerkte, war, dass die Spannung über den Servo-Stromkabeln 2,7 V betrug, wenn es 5 V hätte sein sollen , aber die Stromversorgung selbst lieferte 5V, und dies geschah nur, wenn ich den Signalstift an den PWM-Pin angeschlossen habe, und es geschah unabhängig davon, ob die 5V-Schiene mit dem Servo verbunden war oder nicht ... Irgendwelche Ideen, was das Problem ist ist ??
Wenn du gehst, um mich zu downvote, sagen Sie mir den Grund ... –