- 3D-Druck Einstieg und Tipps         
Ergebnis 1 bis 2 von 2

Thema: ARM 7, Keil und Interrupt

  1. #1

    ARM 7, Keil und Interrupt

    Anzeige

    E-Bike
    Hallo!

    Ich versuche auf einem ARM7 Intterupts zu benutzen. Der Timer läuft richtig, nur Interrupts bekomme ich noch nicht... Welche Register hab ich vergessen?

    Danke schon einmal!


    Code:
    #include <LPC21xx.H>
    // olimex LPC-P2129: LEDs on P0.12/P0.13 (active low)
    #define LED1PIN  	12
    #define LED2PIN  	13
    
    void T0IRQ (void) __irq;
    
    unsigned short switcher = 0;
    
    int main(void)
    {
    
    //INIT
    	// define LED-Pins as outputs
    	IODIR0 |= 1<<LED1PIN;
    	// set Bits = LEDs off (active low) 
    	IOSET0 = 1<<LED1PIN; 
    	//Sets peripheral clock = system clock
    	VPBDIV=0x01;
    	//initialise timer 0
    	T0TCR = 0x0;
    	T0TC  = 0x0;
    	T0PR  = 0x0;
    	T0PC  = 0x0;
    	T0MR0 = 0xFF;
    
    	//Reset and interrupt on match
    	T0MCR = 0x3;
    
    	//TELL VIC WHAT TO DO!
    	VICIntSelect = 0x0; //NO FIQs
    	VICIntEnable = 0x4;  //TIMER 0 on board
    	
    	//Give the VIC the adress
    	VICVectAddr0=(unsigned long) T0IRQ;
    
    	//start the timer
    	T0TCR=0x1;
    	while(1){}
    }
    
    
    
    
    void T0IRQ (void) __irq
    {
    	//TOGGLE LED
    	if(switcher) {
    		IOSET0 = 0<<LED1PIN;
    		switcher = 0;
    	} else {
    		switcher = 1;
    		IOSET0 = 1<<LED1PIN;
    	}
    	
    
    	//RESET NECCESSARY TIMER VALUES
    	T0IR=0x1;
    	
    	//END ISR
    	VICVectAddr=0xff;
    }

  2. #2
    Falls einer mal vor dem selben Problem steht:

    Dieser Code funktioniert...

    Code:
    /************************************************************/
    /* PROJECT NAME: INTERRUPTS	                                */
    /* Project:      LPC2100                                    */
    /* Engineer:     S. Stefanowitsch                           */
    /* Filename:     main.c                                     */
    /* Language:     C                      	                */
    /* Compiler:     Keil ARM	V2.00b		                    */
    /* Assembler:    				                            */
    /*                                                          */
    /************************************************************/
    
    #include <LPC21xx.H>
    // olimex LPC-P2129: LED on P0.12 (active low)
    #define LED1PIN  	12
    
    void T0IRQ (void) __irq;
    unsigned short switcher = 0;
    
    int main(void)
    {
    //INIT
    	// define LED-Pins as outputs
    	IODIR0 |= 1<<LED1PIN;
    	// set Bits = LEDs off (active low) 
    	IOSET0 = 1<<LED1PIN; 
    	//Sets peripheral clock = system clock
    	VPBDIV=0x01;
    	//initialise timer 0
    	T0TCR = 0x0;
    	T0TC  = 0x0;
    	T0PR  = 0x0;
    	T0PC  = 0x0;
    	T0MR0 = 0x1FF;
    
    	//Reset and interrupt on match
    	T0MCR = 0x3;
    	
    	//INitialise the VIC
    	VICVectAddr4 = (unsigned long) T0IRQ;
    	VICVectCntl4= 0x24; //Allow This Vector, set is as IRQ Slot 4	
    	VICIntSelect = 0x0; //NO FIQs
    	VICIntEnable = 0x10;//TIMER 0 on board	
    	//start the timer
    	T0TCR=0x1;
    	while(1){}
    }
    
    
    void T0IRQ (void) __irq
    {
    	//TOGGLE LED
    	if(switcher) {
    		IOSET0 = 1<<LED1PIN;
    		switcher = 0;
    	} else {
    		IOCLR0 = 1<<LED1PIN;
    		switcher = 1;
    	}  
    	//RESART TIMER
    	T0IR=0x1;
    	//END ISR "Pseudo Write Operation"
    	VICVectAddr=0xff;
    }

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

fchao-Sinus-Wechselrichter AliExpress