This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
timer 0 interrupt
- From: sandip <sandip at masibus dot com>
- To: <ecos-discuss at ecos dot sourceware dot org>
- Date: Mon, 13 Aug 2007 09:37:49 +0530
- Subject: [ECOS] timer 0 interrupt
Dear friends,
i am sending my code for timer 0 interrupt at every 10ms but timer
interrupt is not coming.
can any one help for that.
i am using arm sam7x.
#include <pkgconf/system.h> /* which packages are enabled/disabled */
#ifdef CYGPKG_KERNEL
# include <pkgconf/kernel.h>
#endif
#ifdef CYGPKG_LIBC
# include <pkgconf/libc.h>
#endif
#ifdef CYGPKG_IO_SERIAL
# include <pkgconf/io_serial.h>
#endif
#ifndef CYGFUN_KERNEL_API_C
# error Kernel API must be enabled to build this example
#endif
#ifndef CYGPKG_LIBC_STDIO
# error C library standard I/O must be enabled to build this example
#endif
#ifndef CYGPKG_IO_SERIAL_HALDIAG
# error I/O HALDIAG pseudo-device driver must be enabled to build this
example
#endif
/* INCLUDES */
#include <stdio.h> /* printf */
#include <string.h> /* strlen */
#include <cyg/kernel/kapi.h> /* All the kernel specific stuff */
#include <cyg/io/io.h> /* I/O functions */
#include <cyg/hal/hal_arch.h> /* CYGNUM_HAL_STACK_SIZE_TYPICAL */
#include <cyg/io/serialio.h>
# include <cyg/hal/hal_platform_ints.h>
/* DEFINES */
#define NTHREADS 1
#define STACKSIZE ( CYGNUM_HAL_STACK_SIZE_TYPICAL + 4096 )
/* STATICS */
static cyg_handle_t thread[NTHREADS];
cyg_uint32 i;
static cyg_thread thread_obj[NTHREADS];
static char stack[NTHREADS][STACKSIZE];
static cyg_interrupt int1;
static cyg_handle_t int1_handle;
/* FUNCTIONS */
static void simple_prog(CYG_ADDRESS data)
{
cyg_io_handle_t handle;
cyg_io_handle_t handle_ser0;
cyg_io_handle_t handle_ser1;
cyg_io_handle_t handle_ser2;
Cyg_ErrNo err;
const char test_string[] = "hi this is com1 ?\n";
cyg_uint32 len = strlen(test_string);
err = cyg_io_lookup( "/dev/ser2", &handle_ser2 );
cyg_serial_info_t si;
i = sizeof(si);
cyg_io_get_config( handle_ser2, CYG_IO_GET_CONFIG_SERIAL_INFO, &si,
&i);
si.baud = CYGNUM_SERIAL_BAUD_19200;
si.stop = CYGNUM_SERIAL_STOP_1;
si.parity = CYGNUM_SERIAL_PARITY_NONE;
si.word_length = CYGNUM_SERIAL_WORD_LENGTH_8;
si.flags = CYGNUM_SERIAL_FLOW_NONE;
cyg_io_set_config(handle_ser2, CYG_IO_SET_CONFIG_SERIAL_INFO, &si, &i);
cyg_thread_delay(10);
cyg_io_write( handle_ser2, test_string, &len );
cyg_thread_delay(10);
do
{
cyg_thread_delay(50);
printf("hi sandip here");
}while(1);
}
cyg_uint32 interrupt_1_isr(cyg_vector_t vector,cyg_addrword_t data)
{
// mask it from further such interrupts
cyg_interrupt_mask(vector);
cyg_uint32 sm1;
HAL_READ_UINT32(AT91_TC_SR + AT91_TC ,sm1);
// acknowledge
cyg_interrupt_acknowledge(vector);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_PER,0x00ff0000);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_OER,0x00ff0000);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_CODR,0x00ff0000);
cyg_uint32 sm;
HAL_READ_UINT32(AT91_AIC_CISR + AT91_AIC,sm);
printf("\n isr.\n");
// hand over to DSR
return(CYG_ISR_HANDLED | CYG_ISR_CALL_DSR);
}
// the DSR routine
void interrupt_1_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t
data)
{
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_PER,0x00ff0000);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_OER,0x00ff0000);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_CODR,0x00ff0000);
printf("\n dsr.\n");
cyg_interrupt_unmask(vector);
}
void cyg_user_start(void)
{
printf("\nprogram start\n");
cyg_vector_t int1_vector = CYGNUM_HAL_INTERRUPT_TC0;
// cyg_vector_t int1_vector = CYGNUM_HAL_INTERRUPT_IRQ0;
//cyg_interrupt_disable();
cyg_interrupt_create(
int1_vector,
0,
0,
&interrupt_1_isr,
&interrupt_1_dsr,
&int1_handle,
&int1);
// attach the interrupt to the vector
cyg_interrupt_attach(int1_handle);
// unmask the interrupt
cyg_interrupt_unmask(int1_vector);
//pheri clock...
HAL_WRITE_UINT32(AT91_PMC_PCER + AT91_PMC ,0x00001000);
//disable interrup and clock...
HAL_WRITE_UINT32(AT91_TC_CCR + AT91_TC ,0x00000002);
HAL_WRITE_UINT32(AT91_TC_IDR + AT91_TC ,0xFFFFFFFF);
// read status res
cyg_uint32 sm1;
HAL_READ_UINT32(AT91_TC_SR + AT91_TC ,sm1);
//set TIMER_CLOCK3
HAL_WRITE_UINT32(AT91_TC_CMR + AT91_TC ,0x0000c002);
//set value
//HAL_WRITE_UINT32(AT91_TC_RC + AT91_TC ,0x000005dC);
//enable clock
HAL_WRITE_UINT32(AT91_TC_RC+ AT91_TC ,0x00000001);
//enabl;e interrupt
HAL_WRITE_UINT32(AT91_TC_IER + AT91_TC ,0x00000010);
//enabl;e interrupt
HAL_WRITE_UINT32(AT91_AIC_IECR + AT91_AIC ,0x00001000);
//start timer
HAL_WRITE_UINT32(AT91_TC_CCR + AT91_TC ,0x00000004);
cyg_thread_create(4, simple_prog, (cyg_addrword_t) 0, "serial",
(void *)stack[0], STACKSIZE, &thread[0],
&thread_obj[0]);
cyg_thread_resume(thread[0]);
}
-------------------------------------------------------
Masibus Process Instruments (P) Ltd, Gandhinagar, India
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss