Atmel website | ARM Community | AVR freaks | Technical Support
Banner
Welcome to AT91SAM Community Forum
http://www.at91.com/samphpbb/

SAM4SXplained Technology on Tour
http://www.at91.com/samphpbb/viewtopic.php?f=29&t=20901
Page 1 of 1

Author:  Pulse1 [ Wed Jun 13, 2012 3:34 pm ]
Post subject:  SAM4SXplained Technology on Tour

Hello,

I have been on the Atmel Technology on Tour course at ARM in Cambridge where they demo'd the SAM4S on two dev boards. The one I am using at the moment is the SAM4SXplained and I am currently trying to implement a TC0_Handler which should be triggered by Timer counter 0 channel 0 RA Compare interrupt at 128 and also by RC Compare interrupt at 255. I have tried my best with limited knowledge of this device and the use of the API and recalling upon my experience gained in the course.

The best I can do is acknowledge the fact that in debugging I can follow the steps through the main.c, to the end while loop which is then interrupted and jumps to the TC0_Handler. The two if statements I have inside this Handler keep getting executed but I wanted them to be executed depending upon RA and RC Compare interrupt status.

Ideally the LED and scope connection outputs should toggle on to off from RA to RC and repeat forever using interrupts only.

Anybody able to spare some time and check out my source code please?

Attachments:
SAM4SXplained - Qtouch_Led_Driver1_2nd_Try-SENT130612.zip [1.1 MiB]
Downloaded 87 times

Author:  gerhardf [ Thu Jun 14, 2012 9:01 am ]
Post subject:  Re: SAM4SXplained Technology on Tour

hello,
reading the status register with function tc_get_status() multiple times isn't a good idea because all of the flags are cleared at the first reading of the register.
so read the register only once and write it to a variable and check the variable afterwards.


regards
gerhard

Author:  Pulse1 [ Thu Jun 14, 2012 12:23 pm ]
Post subject:  Re: SAM4SXplained Technology on Tour

gerhardf wrote:
hello,
reading the status register with function tc_get_status() multiple times isn't a good idea because all of the flags are cleared at the first reading of the register.
so read the register only once and write it to a variable and check the variable afterwards.


regards
gerhard


Ahh yes this makes sense now. I created variable name uint32_t tc_status, and put that at the start of main.c. I then cut the get status function from the two brackets, put it before the if statements in the TC0_Handler, then set my tc_status to equal get status function.

The result was it worked after compiling.

Thank you for the help Gerhard.

EDIT: I've tested the code and showed the results of changing RA Compare value from 50, to 128, to 205 in three different waveforms below, for anyone wondering about what they should be seeing when successful.

Image

Image

Image

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/