Pages: 1 [2] 3   Go Down
Author Topic: Composite Video Generating  (Read 6973 times)
0 Members and 1 Guest are viewing this topic.
The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried some things with dma, but now my arduino doesn't work anymore. I have seriously no idea what's the problem.

Edit: It works again. I pressed the erease and the reset button at the same time, and were able to upload a sketch again. After that everything worked well again.
« Last Edit: March 20, 2013, 09:46:06 am by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried some things with dma, but now my arduino doesn't work anymore. I have seriously no idea what's the problem.

Edit: It works again. I pressed the erease and the reset button at the same time, and were able to upload a sketch again. After that everything worked well again.
Lucky men, I know this kind of happiness...
Logged

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried some things with dma, but now my arduino doesn't work anymore. I have seriously no idea what's the problem.

Edit: It works again. I pressed the erease and the reset button at the same time, and were able to upload a sketch again. After that everything worked well again.
Lucky men, I know this kind of happiness...
Yea, first I thought it has broken. But then I just tried some random things, and then by purpose the bossac com port connected to my pc.

By the way, I changed the loop (with asm code) and now it is 330 px width.
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Success!  smiley-cool smiley-mr-green smiley-lol


* 20130320_182433.jpg (418.41 KB, 1024x768 - viewed 68 times.)
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Success!  smiley-cool smiley-mr-green smiley-lol
smiley-eek Cool! May I have your code?
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code needs tidying and commenting and debugging before I can share it (and before I forget how it works). I have got colour out of 3 monitors so far so it is looking good. This is using NTSC timings, I will try PAL another day. Resolution is  640x200 (or about 700x220 with overscan), but practically the Arduino won't be fast enough or have the ram to make use of all that. I may aim for a 160x200 mode.

Grayscale, colour bars and dot crawl smiley


* 20130320_221204.jpg (896.21 KB, 2048x1536 - viewed 81 times.)
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code needs tidying and commenting and debugging before I can share it (and before I forget how it works). I have got colour out of 3 monitors so far so it is looking good. This is using NTSC timings, I will try PAL another day. Resolution is  640x200 (or about 700x220 with overscan), but practically the Arduino won't be fast enough or have the ram to make use of all that. I may aim for a 160x200 mode.

Grayscale, colour bars and dot crawl smiley

Sorry, but I wanted to make such library. I really appreciate your help, but I want to do things myself. Could you give me the dma stuff at least?
« Last Edit: March 21, 2013, 08:47:54 am by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is just the DMA section of the code:
Code:
// Continuous DMA -> SMC port (pins 34-41)
// by stimmer

// set up 2 DMA buffers and a linked list
// 888 and 222 is NTSC timings (~15750 buffers/sec)
uint8_t dmabuf[2][888];
uint32_t dmall[10]={(uint32_t)dmabuf[0],0x60000000,0x22060000+222,0x20000000,(uint32_t)(dmall+5),
                    (uint32_t)dmabuf[1],0x60000000,0x22060000+222,0x20000000,(uint32_t)dmall};
int cbuf=0; // current buffer index

void  DMAC_Handler()
{
    uint32_t dummy=REG_DMAC_EBCISR; // clear DMA interrupt flag
    dmall[2+5*cbuf]=0x22060000+222; // may not be needed

  // write to dmabuf[cbuf] here   
  // you only have 6 clock cycles per byte! 
  // write words and longs where you can for speed
 
    cbuf=1-cbuf;
}

void setup() {
 
  // set up memory controller
  REG_PMC_PCER0= 1<<9;
  REG_SMC_SETUP0=0; 
  REG_PIOC_PDR=0b1111111100;
  REG_PIOC_ABSR&=~0b1111111100; 
  REG_SMC_WPCR=0x534d4300;
  REG_SMC_SETUP0=0x00000000;
  REG_SMC_PULSE0=0X00000101;
  REG_SMC_CYCLE0=0X00000006; // this sets the DMA rate -  84/6=14 MByte/sec
  REG_SMC_TIMINGS0=0;
  REG_SMC_MODE0=0x00000000;
 
  // this code puts DMA priority above CPU.
  MATRIX->MATRIX_WPMR=0x4d415400;
  for(int i=0;i<6;i++)MATRIX->MATRIX_MCFG[i]=1;
  MATRIX->MATRIX_MCFG[4]=4;
  for(int i=0;i<8;i++)MATRIX->MATRIX_SCFG[i]=0x01000008;
  MATRIX->MATRIX_SCFG[6]=0x011200ff;
  MATRIX->MATRIX_PRAS0=MATRIX->MATRIX_PRAS1=MATRIX->MATRIX_PRAS2=0x00000000;
  MATRIX->MATRIX_PRAS3=MATRIX->MATRIX_PRAS4=MATRIX->MATRIX_PRAS5=0x00000000;
  MATRIX->MATRIX_PRAS6=0x00030000;
  MATRIX->MATRIX_PRAS7=MATRIX->MATRIX_PRAS8=0x00000000;

  // set up DMA
  REG_PMC_PCER1= 1<<7; 
  REG_DMAC_WPMR=DMAC_WPMR_WPKEY(0x444d4143);
  REG_DMAC_EN=1;
  REG_DMAC_GCFG=0x00;
  REG_DMAC_CFG5=0x10702200;
  REG_DMAC_DSCR5=(uint32_t)dmall;
  REG_DMAC_EBCIER=1<<5;
  NVIC_EnableIRQ(DMAC_IRQn);
 
  // start DMA
  REG_DMAC_CHER=1<<5;

}

