moskid / arduino-tvout

Automatically exported from code.google.com/p/arduino-tvout
0 stars 0 forks source link

make arduino tvout initial release work into atmega32 #95

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Guys

I'd like to improve my understanding about coding.  i am really stuck working 
tvout library to atmega32.

id like to start basic which is the tvout initial release to help understand 
things step by step.

i believe that the tvout initial release work at atmega328 using the pin 9 and 
8.

so this are the pin configuration
//setup the ports

DDRB |= 0x03;
PORTB &= ~0x02;
PORTB |= 0x02;

// inverted fast pwm mode on timer 1
   TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(WGM11);
   TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10);
   ICR1 = CYCLES_SCANLINE;
   OCR1A = CYCLES_HORZ_SYNC;
   OCR1B = CYCLES_OUTPUT_START-20;

how to make it work with the atmega32 which is PD5 is OCR1A and PD6?

sorry for my english =D

hope someone help me.

thanks

Original issue reported on code.google.com by darwins...@gmail.com on 6 Aug 2015 at 10:35

GoogleCodeExporter commented 8 years ago
I also notice there is assembly language at video_gen.cpp.

__asm__ __volatile__ (
      //save PORTB
      "IN      r16,%[port]\n\t"
      "ANDI   r16,0xFD\n\t"

   ".macro output\n\t"
      "BLD   r16,0\n\t"            //output pin of the port here pinB0
      "OUT   %[port],r16\n"         //and on the last line of asm
   ".endm\n"

   ".macro pixeldelay\n\t"            // delay time for setting pixel width
      "NOP\n\t"                  // one can be removed for smaller
      "NOP\n\t"                  // pixels dont forget to remove the
      "NOP\n\t"                  // nop at the start of byteshift
   ".endm\n"

   ".macro byteshift\n\t"
      "NOP\n\t"
      "BST   __tmp_reg__,7\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,6\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,5\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,4\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,3\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,2\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,1\n\t"
      "output\n\t"
      "pixeldelay\n\t"
      "BST   __tmp_reg__,0\n\t"
      "output\n"
   ".endm\n\t"

      //output thingy
      "LD      __tmp_reg__,X+\n\t"      //1
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //2
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //3
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //4
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //5
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //6
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //7
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //8
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //9
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //10
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //11
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //12
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //13
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //14
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //15
      "byteshift\n\t"
      "LD      __tmp_reg__,X+\n\t"      //16
      "byteshift\n"

   "EndLine_%=:\n\t"
      "CBI   %[port],0\n\t"
   // assembly variable IO:
   :
   : [port] "i" (_SFR_IO_ADDR(PORTB)),
     "x" (screenptr)
   : "r16" // try to remove this clobber later...
   );
   renderLine+=16;

Original comment by darwins...@gmail.com on 6 Aug 2015 at 10:36