I wonder about some RTT example

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

moon-sik
Posts: 6
Joined: Tue Mar 31, 2015 1:35 pm

I wonder about some RTT example

Fri May 22, 2015 8:47 am

Hello.

I have a rtt_example.c file.

In this source code, i wonder about function 'configure_rtt'.

Code: Select all

/**
 * \brief RTT configuration function.
 *
 * Configure the RTT to generate a one second tick, which triggers the RTTINC
 * interrupt.
 */
static void configure_rtt(void)
{
	uint32_t ul_previous_time;




	/* Configure RTT for a 1 second tick interrupt */
#if SAM4N || SAM4S || SAM4E || SAM4C || SAM4CP || SAM4CM
	rtt_sel_source(RTT, false);
#endif
	rtt_init(RTT, 32768);




	ul_previous_time = rtt_read_timer_value(RTT);
	while (ul_previous_time == rtt_read_timer_value(RTT));




	/* Enable RTT interrupt */
	NVIC_DisableIRQ(RTT_IRQn);
	NVIC_ClearPendingIRQ(RTT_IRQn);
	NVIC_SetPriority(RTT_IRQn, 0);
	NVIC_EnableIRQ(RTT_IRQn);
	rtt_enable_interrupt(RTT, RTT_MR_RTTINCIEN);
}
At this function, i want to know why use [while (ul_previous_time == rtt_read_timer_value(RTT));] this loop.

I tried to delete this while loop. But i don't find any problem.

Do you know this while loop's function?

Thanks for advise!
Last edited by moon-sik on Fri May 22, 2015 12:13 pm, edited 1 time in total.
moon-sik
Posts: 6
Joined: Tue Mar 31, 2015 1:35 pm

Re: I wonder about some RTT example

Fri May 22, 2015 12:17 pm

awneil, i'm sorry.

I want to use loop not roof.

I don't use english well... :lol:
moon-sik
Posts: 6
Joined: Tue Mar 31, 2015 1:35 pm

Re: I wonder about some RTT example

Fri May 22, 2015 2:29 pm

Thank you awneil. 

I read datasheet RTT part, but i can't find anything about needing to wait for the value to change.

When i use this while loop, program can't run quickly.
If this loop only check the RTT value's change, i don't need to use this loop.

Your advise is suitable to me. Thanks! :D

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 2 guests