This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

interrupt cortex m-3


Hi,
     I have STM32 EVALUATION Kit and use ecos-2.0.I will try interrupt
this kit but not working properly.i mention my code below:


#include <pkgconf/hal.h>
#include <pkgconf/hal_cortexm.h>
#include <pkgconf/hal_cortexm_stm32.h>
#include <pkgconf/hal_cortexm_stm32_stm3210e_eval.h>
#ifdef CYGPKG_KERNEL
#include <pkgconf/kernel.h>
#endif

#include <cyg/infra/diag.h>
#include <cyg/infra/cyg_type.h>
#include <cyg/infra/cyg_trac.h>         // tracing macros
#include <cyg/infra/cyg_ass.h>          // assertion macros

#include <cyg/hal/hal_arch.h>           // HAL header
#include <cyg/hal/hal_intr.h>           // HAL header
#include <cyg/hal/var_io.h>

#include <pkgconf/system.h>
#include <cyg/hal/hal_io.h>
#include <cyg/kernel/kapi.h>
#include <stdio.h>

#define AFIO_EXTICR3	0x10

#define HAL_READ_UINT32( _register_, _value_ ) \
        ((_value_) = *((volatile CYG_WORD32 *)(_register_)))

#define HAL_WRITE_UINT32( _register_, _value_ ) \
        (*((volatile CYG_WORD32 *)(_register_)) = (_value_))



   //
   // Interrupt service routine for interrupt 1.
   //
 
cyg_uint32 hal_exti_isr1( cyg_uint32 vector, CYG_ADDRWORD data )
{
    CYG_ADDRESS base = CYGHWR_HAL_STM32_EXTI;
    cyg_uint32 imr, pr;
    
    printf("enter isr\n");
    // Get EXTI pending and interrupt mask registers
    HAL_READ_UINT32( base+CYGHWR_HAL_STM32_EXTI_IMR, imr );
    HAL_READ_UINT32( base+CYGHWR_HAL_STM32_EXTI_PR, pr );
    
    // Mask PR by IMR and lose ls 5 bits
    pr &= imr;
    pr &= 0xFFFFFFE0;

    // Isolate LS pending bit and translate into interrupt vector
    // number.
    HAL_LSBIT_INDEX( vector, pr );
    vector += CYGNUM_HAL_INTERRUPT_EXTI5 - 5;
    
    // Deliver it
    hal_deliver_interrupt( vector );

    return 0;
}


int main()
{
   	unsigned long int base;
   	unsigned int acr,pr;
                                                                             
        cyg_vector_t int1_vector = CYGNUM_HAL_INTERRUPT_EXTI9_5;
        cyg_priority_t int1_priority = CYGNUM_HAL_PRI_HIGH;

       
        /* System Clocks Configuration */ 
	// Enable all devices in RCC
	base = CYGHWR_HAL_STM32_RCC;
	HAL_READ_UINT32( base+CYGHWR_HAL_STM32_RCC_APB2ENR, acr );
        printf("%x %d\n",acr,__LINE__);
        
	HAL_WRITE_UINT32(base+CYGHWR_HAL_STM32_RCC_APB2ENR,0xFFFFFFFF);
	
        HAL_READ_UINT32( CYGHWR_HAL_STM32_RCC
+CYGHWR_HAL_STM32_RCC_APB2ENR, acr );
        printf("%x %d\n",acr,__LINE__);
         
        // Attach EXTI springboard to interrupt vectors
        HAL_INTERRUPT_ATTACH( CYGNUM_HAL_INTERRUPT_EXTI9_5,
hal_exti_isr1, 0, 0 );


	
        // Create interrupt 1.
    
        //cyg_interrupt_create(int1_vector,int1_priority,0,&interrupt_1_isr,&interrupt_1_dsr,&int1_handle,&int1);
        //printf("vector = %d priority=%d\n",int1_vector,int1_priority);
	 
        // Attach the interrupt created to the vector.
        //cyg_interrupt_attach( int1_handle );
        printf("interrupt attach\n");
        
        // Tell the processor that we have received the interrupt.
	//cyg_interrupt_acknowledge(int1_vector);
        
        // Unmask the interrupt we just configured.
        //cyg_interrupt_unmask( int1_vector );



        /* Configure the GPIO ports */
        base = CYGHWR_HAL_STM32_GPIOG;
        HAL_READ_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRL, acr );
        printf("%x %d\n",acr,__LINE__);
        HAL_READ_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRH, acr );
        printf("%x %d\n",acr,__LINE__);
    	
        //printf("%d\n",__LINE__);
	
	//Setting External interrupt configuration register 3 (AFIO_EXTICR3) to
have source input as GPIO-G port.
        base = CYGHWR_HAL_STM32_AFIO;
	HAL_WRITE_UINT32( base+ AFIO_EXTICR3 ,0x00000006 );




        base= CYGHWR_HAL_STM32_EXTI;

        HAL_READ_UINT32( base+CYGHWR_HAL_STM32_EXTI_PR, pr );
        printf("%x %d\n",pr,__LINE__);
        HAL_WRITE_UINT32( base
+CYGHWR_HAL_STM32_EXTI_IMR,0x00000100 );	//1.	Set IMR Register.
        //HAL_WRITE_UINT32( base
+CYGHWR_HAL_STM32_EXTI_EMR,0x00000100 );	
        HAL_WRITE_UINT32( base
+CYGHWR_HAL_STM32_EXTI_FTSR,0x00000100);	//2.	Set EXTI_FTSR Register.
	//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_EXTI_RTSR,0x00000100);//3.
Set EXTI_RTSR Register.
        //HAL_WRITE_UINT32( base
+CYGHWR_HAL_STM32_EXTI_PR,0x00000100);      
          
	

         HAL_READ_UINT32( base+CYGHWR_HAL_STM32_EXTI_PR, pr );
        printf("%x %d\n",pr,__LINE__);




        base= CYGHWR_HAL_STM32_EXTI;
	HAL_READ_UINT32( base+CYGHWR_HAL_STM32_EXTI_SWIER, pr );
        printf("%x %d\n",pr,__LINE__);

	HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_EXTI_SWIER,0x00000100);

        HAL_READ_UINT32( base+CYGHWR_HAL_STM32_EXTI_SWIER, pr );
        printf("%x %d\n",pr,__LINE__);

	
        printf("start end %d\n",__LINE__);
        while(1);
        return 0;
}
plz tell me where is problem in my code.

Thanks in advance

Gaurang Tamakuwala
Intrigue Technologies(P) Ltd 


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]