SAM4S Xplained Pro RTT Demo2018-10-19T06:23:20+00:00

ASF version

Tested for ASF version 3.31.0

ASF Modules required 

  • RTT – Real Time Timer

Basic Demo

Demo in progress. Meanwhile…

Use this to start it. The counter is incremented (i.e. it ticks) every steps/(2^15) seconds

uint32_t steps;	

rtt_sel_source(RTT, false);	
rtt_init( RTT, steps ); //Configure RTT to tick every steps/32768 secs... 


Use this to start it with a callback that is triggered on every tick.

//sets callback
timer_callback = callback;
rtt_sel_source(RTT, false);	
rtt_init(RTT, steps ); //Configure RTT to tick every steps/32768 secs... 
//Wait until timer starts going? (not sure why this is needed)
volatile uint32_t ul_previous_time = rtt_read_timer_value(RTT);
while (ul_previous_time == rtt_read_timer_value(RTT));

//Clear previous on-going ints? (not too sure of this either)
//Sets new int 
NVIC_SetPriority(RTT_IRQn, 0);
rtt_enable_interrupt(RTT, RTT_MR_RTTINCIEN);


Stop it like this

	rtt_disable_interrupt(RTT, RTT_MR_RTTINCIEN);


Use this to read it (read the count i.e. the number of ticks)

rtt_read_timer_value (RTT);


Use this to read it from within a handler

void RTT_Handler(void){
	uint32_t ul_status;

	//get rtt status
	ul_status = rtt_get_status(RTT);
	//Check whether the Timer has been incremented since the last read
	if ((ul_status & RTT_SR_RTTINC) == RTT_SR_RTTINC) {

		//Timer tick has occurred!