So there is an annoying bug at the moment the macro defines for FSMC_BCR1
.. FSMC_BWTR3 all generate 'integer overflow' warnings when used. An
exemplar :
/* simple demonstrator - bug */
#include <stdint.h>
#include <libopencm3/stm32/fsmc.h>
void foo(void);
void
foo() {
uint32_t some_value;
some_value = (1 << 4) | FSMC_BCR_MBKEN | FSMC_BCR_WREN;
FSMC_BCR1 = some_value;
some_value = FSMC_BTR_DATASTx(6) | FSMC_BTR_ADDSETx(1);
FSMC_BTR1 = some_value;
}
Put this in a file (t.c works) and make the .o with the libopencm3 make
rules and you will get this:
$ make t.o
t.c: In function 'foo':
t.c:11:5: warning: integer overflow in expression [-Woverflow]
t.c:13:5: warning: integer overflow in expression [-Woverflow]
$
I believe the error comes in the nesting of the MMIO32 with offset defines
that are summing PERIPH_ANHB3_BASE to constants not marked as longs (or
perhaps not cast to uint32's) but haven't worked it out completely. In my
code I created new defines that didn't to math offsets and that worked fine
for my purposes.
I also spent some time writing a general purpose FSMC configurator routine
only to find that it's rather impractical to have all that code laying
about in your precious flash space when you use it once. So I've switched
to focusing on a tool called 'sysinit' which takes a config spec for the
chip and generates a '_sysinit()' function which calls out to main() when
done. For my code this replaces all the various clock_setup, gpio_setup
kinds of calls and catches things like GPIO overlap at config time rather
than run time (bit of a problem with that in my code, the LED is on the
wrong GPIO) and for the LCD I was using (that used FSMC to create
effectively a 16 bit parallel port out of the FSMC pins I realized that
general purpose FSMC code is challenging at best and quite possibly
impossible. Since presumably folks here have been thinking about this kind
of thing longer than I have I wonder what the consensus thoughts are.
--Chuck
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
libopencm3-devel mailing list
libopencm3-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libopencm3-devel