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]

Re: timer 0 interrupt


Well said
Ramana
----- Original Message ----- From: "Andrew Lunn" <andrew@lunn.ch>
To: "sandip" <sandip@masibus.com>
Cc: <ecos-discuss@ecos.sourceware.org>
Sent: Monday, August 13, 2007 4:24 AM
Subject: Re: [ECOS] timer 0 interrupt



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




--------------------------------------------------------------------------------


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


--
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]