This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ARM interrupt handler and initialization example in C ( bare-metal no OS ) ?

Has any one done this with no OS, no Linux, no SYS/BIOS and no Starterware ? Just straight C with no library dependencies?

Without an example it is hard to get started; entry address generators, stack setup, IRQ, FIQ, EABASE, etc..  An example would help very much.

Thanks in advance, 

-Ed

  • Hi Ed,
     
    TI does not provide such examples. The closest you can use for reference is Starterware.
  • Thank you for the reply.

    Do you know if StarterWare generate C or assembly source that I can use to learn the steps required to setup interrupts and handlers?  For example a UART or GPIO IRQ?

    -Ed

  • You can freely download it from here: http://software-dl.ti.com/dsps/dsps_public_sw/am_bu/starterware/latest/index_FDS.html. It's in source code, as far as I know.

  • I downloaded StarterWare.  In an effort to reduce an ISR in C to it's simplest form I wrote the code below.

    Can anyone please offer suggestions? What is missing? What is incorrect?  I am pretty sure the interrupt vector setup is plain wrong but can find no examples..

    The timer runs and rolls over at 0x0000FFFF but no ISR called?

    File: main.cpp

    /// timer1 64-bit mode interrupt handler connected to TINT2 innterupt=#34
    /// \todo I think I need to ACK it once I get working
    interrupt void interruptHandlerTimer1(void) {
    	printf("\n [* ISR *] \n");
    }
    
    // Minimal timer IRQ demonstration ( non-functioning )
    //
    // Running under CCS v5.5 JTAG debugger Blackhawk USB510L
    // I don't want to say which EVM
    // or the TI forum moderator will move this post to the digital media ghost town
    // forum where seldom is heard an encouraging word, or any word period.
    /// Please don't make me go back there! ;-)
    ///
    /// \remarks The GEL file is doing much initialization I do not yet understand.
    /// for me but was hoping this would get me started
    void main(void) {
    
    	TIMER1 ->TCR = 0x00000000;
    	// TGCR: TIMMODE=0 64-bit GP, TIM34RS=TIM12RS=1
    	TIMER1 ->TGCR = 0x00000003;
    	TIMER1 ->TIM34 = 0x00000000;
    	TIMER1 ->TIM12 = 0x00000000;
    	TIMER1 ->PRD34 = 0x00000000;
    	TIMER1 ->PRD12 = 0x0000ffff;
    	// TCR: inc until period match, then reset
    	TIMER1 ->TCR = (2 << 6);
    
    	// Should this work for setting interrupt vectors ?
    	// AINTC ->EABASE located @ 0x00000000
    	uint32_t** ptrEabase = (uint32_t**) (AINTC ->EABASE);
    	ptrEabase[34] = (uint32_t*) (interruptHandlerTimer1);
    
    	// Set INT34 TINT2 to IRQ priority 2
    	AINTC ->INTPRI4 = 0x00000200;
    	// Enable INT34
    	AINTC ->EINT1 = (1 << (34 - 32));
    
    	// Enable IRQ in CPSR
    	asm("    mrs     r0, cpsr");
    	asm("    bic     r0, r0, #0x80");
    	asm("    msr     cpsr_c, r0");
    
    	// I expected to see " [* ISR *] " print
    	// when TIMER1->TIM12 reaches 0x0000ffff
    	while (1) {
    		printf("%08x %08x\r\n", TIMER1 ->TIM34, TIMER1 ->TIM12);
    	}
    }

    Thanks in advance,

    -Ed