atsamd10c14a standby seelp mode issue

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used rtc in standby mode, and meet below question.  

 

Question:

when I plug jlink into target board, then download elf file. sleep and wakeup both ok.

But remove jink connector from target board, mcu work failed, and can't into sleep mode.  reset again and again. 

BTW: when i used IDEL mode, it is ok.

 

My develop environment:

Device: ATSAMD10C14A

atmelstudio version 6.2.1563

asf version: 3.26.0

Debugger: Jlink V9(uisng swd interface,  swdio swdclk reset pin)

 

 

Below is my soft code:

#define MAX_RX_BUFFER_LENGTH   5

volatile uint8_t rx_buffer[MAX_RX_BUFFER_LENGTH];
struct rtc_module rtc_instance;
struct usart_module usart_instance;



extern void rtc_overflow_callback(void);
extern void configure_rtc_count(void);
extern void configure_rtc_callbacks(void);
extern void usart_read_callback(struct usart_module *const usart_module);
extern void usart_write_callback(struct usart_module *const usart_module);

extern void configure_usart(void);
extern void configure_usart_callbacks(void);


void rtc_overflow_callback(void)
{
	/* Do something on RTC overflow here */
	uint8_t string[] = "waked up from sleep mode\r\n";
	usart_write_buffer_wait(&usart_instance, string, sizeof(string));

}

void configure_rtc_count(void)
{
	struct rtc_count_config config_rtc_count;
	rtc_count_get_config_defaults(&config_rtc_count);

	config_rtc_count.prescaler           = RTC_COUNT_PRESCALER_DIV_1;
	config_rtc_count.mode                = RTC_COUNT_MODE_16BIT;
	#ifdef FEATURE_RTC_CONTINUOUSLY_UPDATED
	config_rtc_count.continuously_update = true;
	#endif

	rtc_count_init(&rtc_instance, RTC, &config_rtc_count);

	rtc_count_enable(&rtc_instance);

}

void configure_rtc_callbacks(void)
{

	rtc_count_register_callback(
	&rtc_instance, rtc_overflow_callback, RTC_COUNT_CALLBACK_OVERFLOW);

	rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_OVERFLOW);

}


void usart_read_callback(struct usart_module *const usart_module)
{
	usart_write_buffer_job(&usart_instance,
	(uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
}

void usart_write_callback(struct usart_module *const usart_module)
{
	//port_pin_toggle_output_level(LED_0_PIN);
}

void configure_usart(void)
{
	struct usart_config config_usart;

	usart_get_config_defaults(&config_usart);

	config_usart.baudrate    = 9600;
	config_usart.mux_setting = USART_RX_3_TX_2_XCK_3;
	config_usart.pinmux_pad0 = PINMUX_UNUSED;
	config_usart.pinmux_pad1 = PINMUX_UNUSED;
	config_usart.pinmux_pad2 = PINMUX_PA08C_SERCOM1_PAD2;
	config_usart.pinmux_pad3 = PINMUX_PA09C_SERCOM1_PAD3;

	while (usart_init(&usart_instance,
	SERCOM1, &config_usart) != STATUS_OK) {
	}

	usart_enable(&usart_instance);

}

void configure_usart_callbacks(void)
{
	usart_register_callback(&usart_instance,
	usart_write_callback, USART_CALLBACK_BUFFER_TRANSMITTED);
	usart_register_callback(&usart_instance,
	usart_read_callback, USART_CALLBACK_BUFFER_RECEIVED);

	usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_TRANSMITTED);
	usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_RECEIVED);

}

int main (void)
{
	system_init();
	/* Insert application code here, after the board has been initialized. */
	
	configure_rtc_count();
	/* Configure and enable callback */
	configure_rtc_callbacks();
	rtc_count_set_period(&rtc_instance, 1000);
	
	configure_usart();
	configure_usart_callbacks();
	
	system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);
	
	uint8_t string[] = "Enter into main loop\r\n";
	usart_write_buffer_wait(&usart_instance, string, sizeof(string));
	
	en = system_is_debugger_present();
	{
		if(en == true)
		{
			uint8_t string[] = "debug is connected!\r\n";
			usart_write_buffer_wait(&usart_instance, string, sizeof(string));
		}
		else
		{
			uint8_t string[] = "debug is not connected!\r\n";
			usart_write_buffer_wait(&usart_instance, string, sizeof(string));
		}
	}

	/* This skeleton code simply sets the LED to the state of the button. */
	while (1)
	{
		system_sleep();
		usart_read_buffer_job(&usart_instance,
		(uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
	}
}

 

Last Edited: Thu. Oct 15, 2015 - 11:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

At what point does it reset?

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Alex,

 

Thanks your reply.  I found the reset cause is SYSTEM_RESET_CAUSE_BOD12. could you give me some suggestion? thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If this is a real cause, then your power supply has problems.

 

You have a lot of debugging information printed out. Can you identify the point at which reset happens?

 

It is possible that you have some shorts on the board, and when MCU tries to drive some pins, it resets the MCU.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do more test, get below information:

 

1. Using 8M OSC as main clock and set flash wait cycle to 2, CPU runs ok.

2. Using DPLL48M as main clock, the  issue still exist.

 

And if cpu run into standy mode,  current consume is below 5uA. So I doubt my clock configuration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I get some infromation from datasheet errata section. 

 

But compiler prompt message:SYSCTRL has no member named VREG.

 

The voltage regulator in low power mode is not functional at
temperatures above 85C. Errata reference: 12291
Fix/Workaround:
Enable normal mode on the voltage regulator in standby sleep mode.
Example code:
// Set the voltage regulator in normal mode configuration in standby sleep mode
SYSCTRL->VREG.bit.RUNSTDBY = 1;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

One more time. Can you debug your code step by step and see where exactly this reset happens. Since you can read out the reset reason, presumably some code runs normally, right?

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.