Noobie ? - C3400: Cannot initialize object (destination too small)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Noobie ? - C3400: Cannot initialize object (destination too small)

2,368 Views
PeteS
Contributor I

Hey guys,

 

I am relatively new to program so please forgive me if this is a dumb question. I am using a mc9s12dg128 uP. I have a basic handle on using the A to D inputs and simple IO. I have run into some issues now that I have tried to use the A to D registers via interrupt. I am getting a compile error of "C3400: Cannot initialize object (destination too small)"

 

This is my interrupt table:

**************************************************************************

 

#include "constants.h"
#include "types.h"
#include "external.h"
#include "globals.h"                                  

extern void near _Startup(void);       /* Startup routine */                                


#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */
__interrupt void UnimplementedISR(void)
{
   /* Unimplemented ISRs trap.*/
}

typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xFF80 = {     /* Interrupt table */
        UnimplementedISR,                 /* vector 0x40 */
        UnimplementedISR,                 /* vector 0x3F */
        UnimplementedISR,                 /* vector 0x3E */
        UnimplementedISR,                 /* vector  0x3D */
        UnimplementedISR,                 /* vector 0x3C */
        UnimplementedISR,                 /* vector 0x3B */
        UnimplementedISR,                 /* vector 0x3A */
        UnimplementedISR,                 /* vector 0x39 */
        UnimplementedISR,                 /* vector 0x38 */
        UnimplementedISR,                 /* vector 0x37 */
        UnimplementedISR,                 /* vector 0x36 (PWM Emergency Shutdown) */
        UnimplementedISR,                 /* vector 0x35 (Port P Interrupt) */
        UnimplementedISR,                 /* vector 0x34 (CAN4 Transmit) */
        UnimplementedISR,                 /* vector 0x33 (CAN4 Receive)  */
        UnimplementedISR,                 /* vector 0x32 (CAN4 Errors)   */
        UnimplementedISR,                 /* vector 0x31 (CAN4 Wake-Up)  */
        UnimplementedISR,                 /* vector 0x30 (Reserved) */
        UnimplementedISR,                 /* vector 0x2F (BF General)         */
        UnimplementedISR,                 /* vector 0x2E (BF Synchronization) */
        UnimplementedISR,                 /* vector 0x2D (BF Receive)         */
        UnimplementedISR,                 /* vector 0x2C (BF Receive FIFO Not Empty) */
        UnimplementedISR,                 /* vector 0x2B (CAN1 Transmit) */
        UnimplementedISR,                 /* vector 0x2A (CAN1 Receive)  */
        UnimplementedISR,                 /* vector 0x29 (CAN1 Errors)   */
        UnimplementedISR,                 /* vector 0x28 (CAN1 Wake-Up)  */
        UnimplementedISR,                 /* vector 0x27 (CAN0 Transmit) */
        UnimplementedISR,                 /* vector 0x26 (CAN0 Receive)  */
        UnimplementedISR,                 /* vector 0x25 (CAN0 Errors)   */
        UnimplementedISR,                 /* vector 0x24 (CAN0 Wake-Up)  */
        UnimplementedISR,                 /* vector 0x23 (FLASH) */
        UnimplementedISR,                 /* vector 0x22 (EEPROM) */
        UnimplementedISR,                 /* vector 0x21 (Reserved) */
        UnimplementedISR,                 /* vector 0x20 (SPI1) */
        UnimplementedISR,                 /* vector 0x1F (IIC Bus) */
        UnimplementedISR,                 /* vector 0x1D (BDLC) */
        UnimplementedISR,                 /* vector 0x1C (CRG PLL Lock) */
        UnimplementedISR,                 /* vector 0x1B (Pulse Accumulator B Overflow) */
        UnimplementedISR,                 /* vector 0x1A (Modulus Down Counter Underflow) */
        UnimplementedISR,                 /* vector 0x19 (PORT H) */
        UnimplementedISR,                 /* vector 0x18 (PORT J) */
        _AD1Conversion,                    /* vector 0x17 (ATD1) */
        _AD0Conversion,                    /* vector 0x16 (ATD0) */
        UnimplementedISR,                 /* vector 0x15 (SCI1) */
        UnimplementedISR,                 /* vector 0x14 (SCI0) */
        UnimplementedISR,                 /* vector 0x13 (SPI0) */
        UnimplementedISR,                 /* vector 0x12 (Pulse Accumulator Input Edge)  */
        UnimplementedISR,                 /* vector 0x11 (Pulse Accumulator A Overflow)  */
        UnimplementedISR,                 /* vector 0x10 (TOF, timer overflow interrupt) */
        UnimplementedISR,                 /* vector 0x0F (C7I, timer interrupt channel 7)  */
        UnimplementedISR,                 /* vector 0x0E (C6I, timer interrupt channel 6)  */
        UnimplementedISR,                 /* vector 0x0D (C5I, timer interrupt channel 5)  */
        UnimplementedISR,                 /* vector 0x0C (C4I, timer interrupt channel 4)  */
        UnimplementedISR,                 /* vector 0x0B (C3I, timer interrupt channel 3)  */
        UnimplementedISR,                 /* vector 0x0A (C2I, timer interrupt channel 2)  */
        UnimplementedISR,                 /* vector 0x09 (C1I, timer interrupt channel 1)  */
        UnimplementedISR,                 /* vector 0x08 (C0I, timer interrupt channel 0)  */
        UnimplementedISR,                 /* vector 0x07 (RTIE - Real-Time Interrupt) */
        UnimplementedISR,                 /* vector 0x06 (IRQ)  */
        UnimplementedISR,                 /* vector 0x05 (XIRQ - External Interrupt) */
        UnimplementedISR,                 /* vector 0x04 (SWI - Software Interrupt)  */
        UnimplementedISR,                 /* vector 0x03 (Unimplemented Opcode Trap) */
        UnimplementedISR,                 /* vector 0x02 (COP Watchdog Reset)        */
        UnimplementedISR,                 /* vector 0x01 (Clock Monitor Reset)       */
        _Startup                          /* vector 0x00 (Power-On/Staru-Up RESET)   */
   };

