Closed sandric closed 1 year ago
I also not sure how to use even uart though - since vga uses all pins with uart buses using gpio0-gpio17. Here's my schematic I took from pico documentation:
Can someone share schematic to use UART communication with vga 5-5-5 DAC?
I managed to use UART with 20 and 21 pins, but turns out that even smth like led blinking loop simply hangs, so I think it just unusable with rendering to do anything else.
@sandric Have you tried SoftwareSerial?
@Andy2No no, but as I said - 20 and 21 gpio works fine for UART, but when I start vga routine it doesn't work. So the thing is not in usb or uart - I can not make simple loop of blinking led on second core to work, it hangs, you can try this code commenting vga code in main in and out to see:
void core1_blink() {
while(true) {
gpio_put(LED_PIN, 1);
sleep_ms(1000);
gpio_put(LED_PIN, 0);
sleep_ms(1000);
}
int main() {
...
multicore_launch_core1(core1_blink);
...
}
@sandric vgaimage-dma.c
employs DMA (direct memory access), a dedicated hardware mechanism for transferring data between devices, such as RAM and flash memory. The image data is stored in the flash memory and needs to be transferred to RAM. The DMA hardware performs this task because using the CPU would require two data transfer sessions: reading to the CPU and writing to RAM.
The issue is that the CPU requires access to flash memory where the code and data are located, but the flash memory is frequently occupied because the DMA hardware locks it. This is why printf()
in your code does not work. printf()
and other library code/data are located in the flash memory, and the CPU cannot access them.
To solve this problem, you should place your entire code in RAM by specifying the following option:
cmake -DPICO_NO_FLASH=1 -B build
However, this does not work with my code because the image data is part of the code, and the linker will try to place it in RAM, but there is insufficient space. A possible solution is to write the image data directly to the flash memory and access it from the code using a pointer that points to the image data's address in the flash memory. Please refer to https://github.com/raspberrypi/pico-playground/tree/master/scanvideo/flash_stream as this code does exactly that.
@boochow Thanks a lot for great explanation, I also came to this conclusion by trying to read pico datasheet, but its above my expertise level unfortunately. I tried the same but setting this variable in cmake itself:
set(PICO_NO_FLASH 1)
but didn't end up resolving the issue. But thanks for a clue about flash_stream
- I know how to build it too, bud didn't though about picotool as a way to get away with it. I will try it and write back.
@boochow ok, I tried, but no success still. I tried both starting blinking on secondary core, and starting vga routine on secondary core. Both times - smth different is happening when PICO_NO_FLASH=1
is used: display got splitted on half with "blue/black" colors on sides, and blinking/printf CDC routine actually working, but not vga though.
I also found out that for some reason flashed code works only before restarting pico, and fallback to previously loaded without PICO_NO_FLASH=1
, not sure but mb that mean that you need to flash it each time you power device if you want to use RAM loaded code?
I was playing also a bit with dma bulk loading, I found out experimentally that if I reduce buffer to read from ssi/dma to 32 bytes - it actually works, just renders like 1/20 of screen width.
I wonder if it is somehow means possible to reduce bulk loading times by reading picture only 1 time, instead of each time reading from RAM 60 times a second? The thing is that I need to display only 1 picture, not video etc. I mean mb there is timing for 1 hz in vga modes - so that rest of the second I could do anything else apart rendering? Or vga requires you to give 60hz all the times?
@sandric thank you for sharing this; it seems something still conflicts with the DMA... but I'm afraid I can't handle this issue with my knowledge. How about posting your question at https://forums.raspberrypi.com/viewforum.php?f=145 ? kilograham may answer it.
@boochow sure, didn't have big luck before with rp forum, but I'll try there, thanks for your help.
Hi, I wonder is it possible to somehow use usb printf (or anything more heavy than led-blinking to that matter?) in vga-test3 dma example? I tried using usb printf in vga-test3 simple
vgaimage.c
example, and all works fine, but withvgaimage-dma.c
I'm unable to make it work. I tried to use second core in both ways - to printtick
string on it with 1 second delay, and vice versa - to printtick
on main core, and moving vga routine to second core:Second core vga routine main:
Second core ticking main:
If I move vga routine to second core - it draws without a problem but port is not opened and just no communication appears. If I move ticking printing to second core - it didn't draw at all, and no port is opened - looks just halt.
I debugged a bit, and it looks like everything works fine up until
__no_inline_not_in_flash_func(flash_bulk_read)
function gets executed. I tried to remove everything but first line withssi_hw->ssienr = 0;
- and it immidiately breaks. I'm a newbie into pi and not quite sure what this code does.I also tried to do the same with
flash-stream
dma example in similarpico-playground
examle, and created issue in its repository - https://github.com/raspberrypi/pico-playground/issues/36So my question is - do you tried to output usb printout and what am I doing wrong here? I want to draw 640x320 display while simultaneously checking capacitive touch panel every ~5ms via i2c, do you know if its possible at all and if all resources are taken by pico just to draw screen so it will halt? Thx