Dear Alex,
> I see that the original has in these cases
>
> any const __attribute__ ((__aligned__(2*WORD))) Rom[] = {
>
> Does this make any difference? After all, I would expect 'WORD' to be 4
> on a 32-bit machine.
It seems to be making a difference. When I simply print the size of `WORD'
(renamed to `PICOLISP_WORD' to resolve a conflict with one of avr32's
device defines) I get 4. Clear.
However, when I don't explicitly use the variable attribute, I run into an
"Unaligned memory" fault. Is there another way around this?
> Perhaps a stack problem? Also, I'm not sure if allocating 's' in the
> middle of a code body is right. I always did that in an explicit code
> block { .. }, but perhaps current C versions can handle this.
>
> Perhaps you can debug what string exactly you get in 's'?
`s[]' holds the data correctly. The code was indeed working as expected. I
felt silly. It turns out that I had two copies of `pio-pin-setdir' (typo).
I simply
had to change it to `pio-port-setdir'.
pio-pin-setdir {plisp_pio_pin_setdir} <--
pio-pin-setpull {plisp_pio_pin_setpull}
pio-pin-setval {plisp_pio_pin_setval}
pio-pin-sethigh {plisp_pio_pin_sethigh}
pio-pin-setlow {plisp_pio_pin_setlow}
pio-pin-getval {plisp_pio_pin_getval}
pio-pin-setdir {plisp_pio_port_setdir} <--
R
P.S. I will also try to run this on my stm32f103re and post the results
here.
On 25 February 2015 at 12:54, Alexander Burger <[email protected]> wrote:
> Hi Raman,
>
> thanks for the report!
>
> > 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"
> > };
>
> I see that the original has in these cases
>
> any const __attribute__ ((__aligned__(2*WORD))) Rom[] = {
>
> Does this make any difference? After all, I would expect 'WORD' to be 4
> on a 32-bit machine.
>
>
>
> > 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);
> > PIO_CHECK(ret);
> >
> > 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