void loop() {
 
}
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is just the DMA section of the code:
Code:
// Continuous DMA -> SMC port (pins 34-41)
// by stimmer

// set up 2 DMA buffers and a linked list
// 888 and 222 is NTSC timings (~15750 buffers/sec)
uint8_t dmabuf[2][888];
uint32_t dmall[10]={(uint32_t)dmabuf[0],0x60000000,0x22060000+222,0x20000000,(uint32_t)(dmall+5),
                    (uint32_t)dmabuf[1],0x60000000,0x22060000+222,0x20000000,(uint32_t)dmall};
int cbuf=0; // current buffer index

void  DMAC_Handler()
{
    uint32_t dummy=REG_DMAC_EBCISR; // clear DMA interrupt flag
    dmall[2+5*cbuf]=0x22060000+222; // may not be needed

  // write to dmabuf[cbuf] here  
  // you only have 6 clock cycles per byte!  
  // write words and longs where you can for speed
  
    cbuf=1-cbuf;
}

void setup() {
  
  // set up memory controller
  REG_PMC_PCER0= 1<<9;
  REG_SMC_SETUP0=0;  
  REG_PIOC_PDR=0b1111111100;
  REG_PIOC_ABSR&=~0b1111111100;  
  REG_SMC_WPCR=0x534d4300;
  REG_SMC_SETUP0=0x00000000;
  REG_SMC_PULSE0=0X00000101;
  REG_SMC_CYCLE0=0X00000006; // this sets the DMA rate -  84/6=14 MByte/sec
  REG_SMC_TIMINGS0=0;
  REG_SMC_MODE0=0x00000000;
  
  // this code puts DMA priority above CPU.
  MATRIX->MATRIX_WPMR=0x4d415400;
  for(int i=0;i<6;i++)MATRIX->MATRIX_MCFG[i]=1;
  MATRIX->MATRIX_MCFG[4]=4;
  for(int i=0;i<8;i++)MATRIX->MATRIX_SCFG[i]=0x01000008;
  MATRIX->MATRIX_SCFG[6]=0x011200ff;
  MATRIX->MATRIX_PRAS0=MATRIX->MATRIX_PRAS1=MATRIX->MATRIX_PRAS2=0x00000000;
  MATRIX->MATRIX_PRAS3=MATRIX->MATRIX_PRAS4=MATRIX->MATRIX_PRAS5=0x00000000;
  MATRIX->MATRIX_PRAS6=0x00030000;
  MATRIX->MATRIX_PRAS7=MATRIX->MATRIX_PRAS8=0x00000000;

  // set up DMA
  REG_PMC_PCER1= 1<<7;  
  REG_DMAC_WPMR=DMAC_WPMR_WPKEY(0x444d4143);
  REG_DMAC_EN=1;
  REG_DMAC_GCFG=0x00;
  REG_DMAC_CFG5=0x10702200;
  REG_DMAC_DSCR5=(uint32_t)dmall;
  REG_DMAC_EBCIER=1<<5;
  NVIC_EnableIRQ(DMAC_IRQn);
  
  // start DMA
  REG_DMAC_CHER=1<<5;

}

void loop() {
  
}
Thanks, but what if I want to transfer only one buffer at a time? (After calling  REG_DMAC_CHER=1<<5;)
« Last Edit: March 21, 2013, 09:09:00 am by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The last few days, I worked on writing a wss. It was not easy, but now widescreen is possible. I have also made some progress on the color stuff. But not on the arduino yet. I first made an application on the pc to generate composite video signals from pictures. It works great. (I got another tool to get it colored again) I will work soon on color for the arduino.


* DSC00342.JPG (39.13 KB, 640x360 - viewed 45 times.)
« Last Edit: March 29, 2013, 10:54:01 am by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some progress on coloring is made, but I can't get those colors to be smooth.
On the picture you can see from top to bottom Red, Green and Blue. (The green is the most bad one. But you can see some green spots)


* DSC00393.JPG (143.73 KB, 640x480 - viewed 54 times.)
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is much better already. (Same picture as above):


* DSC00396.JPG (149.14 KB, 640x480 - viewed 35 times.)
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Light blue (#00c0c0):


* DSC00444.JPG (144.26 KB, 640x480 - viewed 31 times.)
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino logo:


* DSC00450.JPG (44.93 KB, 640x480 - viewed 57 times.)
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got the colors almost perfect now.   smiley-mr-green
The Arduino logo, the SNES logo, and an Itembox of mkdd:


* DSC00481.JPG (38.83 KB, 640x480 - viewed 35 times.)

* DSC00480.JPG (41.58 KB, 640x480 - viewed 50 times.)

* DSC00482.JPG (37.54 KB, 640x480 - viewed 41 times.)
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Pages: 1 [2] 3   Go Up
Jump to: