For users of the Atmel AT91SAM7 and AT91SAM9 ARM CPU chips. Atmel has taken a new direction by combining on chip flash and ram with the ARM CPU on a single die. This provides low cost devices for small systems using the ARM CPU.
This group is to exchange information to help users get started and learn how to use the devices.
timer interrupt aborts... - v333k - Apr 23 12:21:47 2008
Hi everyone,
I am trying to get the timer counter interrupt code to work with
SAM7SE512 MCU I am working with.
Here is what happens:
When I run the code, I initialize everything and then enable the timer
clock. The timer counter interrupt occurs only once. The main loop
code keeps running and it works fine. I do clear the Status Register
in the timer (please see code below).
When I ran the code in debug, it happened once in a while where the
code was executing in the SAM7.s file at the DAbt_Handler - which I
can conclude that it is aborting the handler. What can possibly cause
that?
Thanks.
/////// timer setup file
void TimerSetup(void) {
AT91PS_TC pTC = AT91C_BASE_TC0; // create a pointer to channel 0
Register structure
AT91PS_TCB pTCB = AT91C_BASE_TCB; // create a pointer to TC Global
Register structure
pTCB->TCB_BCR = 0; // SYNC trigger not used
pTCB->TCB_BMR = 0x15; // external clocks not used
pTC->TC_CCR = 0x5; // enable the clock and start it
pTC->TC_CMR = 0x4004; // TCCLKS = 1 (TIMER_CLOCK5)
// CPCTRG = 1 (RC Compare resets the counter and restarts the clock)
// WAVE = 0 (Capture mode enabled)
pTC->TC_RC = 2346;
pTC->TC_IER = 0x10; // enable RC compare interrupt
pTC->TC_IDR = 0xEF; // disable all except RC compare interrupt
}
////////////// interrupt handler file
void Timer0IrqHandler (void) {
volatile AT91PS_TC pTC = AT91C_BASE_TC0; // pointer to timer channel 0
register structure
volatile AT91PS_PIO pPIO = AT91C_BASE_PIOB; // pointer to PIO register
structure
unsigned int dummy; // temporary
dummy = pTC->TC_SR; // read TC0 Status Register to clear interrupt
tickcount++; // increment the tick count
if ((pPIO->PIO_ODSR & AT91B_LED2) == AT91B_LED2)
pPIO->PIO_SODR = AT91B_LED2; // turn LED2 (DS2) on
else
pPIO->PIO_CODR = AT91B_LED2; // turn LED2 (DS2) off
}
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )
Re: timer interrupt aborts... - Eric Pasquier - Apr 24 3:34:54 2008
Hi v333k,
Can you please check that the initialization of the AIC is made in LEVEL_SENSITIVE mode
?
You should also used constants in your code :
For example : pTC->TC_CMR = AT91C_TC_CPCTRG | AT91C_TC_CLKS_TIMER_DIV5_CLOCK;
instead of : pTC->TC_CMR = 0x4004;
Eric
----- Original Message -----
From: v333k
To: A...@yahoogroups.com
Sent: Wednesday, April 23, 2008 6:21 PM
Subject: [AT91SAM] timer interrupt aborts...
Hi everyone,
I am trying to get the timer counter interrupt code to work with
SAM7SE512 MCU I am working with.
Here is what happens:
When I run the code, I initialize everything and then enable the timer
clock. The timer counter interrupt occurs only once. The main loop
code keeps running and it works fine. I do clear the Status Register
in the timer (please see code below).
When I ran the code in debug, it happened once in a while where the
code was executing in the SAM7.s file at the DAbt_Handler - which I
can conclude that it is aborting the handler. What can possibly cause
that?
Thanks.
/////// timer setup file
void TimerSetup(void) {
AT91PS_TC pTC = AT91C_BASE_TC0; // create a pointer to channel 0
Register structure
AT91PS_TCB pTCB = AT91C_BASE_TCB; // create a pointer to TC Global
Register structure
pTCB->TCB_BCR = 0; // SYNC trigger not used
pTCB->TCB_BMR = 0x15; // external clocks not used
pTC->TC_CCR = 0x5; // enable the clock and start it
pTC->TC_CMR = 0x4004; // TCCLKS = 1 (TIMER_CLOCK5)
// CPCTRG = 1 (RC Compare resets the counter and restarts the clock)
// WAVE = 0 (Capture mode enabled)
pTC->TC_RC = 2346;
pTC->TC_IER = 0x10; // enable RC compare interrupt
pTC->TC_IDR = 0xEF; // disable all except RC compare interrupt
}
////////////// interrupt handler file
void Timer0IrqHandler (void) {
volatile AT91PS_TC pTC = AT91C_BASE_TC0; // pointer to timer channel 0
register structure
volatile AT91PS_PIO pPIO = AT91C_BASE_PIOB; // pointer to PIO register
structure
unsigned int dummy; // temporary
dummy = pTC->TC_SR; // read TC0 Status Register to clear interrupt
tickcount++; // increment the tick count
if ((pPIO->PIO_ODSR & AT91B_LED2) == AT91B_LED2)
pPIO->PIO_SODR = AT91B_LED2; // turn LED2 (DS2) on
else
pPIO->PIO_CODR = AT91B_LED2; // turn LED2 (DS2) off
}

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )
Re: timer interrupt aborts... - 42Bastian - Apr 24 5:03:49 2008
v333k
> I am trying to get the timer counter interrupt code to work with
> SAM7SE512 MCU I am working with.
How do you save the registers ? You do save them ?
--
42Bastian
Note: SPAM-only account, direct mail to bs42@...
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )
Re: timer interrupt aborts... - v333k - Apr 24 14:13:58 2008
--- In A...@yahoogroups.com, 42Bastian
wrote:
>
> v333k
>
> > I am trying to get the timer counter interrupt code to work with
> > SAM7SE512 MCU I am working with.
>
> How do you save the registers ? You do save them ?
>
> --
> 42Bastian
>
> Note: SPAM-only account, direct mail to bs42@
>
What do you mean by "save the registers"? Which registers?
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )Re: timer interrupt aborts... - v333k - Apr 24 14:16:15 2008
Thanks for the suggestions. I checked the code, and have done the
changes to constants as you recommended. Same behavior occurs.
One thing I want to mention (which is a test I just did), the counter
register on the TC0 is still running... In debug mode, I can see the
value changing each time the loop in main is executed.
--- In A...@yahoogroups.com, "Eric Pasquier"
wrote:
>
> Hi v333k,
>
> Can you please check that the initialization of the AIC is made in
LEVEL_SENSITIVE mode ?
>
> You should also used constants in your code :
> For example : pTC->TC_CMR = AT91C_TC_CPCTRG |
AT91C_TC_CLKS_TIMER_DIV5_CLOCK;
> instead of : pTC->TC_CMR = 0x4004;
>
> Eric
> ----- Original Message -----
> From: v333k
> To: A...@yahoogroups.com
> Sent: Wednesday, April 23, 2008 6:21 PM
> Subject: [AT91SAM] timer interrupt aborts...
> Hi everyone,
> I am trying to get the timer counter interrupt code to work with
> SAM7SE512 MCU I am working with.
>
> Here is what happens:
> When I run the code, I initialize everything and then enable the timer
> clock. The timer counter interrupt occurs only once. The main loop
> code keeps running and it works fine. I do clear the Status Register
> in the timer (please see code below).
>
> When I ran the code in debug, it happened once in a while where the
> code was executing in the SAM7.s file at the DAbt_Handler - which I
> can conclude that it is aborting the handler. What can possibly cause
> that?
>
> Thanks.
>
> /////// timer setup file
>
> void TimerSetup(void) {
> AT91PS_TC pTC = AT91C_BASE_TC0; // create a pointer to channel 0
> Register structure
> AT91PS_TCB pTCB = AT91C_BASE_TCB; // create a pointer to TC Global
> Register structure
> pTCB->TCB_BCR = 0; // SYNC trigger not used
> pTCB->TCB_BMR = 0x15; // external clocks not used
>
> pTC->TC_CCR = 0x5; // enable the clock and start it
> pTC->TC_CMR = 0x4004; // TCCLKS = 1 (TIMER_CLOCK5)
> // CPCTRG = 1 (RC Compare resets the counter and restarts the clock)
> // WAVE = 0 (Capture mode enabled)
>
> pTC->TC_RC = 2346;
>
> pTC->TC_IER = 0x10; // enable RC compare interrupt
>
> pTC->TC_IDR = 0xEF; // disable all except RC compare interrupt
> }
>
> ////////////// interrupt handler file
>
> void Timer0IrqHandler (void) {
>
> volatile AT91PS_TC pTC = AT91C_BASE_TC0; // pointer to timer channel 0
> register structure
> volatile AT91PS_PIO pPIO = AT91C_BASE_PIOB; // pointer to PIO register
> structure
> unsigned int dummy; // temporary
>
> dummy = pTC->TC_SR; // read TC0 Status Register to clear interrupt
> tickcount++; // increment the tick count
>
> if ((pPIO->PIO_ODSR & AT91B_LED2) == AT91B_LED2)
> pPIO->PIO_SODR = AT91B_LED2; // turn LED2 (DS2) on
> else
> pPIO->PIO_CODR = AT91B_LED2; // turn LED2 (DS2) off
> }
>
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )RE: Re: timer interrupt aborts... - "Srivishnu D , Bangalore" - Apr 25 3:00:10 2008
Hi Vartan,
I have a suggestion to you.
1. Why do you have the two functions (void TimerSetup(void) and
void Timer0IrqHandler (void)) in separate files...? Have any specific
reasons for that...? Instead have it in a single file.
2. Why do you create various instances (AT91PS_TC pTC =
AT91C_BASE_TC0;) for the Timer in the TimerSetup function and the
Timer0IrqHandler function. Do it once globally (that's enough) if you
implement the above suggested point (point number 1) in your code.
Cheers,
Vishnu.
________________________________
From: A...@yahoogroups.com [mailto:A...@yahoogroups.com] On Behalf
Of v333k
Sent: Thursday, April 24, 2008 11:46 PM
To: A...@yahoogroups.com
Subject: [AT91SAM] Re: timer interrupt aborts...
Thanks for the suggestions. I checked the code, and have done the
changes to constants as you recommended. Same behavior occurs.
One thing I want to mention (which is a test I just did), the counter
register on the TC0 is still running... In debug mode, I can see the
value changing each time the loop in main is executed.
--- In A...@yahoogroups.com
,
"Eric Pasquier" wrote:
>
> Hi v333k,
>
> Can you please check that the initialization of the AIC is made in
LEVEL_SENSITIVE mode ?
>
> You should also used constants in your code :
> For example : pTC->TC_CMR = AT91C_TC_CPCTRG |
AT91C_TC_CLKS_TIMER_DIV5_CLOCK;
> instead of : pTC->TC_CMR = 0x4004;
>
> Eric
> ----- Original Message -----
> From: v333k
> To: A...@yahoogroups.com
> Sent: Wednesday, April 23, 2008 6:21 PM
> Subject: [AT91SAM] timer interrupt aborts...
> Hi everyone,
> I am trying to get the timer counter interrupt code to work with
> SAM7SE512 MCU I am working with.
>
> Here is what happens:
> When I run the code, I initialize everything and then enable the timer
> clock. The timer counter interrupt occurs only once. The main loop
> code keeps running and it works fine. I do clear the Status Register
> in the timer (please see code below).
>
> When I ran the code in debug, it happened once in a while where the
> code was executing in the SAM7.s file at the DAbt_Handler - which I
> can conclude that it is aborting the handler. What can possibly cause
> that?
>
> Thanks.
>
> /////// timer setup file
>
> void TimerSetup(void) {
> AT91PS_TC pTC = AT91C_BASE_TC0; // create a pointer to channel 0
> Register structure
> AT91PS_TCB pTCB = AT91C_BASE_TCB; // create a pointer to TC Global
> Register structure
> pTCB->TCB_BCR = 0; // SYNC trigger not used
> pTCB->TCB_BMR = 0x15; // external clocks not used
>
> pTC->TC_CCR = 0x5; // enable the clock and start it
> pTC->TC_CMR = 0x4004; // TCCLKS = 1 (TIMER_CLOCK5)
> // CPCTRG = 1 (RC Compare resets the counter and restarts the clock)
> // WAVE = 0 (Capture mode enabled)
>
> pTC->TC_RC = 2346;
>
> pTC->TC_IER = 0x10; // enable RC compare interrupt
>
> pTC->TC_IDR = 0xEF; // disable all except RC compare interrupt
> }
>
> ////////////// interrupt handler file
>
> void Timer0IrqHandler (void) {
>
> volatile AT91PS_TC pTC = AT91C_BASE_TC0; // pointer to timer channel 0
> register structure
> volatile AT91PS_PIO pPIO = AT91C_BASE_PIOB; // pointer to PIO register
> structure
> unsigned int dummy; // temporary
>
> dummy = pTC->TC_SR; // read TC0 Status Register to clear interrupt
> tickcount++; // increment the tick count
>
> if ((pPIO->PIO_ODSR & AT91B_LED2) == AT91B_LED2)
> pPIO->PIO_SODR = AT91B_LED2; // turn LED2 (DS2) on
> else
> pPIO->PIO_CODR = AT91B_LED2; // turn LED2 (DS2) off
> }
>
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the
named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views
or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of
HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution
and / or publication of
this message without the prior written consent of the author of this e-mail is strictly
prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before
opening any mail and
attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )Re: Re: timer interrupt aborts... - 42Bastian - Apr 25 3:41:44 2008
v333k schrieb:
>>> I am trying to get the timer counter interrupt code to work with
>>> SAM7SE512 MCU I am working with.
>> How do you save the registers ? You do save them ?
> What do you mean by "save the registers"? Which registers?
On interrupt entry you need to save r0-r3 and restore it.
Also you can't use the normal return.
=> You can not use a normal C-function as ISR.
BTW: Please trim your replies.
--
42Bastian
Note: SPAM-only account, direct mail to bs42@...
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )
RES: Re: timer interrupt aborts... - Eric Pasquier - Apr 27 16:09:23 2008
Hi V333k,
Can you please check that the initialization of the AIC is made in
LEVEL_SENSITIVE mode ?
(or send the rest of your code ... )
Eric.
-----Mensagem original-----
De: A...@yahoogroups.com [mailto:A...@yahoogroups.com] Em nome de
v333k
Enviada em: jeudi 24 avril 2008 20:16
Para: A...@yahoogroups.com
Assunto: [AT91SAM] Re: timer interrupt aborts...
Thanks for the suggestions. I checked the code, and have done the
changes to constants as you recommended. Same behavior occurs.
One thing I want to mention (which is a test I just did), the counter
register on the TC0 is still running... In debug mode, I can see the
value changing each time the loop in main is executed.
--- In AT91SAM@yahoogroups
.com, "Eric
Pasquier" wrote:
>
> Hi v333k,
>
> Can you please check that the initialization of the AIC is made in
LEVEL_SENSITIVE mode ?
>
> You should also used constants in your code :
> For example : pTC->TC_CMR = AT91C_TC_CPCTRG |
AT91C_TC_CLKS_TIMER_DIV5_CLOCK;
> instead of : pTC->TC_CMR = 0x4004;
>
> Eric
> ----- Original Message -----
> From: v333k
> To: AT91SAM@yahoogroups .com
> Sent: Wednesday, April 23, 2008 6:21 PM
> Subject: [AT91SAM] timer interrupt aborts...
> Hi everyone,
> I am trying to get the timer counter interrupt code to work with
> SAM7SE512 MCU I am working with.
>
> Here is what happens:
> When I run the code, I initialize everything and then enable the timer
> clock. The timer counter interrupt occurs only once. The main loop
> code keeps running and it works fine. I do clear the Status Register
> in the timer (please see code below).
>
> When I ran the code in debug, it happened once in a while where the
> code was executing in the SAM7.s file at the DAbt_Handler - which I
> can conclude that it is aborting the handler. What can possibly cause
> that?
>
> Thanks.
>
> /////// timer setup file
>
> void TimerSetup(void) {
> AT91PS_TC pTC = AT91C_BASE_TC0; // create a pointer to channel 0
> Register structure
> AT91PS_TCB pTCB = AT91C_BASE_TCB; // create a pointer to TC Global
> Register structure
> pTCB->TCB_BCR = 0; // SYNC trigger not used
> pTCB->TCB_BMR = 0x15; // external clocks not used
>
> pTC->TC_CCR = 0x5; // enable the clock and start it
> pTC->TC_CMR = 0x4004; // TCCLKS = 1 (TIMER_CLOCK5)
> // CPCTRG = 1 (RC Compare resets the counter and restarts the clock)
> // WAVE = 0 (Capture mode enabled)
>
> pTC->TC_RC = 2346;
>
> pTC->TC_IER = 0x10; // enable RC compare interrupt
>
> pTC->TC_IDR = 0xEF; // disable all except RC compare interrupt
> }
>
> ////////////// interrupt handler file
>
> void Timer0IrqHandler (void) {
>
> volatile AT91PS_TC pTC = AT91C_BASE_TC0; // pointer to timer channel 0
> register structure
> volatile AT91PS_PIO pPIO = AT91C_BASE_PIOB; // pointer to PIO register
> structure
> unsigned int dummy; // temporary
>
> dummy = pTC->TC_SR; // read TC0 Status Register to clear interrupt
> tickcount++; // increment the tick count
>
> if ((pPIO->PIO_ODSR & AT91B_LED2) == AT91B_LED2)
> pPIO->PIO_SODR = AT91B_LED2; // turn LED2 (DS2) on
> else
> pPIO->PIO_CODR = AT91B_LED2; // turn LED2 (DS2) off
> }
>

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )