This is the mail archive of the ecos-discuss@sources.redhat.com 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]

Re: E7T timer0 interrupt issue ?


On Mon, 2002-05-20 at 21:31, peter_ku wrote:
> Hello,
> 
> Target = E7T.
> I write a simple program to test timer0 interrupt, I want to toggle the led every 1sec. But I can't enter my ISR.
> I can see the INTPND = 0x400, and also see my timer0 running!!
> Anyone can check the following code?
> 

You need to start the kernel/scheduler, which in turn enables
interrupts.  If you use cyg_start() or cyg_user_start(), this has to be
done manually (see below).  Alternatively, use main() instead of
cyg_user_start().

> thanks a lot
> Peter
> 
> 
> #define TOTAL_THREADS	1
> 
> cyg_thread threads[TOTAL_THREADS];
> 
> cyg_handle_t handle_thread_show_led;
> cyg_handle_t handle_timer0_isr;
> 
> cyg_interrupt isr;
> 
> char	stack[TOTAL_THREADS][4096];
> 
> cyg_thread_entry_t 	show_led_proc;
> cyg_ISR_t 		Timer0_ISR;
> cyg_DSR_t		Timer0_DSR;
> 
> void cyg_user_start(void)
> {
>   cyg_thread_create(4, show_led_proc , (cyg_addrword_t) 0 , "THREAD SHOW LED", (void *) stack[0], 4096,
>   			&handle_thread_show_led, &threads[0]);
>   			
> 
>   cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TIMER0,99,0,Timer0_ISR, Timer0_DSR, &handle_timer0_isr, &isr);
>   
>   cyg_interrupt_attach(handle_timer0_isr);
>   
>   HAL_WRITE_UINT32(E7T_TDATA0,50000000);  
>   HAL_WRITE_UINT32(E7T_TMOD,E7T_TMOD_TE0 | E7T_TMOD_TMD0);
>   
>   cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_TIMER0);
>   cyg_interrupt_enable();
>   
>     
>   cyg_thread_resume(handle_thread_show_led);
> 	
    cyg_scheduler_start();

	
> 	
> }
> 
> 
> 
> 
> void show_led_proc(cyg_addrword_t data)
> {
> 
>    int i,j;
>    int temp_data;
>    
>    
>    HAL_READ_UINT32(E7T_IOPDATA,temp_data);
>    temp_data |= 0xf0;
>    HAL_WRITE_UINT32(E7T_IOPDATA,temp_data);
>       
>    for( ; ; )
>    {
>      for( i =0 ; i < 10 ; i++)
>      {
>    	
>    	HAL_READ_UINT32(E7T_IOPDATA,temp_data);
>    	temp_data &= ~SEG_MASK;
>    	temp_data |= numeric_display[i];
>    	HAL_WRITE_UINT32(E7T_IOPDATA,temp_data);
>    	for(j = 0; j < 10000000; j++) { }
>      }	
> 		
>    }
> 	
> }
> 
> 
> cyg_uint32 Timer0_ISR(cyg_vector_t vector, cyg_addrword_t data)
> {
> 
>    cyg_uint32 temp_data;
>    HAL_READ_UINT32(E7T_IOPDATA,temp_data);
>    temp_data ^= 0xf0;
>    HAL_WRITE_UINT32(E7T_IOPDATA,temp_data);	
> 
>    cyg_interrupt_acknowledge(vector);	
>    
>    return CYG_ISR_HANDLED;
> }
> 
> void Timer0_DSR(cyg_vector_t vector,cyg_ucount32 count, cyg_addrword_t data)
> {
> 
> }



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


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