Linear Memory on a PIC

A project log for WAV-1K

An SD card reader and WAV file player in 1KB of code.

luciolucio 01/05/2017 at 09:410 Comments

Porting (down) a C code base to ASM has been a great exercise for my ASM muscle that was getting really close to complete atrophy!

Even though some of the work turned out to be rather low level repetitive translation of the C constructs to PIC ASM, the need to handle two (overlapping) large RAM buffers (512 bytes each) turned out to be a good test of the agility of the modern PIC (14-bit) core.

The PIC16F18855, like most/all of the PIC models released in the last five years, sports a fourth generation PIC core (Enhanced Mid Range or EMR or more simply the "F1") with an improved instruction set supposed to enable better C compiler efficiency.

In fact I had never programmed any of the devices in this (large) family in assembly, but only exclusively in C!

So this was my first real experience with "Linear Memory on a PIC" and it turned out to be quite simple and powerful. You will find a few "bankselect" statements left only in the initial peripherals configurations, where it is still most convenient, but all the rest of the code is addressing RAM using the "linear pointers"!

As a more general note, the player code had been extensively tested and hacked in several previous projects (in C), so the debugging phase turned out to be focused exclusively on my general ASM level of "rustiness".