I have project that includes a '.lib' file. The library contains separate modules like adc.c, i2c.c, tmr.c...
The interrupt routines are placed in their corresponding modules. The interrupt vectors are created for the adc and i2c modules just fine, but the timer isr vector's are not there when looking at the disassembly. The interrupt functions are present in the code just not the 'LJMP' at 0x0B and 0x1B. I've tried moving around the order of the functions, and removing all but the interrupt code but the interrupt vectors are still not added.
Has any one seen this before or having any suggestions to fix this?
Example:
///adc.c
#pragma nomodp2 void adc_isr() interrupt 14 { ADCON1 = (ADCON1 & 0xF7); ADCON0 = (ADCON0 & 0xF7); } #pragma modp2
///tmr.c
#pragma nomodp2 void timer_zero_isr () interrupt 1 using 2 { MISO = ~MISO; puts ("tmr zero intrpt"); TF0 = 0; } void timer_one_isr () interrupt 3 using 2 { if (TF1) puts ("tmr one intrpt"); } #pragma modp2
C_STARTUP: C:0x0000 0213A0 LJMP C:13A0 C:0x0003 00 NOP C:0x0004 00 NOP C:0x0005 00 NOP C:0x0006 00 NOP C:0x0007 00 NOP C:0x0008 00 NOP C:0x0009 00 NOP C:0x000A 00 NOP C:0x000B 00 NOP C:0x000C 00 NOP C:0x000D 00 NOP C:0x000E 00 NOP C:0x000F 00 NOP C:0x0010 00 NOP C:0x0011 00 NOP C:0x0012 00 NOP C:0x0013 00 NOP C:0x001B 00 NOP C:0x001C 00 NOP C:0x001D 00 NOP ...
C:0x0022 00 NOP C:0x0023 020C73 LJMP uart_isr(C:0C73) C:0x0026 00 NOP C:0x0027 00 NOP ...
C:0x0031 00 NOP C:0x0032 00 NOP C:0x0033 0209E9 LJMP i2c_isr(C:09E9)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ P89LPC935 IDE-Version: µVision3 V3.30a Tool Version Numbers: Toolchain Path: C:\Keil\C51\BIN\ C Compiler: C51.Exe V8.02 Assembler: AX51.Exe V3.01 Linker/Locator: LX51.Exe V4.05 Librarian: LIBX51.Exe V4.24
Since the compiler works, what about the library. Is it correctly made? Do you have the Source? ( It looks like yes) Are you calling any functions from the library? The Linker will not link unused Units in the are not used.
I'm using the IDE to create the library and the only think I've changed from the default setting is adding REMOVEUNUSED, so I'm not sure if the IDE correctly assembles all the OBJ files into the library.
"The Linker will not link unused Units in the are not used."
The problem persists even when I use other functions that are in the timer module.
It looks like when the ISR function is directly under a function that's not being called the interrupt vector is not addded.
Workaround: Placing each ISR function in a seperate file seems to work.
Placing each ISR function in a seperate file seems to work. indeed it does, however that will lead to very unstructured code. what I do during development to ensure that all ISR's get included regardless is as follows (using usb as an example):
main: call InitUSB
in usb module if nothing else void InitUSB(void)
{ }
.... void USBisr(void) interrupt n using x
of course, when developent is complete some other routine in the USB module will be called from main() and if the InitUSB is still 'empty' I may remove it, but since it is part of initialization it does not hurt to leave it.
Erik