Dear Alex, dear list, A very good morning!

It has been a while! I trust you are all doing well.

I finally have core miniPicoLisp (with the miniCodeROM enhancement) running
my Mizar32 (at32uc3a). While PicoLisp itself works out of the box, I had a
concerns about the microcontroller specific sections. I did exactly 2
changes to get
the MCU specific functions to work. I just wanted to check if I was doing
the right
thing (or if I could do it better). My init.s file looks like this [1]. I
have enabled the
functions at the end in my local copy.

1) The MCU specific functions (unlike regular PicoLisp functions) have long
(solely for consistency); e.g. `pio-pin-sethigh'. gen3m generates 64-bit
values for
them (ram.d). I forced `-m32' (gcc) on the compilation for gen3m.

2) I assumed step-1 should be sufficient but I ran into an "Unaligned
memory" fault
when I executed the build with step-1 alone. I then introduced variable
attributes for
`Rom' and `Ram' (included in main.c).

any const Rom[] __attribute__ ((aligned (8))) = {
   #include "rom.d"

any Ram[] __attribute__ ((aligned (8))) = {
   #include "ram.d"

Things are now (mostly) fine on Mizar32 but I'm not sure this is the right
way to fix
the problem. While it works on Mizar32, I'm not sure how it might respond
on stm32.
(64KB SRAM). Is there a better way to fix the problem?

I'm yet to test all MCU specific PicoLisp functions but I quickly found one
problem in
one of my functions - `pio-pin-setdir' (sets port pin direction; input or
output). The C
implementation internally uses bufString() to get the pin value to set.
Please see
sample below.

any plisp_pio_pin_setdir(any ex) {
   any x, y;
   // Some code here

   x = cdr(x);
   NeedSym(ex, y = EVAL(car(x)));
   char s[bufSize(y)];
   bufString(y, s);
   ret = pio_value_parse(s);

   plisp_pio_gen_setdir(ex, NULL, ret, PIO_PIN_OP, dir);
   return Nil;

I would then invoke my function like this:
(pio-pin-setdir *pio-output* 'PB_29)

Strange, but it looks like a part of 'PB_29 is getting stripped somehow.
The same
function call worked before miniCodeROM but now, Lisp tells me that 'PB_2'
is an
invalid port. I'm yet to see the bufString implementation but do you think
steps 1 &
2 are influencing this behaviour somehow?



Reply via email to