I am developing a program for an Analog Devices ADuC812 8051-compatible
(with extra features) micro, using SDCC, Win-bin release, since I haven't
been able to get any other version working - Haven't been able to compile a
fresh-out-of-cvs on my cygwin box (gcc-3.0, self-compiled - no trouble with
anything else), or on my Linux-Box (LM8.0, gcc-2.96).
Having got my program working, I decided to add more features to it, and in
doing so I made it not work any more. I'll elaborate later...
I'm unsure as to the reasons why the program doesn't work, but here's hoping
someone can help me.
My project is laid out in a number of source files, which are named as
main.c ==> the main() loop;
serial.c ==> serial i/i, interrupt driven;
adc.c ==> routines to control the on-board adc of the ADuC812;
dac.c ==> routines to control the on-board dac of the ADuC812;
intr.c ==> routines to use timer2 as a periodic interrupt.
My initial program was just main and serial, trying to get that working.
Eventually I got it going satisfactorily. The serial routines I use are
basically a rip-off of the serial.c available at the okr site, written by
Victoria Welch (who based her code on something written for keil).
Then, I got the adc and dac going, which seemed to work quite well - I had
the dac incrementing, feeding back to the adc, which was reading it and
spitting the result out the serial port.
All fine and good.
Then, I tried to add my periodic interrupt. This is when things started to
The initial version of intr.c used a call-back function passed as a
function-pointer to the init() routine. But this didn't seem to work, so I
tried it without, which seemed to work for a little while, but also stuffed
up other parts of the program...
Anyway, here's my questions:
1. Is it possible to use function pointers in sdcc, and if so, what are the
caveats? Can you use them in isr's, and what special options do you need to
compile with (I eventually used large memory model, external stack, and
nooverlay as the options, simply so I wouldn't have any conflict in memory
space). Do I need to specify the function as reentrant?
2. How does sdcc handle extra interrupts over and above 0-4 as specified in
the manual? Timer 2 is supposed to be interrupt 5, does this get placed in
the correct place in memory (0x2B), and even more importantly, if I were to
specify "interrupt 6" as an isr, will this get placed correctly at 0x33 (the
ADuC812 has an "interrupt 6" @ 0x33 for the ADC)?
3. My current serial port routine uses timer 1 for the baud rate generation,
while I've also seen timer 2 used, much more commonly, too. Should I swap
the baud rate gen to timer 2 and the periodic interrupt to timer 1?
4. I've noticed that packihx only does a partial job of packing the hex
file, there are still portions within the resultant hex file that are not
contiguous - is this normal, or does it indicate that there are overlapping
sections in the code?
5. Any other advice, especially when it comes to the ADuC812?
I'm happy to email code and a Makefile to anyone who is willing to help,
because quite frankly I'm at my wits' end...
Matthew van de Werken
CSIRO Exploration & Mining - Gravity Group
1 Technology Court - Pullenvale - Qld - 4069
ph: (07) 3327 4685 fax: (07) 3327 4455