****************************************************************************

 

 

 

Here are the interrupt functions I want to call:

**************************************************************************

 

 __interrupt void _AD0Conversion(void){

    extern uint channel[AD_CHAN][AD_SIZE];
    static byte index=0;
    
    channel[CHANNEL_0_0][index] = ATD0DR0;            
    channel[CHANNEL_0_1][index] = ATD0DR1;    
    channel[CHANNEL_0_2][index] = ATD0DR2;    
    channel[CHANNEL_0_3][index] = ATD0DR3;    
    channel[CHANNEL_0_4][index] = ATD0DR4;                        
    channel[CHANNEL_0_5][index] = ATD0DR5;
    channel[CHANNEL_0_6][index] = ATD0DR6;    
    channel[CHANNEL_0_7][index] = ATD0DR7;        

    if (++index >= AD_SIZE) {
                index = 0;
        }
    }

 

 

 __interrupt void _AD1Conversion(void){

    extern uint channel[AD_CHAN][AD_SIZE];
    static byte index=0;
    
    channel[CHANNEL_1_0][index] = ATD0DR0;            
    channel[CHANNEL_1_1][index] = ATD0DR1;    
    channel[CHANNEL_1_2][index] = ATD0DR2;    
    channel[CHANNEL_1_3][index] = ATD0DR3;    
    channel[CHANNEL_1_4][index] = ATD0DR4;                        
    channel[CHANNEL_1_5][index] = ATD0DR5;
    channel[CHANNEL_1_6][index] = ATD0DR6;    
    channel[CHANNEL_1_7][index] = ATD0DR7;        

    if (++index >= AD_SIZE) {
                index = 0;
        }
    }

****************************************************************************

 

 Any idea or tips?

 

Thanks,

Pete

 

 

 

 

Message Edited by PeteS on 2009-10-30 03:32 AM
Labels (1)
0 Kudos
6 Replies

700 Views
CompilerGuru
NXP Employee
NXP Employee

In the banked memory model functions are allocated with a 24 bit address,

but the _vect table only contains 16 bit entries. Therefore the compiler has to know that

the functions are either interrupt handler or are allocated in a __NEAR_SEG, best both.

Just having a void _AD0Conversion(void) declaration visible causes that error.

 

Daniel

 

E.g.:

 

 

#pragma push#pragma CODE_SEG __NEAR_SEG NON_BANKED
__interrupt void _AD0Conversion(void);#pragma poptypedef void (*near tIsrFunc)(void);const tIsrFunc _vect[] @0xFF80 = {        _AD0Conversion};

 

 

 

0 Kudos

700 Views
PeteS
Contributor I

Daniel,

 

I tired what you had suggested. This rectified the issue of error C3400, but has now lead to another error of:

 

L1907: Fixup overflow in _vect, to _AD1ConversionComplete type 1, at offset 0x50

L1907: Fixup overflow in _vect, to _AD0ConversionComplete type 1, at offset 0x52

 

 

My interrupt table now reads:



extern void near _Startup(void);       /* Startup routine */                               


#pragma push
#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */
__interrupt void _AD0Conversion(void);
__interrupt void _AD1Conversion(void);
__interrupt void UnimplementedISR(void)
{
   /* Unimplemented ISRs trap.*/
}
#pragma pop

typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xFF80 = {     /* Interrupt table */
        UnimplementedISR,                 /* vector 0x40 */
        UnimplementedISR,                 /* vector 0x3F */
        UnimplementedISR,                 /* vector 0x3E */
        UnimplementedISR,                 /* vector  0x3D */
        UnimplementedISR,                 /* vector 0x3C */
        UnimplementedISR,                 /* vector 0x3B */
        UnimplementedISR,                 /* vector 0x3A */
        UnimplementedISR,                 /* vector 0x39 */
        UnimplementedISR,                 /* vector 0x38 */
        UnimplementedISR,                 /* vector 0x37 */
        UnimplementedISR,                 /* vector 0x36 (PWM Emergency Shutdown) */
        UnimplementedISR,                 /* vector 0x35 (Port P Interrupt) */
        UnimplementedISR,                 /* vector 0x34 (CAN4 Transmit) */
        UnimplementedISR,                 /* vector 0x33 (CAN4 Receive)  */
        UnimplementedISR,                 /* vector 0x32 (CAN4 Errors)   */
        UnimplementedISR,                 /* vector 0x31 (CAN4 Wake-Up)  */
        UnimplementedISR,                 /* vector 0x30 (Reserved) */
        UnimplementedISR,                 /* vector 0x2F (BF General)         */
        UnimplementedISR,                 /* vector 0x2E (BF Synchronization) */
        UnimplementedISR,                 /* vector 0x2D (BF Receive)         */
        UnimplementedISR,                 /* vector 0x2C (BF Receive FIFO Not Empty) */
        UnimplementedISR,                 /* vector 0x2B (CAN1 Transmit) */
        UnimplementedISR,                 /* vector 0x2A (CAN1 Receive)  */
        UnimplementedISR,                 /* vector 0x29 (CAN1 Errors)   */
        UnimplementedISR,                 /* vector 0x28 (CAN1 Wake-Up)  */
        UnimplementedISR,                 /* vector 0x27 (CAN0 Transmit) */
        UnimplementedISR,                 /* vector 0x26 (CAN0 Receive)  */
        UnimplementedISR,                 /* vector 0x25 (CAN0 Errors)   */
        UnimplementedISR,                 /* vector 0x24 (CAN0 Wake-Up)  */
        UnimplementedISR,                 /* vector 0x23 (FLASH) */
        UnimplementedISR,                 /* vector 0x22 (EEPROM) */
        UnimplementedISR,                 /* vector 0x21 (Reserved) */
        UnimplementedISR,                 /* vector 0x20 (SPI1) */
        UnimplementedISR,                 /* vector 0x1F (IIC Bus) */
        UnimplementedISR,                 /* vector 0x1D (BDLC) */
        UnimplementedISR,                 /* vector 0x1C (CRG PLL Lock) */
        UnimplementedISR,                 /* vector 0x1B (Pulse Accumulator B Overflow) */
        UnimplementedISR,                 /* vector 0x1A (Modulus Down Counter Underflow) */
        UnimplementedISR,                 /* vector 0x19 (PORT H) */
        UnimplementedISR,                 /* vector 0x18 (PORT J) */
        _AD1Conversion,        /* vector 0x17 (ATD1) */
        _AD0Conversion,        /* vector 0x16 (ATD0) */
        UnimplementedISR,                 /* vector 0x15 (SCI1) */
        UnimplementedISR,                 /* vector 0x14 (SCI0) */
        UnimplementedISR,                 /* vector 0x13 (SPI0) */
        UnimplementedISR,                 /* vector 0x12 (Pulse Accumulator Input Edge)  */
        UnimplementedISR,                 /* vector 0x11 (Pulse Accumulator A Overflow)  */
        UnimplementedISR,                 /* vector 0x10 (TOF, timer overflow interrupt) */
        UnimplementedISR,                 /* vector 0x0F (C7I, timer interrupt channel 7)  */
        UnimplementedISR,                 /* vector 0x0E (C6I, timer interrupt channel 6)  */
        UnimplementedISR,                 /* vector 0x0D (C5I, timer interrupt channel 5)  */
        UnimplementedISR,                 /* vector 0x0C (C4I, timer interrupt channel 4)  */
        UnimplementedISR,                 /* vector 0x0B (C3I, timer interrupt channel 3)  */
        UnimplementedISR,                 /* vector 0x0A (C2I, timer interrupt channel 2)  */
        UnimplementedISR,                 /* vector 0x09 (C1I, timer interrupt channel 1)  */
        UnimplementedISR,                 /* vector 0x08 (C0I, timer interrupt channel 0)  */
        UnimplementedISR,                 /* vector 0x07 (RTIE - Real-Time Interrupt) */
        UnimplementedISR,                 /* vector 0x06 (IRQ)  */
        UnimplementedISR,                 /* vector 0x05 (XIRQ - External Interrupt) */
        UnimplementedISR,                 /* vector 0x04 (SWI - Software Interrupt)  */
        UnimplementedISR,                 /* vector 0x03 (Unimplemented Opcode Trap) */
        UnimplementedISR,                 /* vector 0x02 (COP Watchdog Reset)        */
        UnimplementedISR,                 /* vector 0x01 (Clock Monitor Reset)       */
        _Startup                          /* vector 0x00 (Power-On/Staru-Up RESET)   */
   };

 

