On Mon, Aug 13, 2007 at 09:37:49AM +0530, sandip wrote:
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.
Do you always write such ugly looking code? If i were posting code to
a mailing list which hundreds of people were going to read, i would
want to make my code as good as possible. Attached is your exact same
code, but re indented. Which do you think looks better? Now try taking
out all the dead code inside comments? Doesn't it look even better?
Something to remember when writing code. You only write it once, but
you and others will read it many many times. So make it easy to read
and understand.
Next, compiler warnings:
tc0.c: In function `simple_prog':
tc0.c:52: warning: unused variable `handle'
tc0.c:53: warning: unused variable `handle_ser0'
tc0.c:54: warning: unused variable `handle_ser1'
Again, i would never post code which produces compiler
warnings. Compiler warnings are bad. Sometimes they are real errors,
sometimes not. With a little program like this, you can easily look at
three warnings and decided if they are important or not. But think
about what it would be like if every file in an eCos build produces
three warnings. Could you see the real errors mixed in between
hundreds of compiler warnings?
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);
You are asking for help with tc0. So why have you included all this
serial port stuff? Cut out all the junk which is not relevant to the
problem. The less code i need to read, the more likely i will take a
look at it and see what the problem is.
HAL_WRITE_UINT32(AT91_PMC_PCER + AT91_PMC ,0x00001000);
//disable interrup and clock...
HAL_WRITE_UINT32(AT91_TC_CCR + AT91_TC ,0x00000002);
Don't use hard coded magic values. I have no idea what 0x2 is in
register AT91_TC_CCR + AT91_TC. If you write
HAL_WRITE_UINT32(AT91_TC + AT91_TC_CCR, AT91_TC_CCR_CLKDIS)
i have a much better idea what is happening. Take a look at
packages/hal/arm/at91/var/current/include/var_io.h. Every register
should be described with #defines. Use them.
So, please write a new little program which just has your code for
tc0. Make it look nice, and use all the correct #define's. Make sure
it compiles without warnings. Then and only then will i look at it and
see if i can see what is wrong.
Andrew