Wren6991 / PicoDVI

Bitbanged DVI on the RP2040 Microcontroller
BSD 3-Clause "New" or "Revised" License
1.26k stars 140 forks source link

Running in flash #21

Closed fruit-bat closed 2 years ago

fruit-bat commented 3 years ago

Ok, so this isn't really an issue, but I was hoping for some advice (please!).

I've been having lots of fun with this library and have had a go at writing a tmds encoder for a 48k ZX Spectrum. My first attempt at arm assembly, which I'm sure is pretty terrible, but it seems to work fine.

Given that worked, I thought I would try a 128k spectrum but there is not enough RAM with 'copy to ram' set... So I switched it off, and amazingly almost everything keeps working from flash.

But now, when I try to read from the SD card it now stalls the video output, which is visually apparent as white lines on the screen , often followed by the colour channels ending up out of sync.

I figured that I 'just' needed to move some functions to RAM, in particular the isr routines for the SD card. After many random attempts all which had no effect, I thought I would seek some advice.

As some context, the SD card uses dma_irq_0 and a couple of dma channels along with an spi interface. I've set the dvi encoder to use dma_irq_1. I don't think the encoder is under-running as changing the number of buffers makes no difference (although this is a guess).

Any thoughts appreciated, even if it's give up!

fruit-bat commented 3 years ago

Ok, got this working. Probably doesn't need any changes to PicoDvi. I'll comment again when I've wound back to a minimum set of changes.

fruit-bat commented 3 years ago

Looks like I only need the changes to the SD card SPI library, so feel free to close this one. Thanks for leaving this open while I investigated.

Wren6991 commented 2 years ago

Thanks for looking at that. Colour channels getting out of sync sounds like a DMA throughput issue, which might happen if you inadvertently DMA from XIP, causing DMA to stall.