My interrupt functions still read:

 

 

__interrupt void _AD0Conversion(void){

    static byte index=0;
    PORTA_BIT1 = 0x01;
    channel[AD_CHAN][AD_SIZE];

  
    channel[CHANNEL_0_0][index] = ATD0DR0;          
    channel[CHANNEL_0_1][index] = ATD0DR1;  
    channel[CHANNEL_0_2][index] = ATD0DR2;  
    channel[CHANNEL_0_3][index] = ATD0DR3;  
    channel[CHANNEL_0_4][index] = ATD0DR4;                      
    channel[CHANNEL_0_5][index] = ATD0DR5;
    channel[CHANNEL_0_6][index] = ATD0DR6;  
    channel[CHANNEL_0_7][index] = ATD0DR7;      

    if (++index >= AD_SIZE) {
        index = 0;
        }
    }


__interrupt void _AD1Conversion(void){
    static byte index=0;
    PORTA_BIT2 = 0x01;
    channel[AD_CHAN][AD_SIZE];

  
    channel[CHANNEL_1_0][index] = ATD1DR0;          
    channel[CHANNEL_1_1][index] = ATD1DR1;  
    channel[CHANNEL_1_2][index] = ATD1DR2;  
    channel[CHANNEL_1_3][index] = ATD1DR3;  
    channel[CHANNEL_1_4][index] = ATD1DR4;                      
    channel[CHANNEL_1_5][index] = ATD1DR5;
    channel[CHANNEL_1_6][index] = ATD1DR6;  
    channel[CHANNEL_1_7][index] = ATD1DR7;      

    if (++index >= AD_SIZE) {
        index = 0;
        }
    }

It appears from some of the other posts I have read on the forums that placing the interrupt functions in the NON_BANKED portion of memory has fixed the issue. Any ideas as to why the error is present in this case?

 

Thanks for all the help so far!!

 

Pete 
 

Message Edited by PeteS on 2009-11-02 03:27 AM
0 Kudos

700 Views
pgo
Senior Contributor V

Dear Pete,

 

Repeat the code location pragmas on the actual functions.

 

As a general rule I would put the prototypes (with the pragmas) in a header file and include in both files.  This would produce an inconsistent segment error during compilation rather than a linker overflow error later (which I prefer anyway).

 

bye

 

0 Kudos

700 Views
PeteS
Contributor I

pgo,

 

Thanks for the response. I did what you suggested and it will compile and run on my demo board now. However, I do not believe the ISRs are ever being called. I can be sure of this because I never get a returned A to D value and because I have set an LED to turn on within the ISR function AD0Conversion as well as AD1Conversion that never illuminates. I am using serial monitor to debug. Will serial monitor allow the ISRs to run? Any ideas? Thanks for all the help so far. I am new to interrupts and could use all the help I can get!

 

 

Pete  

0 Kudos

700 Views
pgo
Senior Contributor V

Dear Pete,

 

Things to check:

 

Enabled system level interrupts (EnableInterrupts)

Enabled interrupts from the ADCs

Initiate a conversion on the ADC (I think the interrupts are generated when a conversionm completes).

 

I've not used the ADC with interrupts so can't really suggest  much more!

 

If you post complete code (zip file?) you may get a more complete response.

 

bye

0 Kudos

700 Views
PeteS
Contributor I

pgo,

 

Thanks again for the reply. I have checked those areas and think they are correct. I have also started a new post entitled "A to D interrupt issuess" which better describes the issue at this point since I no longer have compiler errors.

 

Thanks,

Pete

0 Kudos