PicoCalc Text Starter (C/C++)

I love the history display with the up/down buttons and the sprite test seems very promising!

1 Like

Interesting. I just tried compiling the latest from the github repo (which doesn’t have this change, I checked), and it built and linked without errors. I was building for the default pico_2w target, so maybe this is only a problem for certain targets? Going to try running it now under uf2loader.

EDIT:
Just checked and it seems to run fine too with the default CMakeLists.txt. There’s one ā€œrowā€ of the sprite test that looks a little glitchy, unless it was intentional, but otherwise the new functionality seems to work.

I wonder if you were using a different version of the Pico SDK, or were building for a target other thatn pico2_w? I’ve been using version 2.2.0.

Thanks you for your remark, you are absolutely right, sorry, it seems I used pico2 as PICO_BOARD. pico2_w works like charm. Forget my ā€œcorrectionā€, please.

I’m using the lastest version of Pico SDk (2.2.0). I’m compiling and testing only for PiOC2W. I haven’t tried it with Pico2 or Pico.
I have created a new branch (ā€œdevā€) that I’m using to save my work in progress.I am currently working on using DMA to send data to the display. I’m also moving the management of sprite and tile graphics to core1. I However in this moment the DMA is synchronous; I’m working to making it asynchronous.

2 Likes

I just updated the main branch with the latest changes from the DEV branch. I removed the double buffer management for a single buffer that is never destroyed but updated. Modified the sprite redraw routine. Moved all graphics procedures to core1. Data transfer to the LCD is done via semi-asynchronous DMA. Core0 and Core1 communicate via a FIFO command buffer. The glitch seems to be fixed. I hope.

1 Like

I should draw your attention to this note in the SDK documentation:

The inter-core FIFOs are a very precious resource and are frequently used for SDK functionality (e.g. during core 1 launch or by the lockout functions). Additionally they are often required for the exclusive use of an RTOS (e.g. FreeRTOS SMP). For these reasons it is suggested that you do not use the FIFO for your own purposes unless none of the above concerns apply; the majority of cases for transferring data between cores can be eqaully well handled by using a queue

Thanks a lot. I missed this information. I’ll be change the communication.

1 Like

Modified communication between cores. Replaced inter-core FIFOs with queues to comply with the specifications indicated on PICO SDK (thanks BlairLeduc). Initial tests show that communication is slightly slower than FIFO management. Obviously, the code is not optimized.

Added a new command ā€œtedā€. This is a simple a text editor with a four functionalities: Load (F1) Save AS (F2), Save (F3). Press F6 to see a list of files in the current directory. I wanted like to try to create a simple editor.

Very interesting updates, works well and compiled without issue on my setup. I am curious about the DMA thing for the screen updates, does it improve performance significantly ? I am looking at ā€œportingā€ some graphics heavy thing to the PicoCalc and was wondering if it was worth looking into it ?

And BTW I don’t know if you looked at it but the ā€œofficialā€ ClockworkPi Shapones port (the NES emulator on the SD) seems to be using some PIO and DMA to good effect, check the picocalc.cpp file, it is lightly commented but looks interesting.

2 Likes

Thanks for the information about Shapones (NES) I’ll look it.

From official Pico SDK documentation:
The DMA data throughput is significantly higher than the RP-series processors. The DMA can perform one read access and one write access, up to 32 bits in size, every clock cycle.

Key DMA Characteristics:

  1. Maximum theoretical throughput: 1 read + 1 write (up to 32 bits) per clock cycle Raspberry Pi
  2. Parallelism: 12 independent DMA channels available Raspberry Pi
  3. Zero CPU overhead: DMA leaves processors free to attend to other tasks or enter low-power sleep states Raspberry PiAPS

Thanks for your feedback.

In a forum an user shared concrete results for a 320x240 RGB565 LCD display:

In my example: the Core 0 continue calculations while Core 1 + DMA handle the display. In current version the DMA is yet semi-asynchronous. I have noticed improvements in performance compared to using only the CPU for data transfer. There are some other optimisation to do.

Cool, thanks for the details, that seems really promising !

1 Like

@BlairLeduc Hello… I just released a small project (port of runCPM) made from your framework, it works great !

I found a microscopic bug in clib.c and made a PR for you.

Thank you for the great job !

jF

1 Like

Hi,

Next to come: an onboard C compiler by a freaking good programmer (not me !)

Best wishes

2 Likes