Използвам този код на Arduino, за да генерирам 5V, 200 KHz импулс с 50% ширина на импулса.
void setup() {
// put your setup code here, to run once:
pinMode(pwmpin, OUTPUT);
pinMode(FBo, INPUT);
pinMode(FBi, INPUT);
noInterrupts(); // disable all interrupts
TCCR0A = 0;
TCCR0B = 0;
TCNT0 = 0;
OCR0A = 40; // compare match register Duty Cycle * 16MHz/200kHz
OCR0B = 40; // compare match register 1 - Duty Cycle * 16MHz/200kHz
TIMSK0 |= (1 << OCIE0A); // enable timer compare interrupt
digitalWrite(pwmpin,HIGH);
TCCR0B |= (1 << CS00);
interrupts(); // enable all interrupts
}
ISR(TIMER0_COMPA_vect) {
digitalWrite(pwmpin, digitalRead(pwmpin) ^ 1);
//TIMSK0 |= (1 << OCIE0B); // enable timer compare interrupt
//TIMSK0 &= ~(1 << OCIE0A); // disable timer compare interrupt
}
Вместо 5V 200 KHz импулс, той ми показва приблизително 2V 30 KHz сигнал. Може ли някой да ми каже какъв е проблема?