![]() |
Forum Index : Microcontroller and PC projects : memory pack question
Author | Message | ||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5056 |
All, This is a generic question about MEMORY PACK and MEMORY UNPACK. These commands can be used to pack data into 64 bit integers (i.e. 8 bytes per integer). What I am trying to achieve is packing text (ASCII data) for use in PIO FIFO's. The FIFO's are 32 bit wide, and a DMA of integers will fill the PIO FIFO 32 bits at at time (2 FIFO locations per integer). But I need to fill the FIFO with text in a$. I already experimented with peek(varaddr a$) as sourceaddr% and an array%() as destination. But I never seem to get the right mapping of text into the integer to match the FIFO. What I need is MSByte LSbyte 0 0 0 a$:2 0 0 0 a$:1 I currently use a loop (slow) to transfer character for character into integers (1 char per integer), and then pack the integers in a new array (2 char per integer). But the loop is slow (when the string is long). So I wonder if there is a way to avoid the loop, and use either a single MEMORY PACK, or 2 MEMORY PACK's ... Any advise ? Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10232 |
s$="1234567890" a%=Peek(varaddr s$)+1 Dim o%(4) b%=Peek(varaddr o%()) Memory copy a%,b%,10,1,4 For i=0 To 4 Print Hex$(o%(i)) Next |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5056 |
Wauw that is fast.... tested: it works... Thanks a lot. Can use this the other way around also. Volhout Edited 2025-01-15 20:46 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4301 |
That form of MEMORY COPY doesn't seem to be in the manual. Would I be correct in assuming it is a byte copy and that the last two parameters are the optional source and destination increments (c.f. MEMORY COPY INTEGER and MEMORY COPY FLOAT). Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10232 |
Yes, it's a manual omission. I've asked Geoff to update. You could also do what Harm wants with an UNPACK from char to integer and then a pack from integer to word. Bit clunkier but works fine. s$="1234567890" a%=Peek(varaddr s$)+1 Dim o%(9),oo%(4) Memory unpack a%,o%(),10,8 Memory pack o%(),oo%(),10,32 For i=0 To 4 Print Hex$(oo%(i)) Next |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4301 |
Thanks Peter, more stuff to go in MMB4L post v0.7. Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 459 |
To play music in MOD format, a MODBUFFER is used, which is located in the Pico flash, and each time a composition is loaded, this area of flash memory is reflashed, which is not good for intensive listening to many compositions. Is it possible to make it so that if there is a PSRAM, this MODBUFFER is located in it? |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5056 |
Javavi, A system is in place to only reprogram when changed. Volhout PicomiteVGA PETSCII ROBOTS |
||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 459 |
Yes, but I wrote a music player and just listen to this music for hours and the compositions change one after another continuously. And I'm already starting to worry about the state of Pico's flash memory! That's why I'm saying that it wouldn't be bad to have this MODBUFFER in RAM in a configuration with PSRAM. Edited 2025-01-16 03:12 by javavi |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10232 |
Wrong thread - but good idea ![]() |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |