Ср июн 30, 2021 14:06:27
Ср июн 30, 2021 15:52:38
Ср июн 30, 2021 16:28:06
#define F_CPU 16000000UL //частота 16 мегагерц
#include <avr/io.h> // Подключим файл io.h
#include <util/delay.h> // Подключим файл delay.h
//Quickly Turn VSYNC On/Off
//Or You Can Change The VSYNC Pin..
#define VSYNC_LOW PORTD &= ~_BV(6)
#define VSYNC_HIGH PORTD |= _BV(6)
//Quickly Turn HSYNC On/Off
//Or You Can Change The HSYNC Pin..
#define HSYNC_LOW PORTD &= ~_BV(7)
#define HSYNC_HIGH PORTD |= _BV(7)
//RED
#define RED_ON PORTB |= _BV(4)
#define RED_OFF PORTB &= ~_BV(4)
#define WHITE_ON PORTB |= _BV(4);PORTB |= _BV(3); PORTB |= _BV(2)
#define WHITE_OFF PORTB &= ~_BV(4);PORTB &= ~_BV(3);PORTB &= ~_BV(2)
#define YELLOW_ON PORTB |= _BV(4);PORTB |= _BV(3)
#define YELLOW_OFF PORTB &= ~_BV(4);PORTB &= ~_BV(3)
//Green
#define GREEN_ON PORTB |= _BV(3)
#define GREEN_OFF PORTB &= ~_BV(3)
//BLUE
#define BLUE_ON PORTB |= _BV(2)
#define BLUE_OFF PORTB &= ~_BV(2)
void H_SYNK(void)
{
_delay_us(1); //Front Porch
HSYNC_LOW;
_delay_us(3.2);
HSYNC_HIGH;
_delay_us(2.2); //BACK PORCH
}
void V_SYNK(void)
{
//FRONT PORCH VERTICAL
_delay_us(20);
_delay_us(1); //front porch
HSYNC_LOW;
_delay_us(3.2);
HSYNC_HIGH;
_delay_us(2.2); //Back Porch
//VERTICAL SYNC
VSYNC_LOW;
for(int i=0;i<4;i++)
{
_delay_us(20);
_delay_us(1); //front porch
HSYNC_LOW;
_delay_us(3.2);
HSYNC_HIGH;
_delay_us(2.2); //Back Porch
}
VSYNC_HIGH;
//BACK PORCH VERTICAL
for(int i=0;i < 23;i++)
{
_delay_us(1); // Front Porch
_delay_us(20); //Color Data
_delay_us(2.2); //Back Porch
HSYNC_LOW;
_delay_us(3.2);
HSYNC_HIGH;
}
}
int m [4][4] =
{
{1,1,1,1},
{1,0,0,1},
{1,0,0,1},
{1,0,0,1}
};
int main(void) {
//Initializations
cli();
DDRB = 0xFF;
DDRD = 0xFF;
while(1)
{
VSYNC_HIGH;
HSYNC_HIGH;
for(long c=100;c>0;c--)
{
_delay_us(20);
H_SYNK();
}
for(long c=4;c>0;c--)
{_delay_us(15);
RED_ON;
_delay_us(0.4);
RED_OFF;
_delay_us(0.6);
_delay_us(4);
H_SYNK();
}
for(long c=16;c>0;c--)
{
_delay_us(15);
RED_ON;
_delay_us(0.1);
RED_OFF;
_delay_us(0.2);
RED_ON;
_delay_us(0.1);
RED_OFF;
_delay_us(0.6);
_delay_us(4);
H_SYNK();
}
for(long c=480;c>0;c--)
{
_delay_us(20);
H_SYNK();
}
V_SYNK();
}
}
V_SYNK();
}
}
Ср июн 30, 2021 18:45:18