Код
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <avr/sleep.h>
#define lineTime 1280
int LineCount;
ISR (TIMER1_COMPA_vect) {
LineCount++;
if (LineCount==312){
LineCount = 0;
}
if(LineCount > 305 && LineCount < 309){
PORTD = 0b01000000;;
_delay_us(8);
PORTD = 0b00000000;
}else{
PORTD = 0b00000000;
_delay_us(4);
PORTD = 0b01000000;
_delay_us(8);
PORTD = 0b10000000;
}
if(LineCount > 100 && LineCount < 150){
_delay_us(13);
PORTD = 0b10000000;
_delay_us(25);
}
PORTD = 0b01000000;
}
int main(){
OCR1A = lineTime; //One PAL line
TCCR1B = (1<<WGM12)|(1<<CS10); //full speed; clear-on-match
TCCR1A = 0x00; //turn off pwm and oc lines
TIMSK1 = 1<<OCIE1A; //enable interrupt T1 cmp A
DDRD=0xC0; //video out
PORTD = 0b01000000;
LineCount = 0;
sei();
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
while(1){
sleep_cpu();
}
}
#include <avr/interrupt.h>
#include <util/delay.h>
#include <avr/sleep.h>
#define lineTime 1280
int LineCount;
ISR (TIMER1_COMPA_vect) {
LineCount++;
if (LineCount==312){
LineCount = 0;
}
if(LineCount > 305 && LineCount < 309){
PORTD = 0b01000000;;
_delay_us(8);
PORTD = 0b00000000;
}else{
PORTD = 0b00000000;
_delay_us(4);
PORTD = 0b01000000;
_delay_us(8);
PORTD = 0b10000000;
}
if(LineCount > 100 && LineCount < 150){
_delay_us(13);
PORTD = 0b10000000;
_delay_us(25);
}
PORTD = 0b01000000;
}
int main(){
OCR1A = lineTime; //One PAL line
TCCR1B = (1<<WGM12)|(1<<CS10); //full speed; clear-on-match
TCCR1A = 0x00; //turn off pwm and oc lines
TIMSK1 = 1<<OCIE1A; //enable interrupt T1 cmp A
DDRD=0xC0; //video out
PORTD = 0b01000000;
LineCount = 0;
sei();
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
while(1){
sleep_cpu();
}
}
От PORTD7 вывел 330 Ом, от PORTD6 1кОм, от них на землю увел 75Ом и место сединения всех 3 резисторов вывел на сигнал PAL.
Чего я не того наворотил?
