From 97e0ff26faf90fa257fd64034502d8a3fa4a59a9 Mon Sep 17 00:00:00 2001 From: giomba Date: Sat, 26 Jun 2021 23:42:23 +0200 Subject: [PATCH] "diagonal line" not the whole screen, but vertically locked actually it has some issues, there is a single dot (at the end/beginning of a cycle) that messes up the horizontal sync and moves all the picture... must be fixed --- main.S | 40 +++++++++++++++++++++++++++++++--------- main.c | 15 ++++----------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/main.S b/main.S index 47ee4a0..ee11340 100644 --- a/main.S +++ b/main.S @@ -9,6 +9,9 @@ status: offset: .byte 78 +line: +.word 0 + .text .global main_s @@ -21,10 +24,10 @@ main_s: out IO(MCUCR), r16 out IO(MCUCR), r17 - ldi r16, 0x3 ; enable falling edge interrupt 0 + ldi r16, 0xa ; external interrupt 0 and 1, falling edge sts EICRA, r16 - ldi r16, 0x1 ; external interrupt mask enable + ldi r16, 0x3 ; external interrupt 0 and 1, mask enable sts EIMSK, r16 sei @@ -66,26 +69,33 @@ wait2: jmp again -.global int0_handler -int0_handler: +.global int_horizontal_sync +int_horizontal_sync: push r31 in r31, IO(SREG) ; status register push r31 + lds r31, line + cpi r31, 255 + brsh int_horizontal_sync_end + inc r31 + sts line, r31 + + lds r31, status + cpi r31, 0 + brne int_horizontal_sync_end + lds r31, offset dec r31 cpi r31, 1 brne 1f - ldi r31, 78 + ldi r31, 140 1: sts offset, r31 loop: dec r31 brne loop - lds r31, status - cpi r31, 1 - brne 1f sbi IO(PORTB), 4 nop nop @@ -98,9 +108,21 @@ loop: nop nop cbi IO(PORTB), 4 -1: + +int_horizontal_sync_end: pop r31 out IO(SREG), r31 pop r31 reti +.global int_vertical_sync +int_vertical_sync: + push r31 + ldi r31, 0 + sts line, r31 + ldi r31, 140 + sts offset, r31 + pop r31 + reti + + diff --git a/main.c b/main.c index f795dd1..f509ba1 100644 --- a/main.c +++ b/main.c @@ -2,20 +2,13 @@ #include void main_s(void); -void int0_handler(void); - -void pippo() { - asm("nop"); - asm("push r1"); - int i = 0; - i = 2; - i += 1; - reti(); -} ISR(INT0_vect, ISR_NAKED) { - asm("jmp int0_handler"); + asm("jmp int_vertical_sync"); +} +ISR(INT1_vect, ISR_NAKED) { + asm("jmp int_horizontal_sync"); } int main() {