Problems with Start-of-Frame detection (SoF) on a SAM D21

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Folks :)

this is my first thread here and I hope I didn't miss another solution and this is the right location.

I am using a bluetooth module (Zentri AMS001) to communicate via UART with a SAM D21 wich waits in stand-by sleep mode for small data packages.

My idea is to use the Start-of-Frame detection to wake up the SAM as soon as the AMS001 is sending data like proposed in application note AT11626, chapter 4.5.

And as I understand, the internal 8 MHz clock source doesn't have to run in stand-by mode but starts immediately with the detection of the UART start bit.

The problem: it doesn't start! (Or the interrupt is not fired)

(If I let run the clock in standby it works flawlessly, but consequently the power consumption is too high for this battery powered application.)


This is my uart code using the ASF:

in "bluetooth.c":

void init_bluetooth()
	usart_read_buffer_job(&bluetooth_usart_instance, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);

void usart_read_callback(struct usart_module *const usart_module)
    //echoes back the received data
        usart_write_buffer_wait(&bluetooth_usart_instance, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
	usart_read_buffer_job(&bluetooth_usart_instance, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);

void configure_usart(void)
	struct usart_config config_usart;
	config_usart.generator_source	= GCLK_GENERATOR_0;	// internal 8 MHz clock generator (GCLK_0)
	config_usart.baudrate		= 9600;	
	config_usart.character_size	= USART_CHARACTER_SIZE_8BIT;
	config_usart.stopbits		= USART_STOPBITS_1;
	config_usart.parity		= USART_PARITY_NONE;
	config_usart.mux_setting	= USART_RX_0_TX_2_XCK_3 ; //RX on Pad 2, TX on pad 0 and XCK on pad 1 
	config_usart.pinmux_pad0	= PINMUX_PA16C_SERCOM1_PAD0; //ähnlich wie pin_set_peripheral_function(PINMUX_PA16C_SERCOM1_PAD0);
	config_usart.pinmux_pad1	= PINMUX_UNUSED; 
	config_usart.pinmux_pad2	= PINMUX_PA18C_SERCOM1_PAD2;
	config_usart.pinmux_pad3	= PINMUX_UNUSED;
	//config_usart.run_in_standby = true;
	config_usart.start_frame_detection_enable = true;
	while (usart_init(&bluetooth_usart_instance, SERCOM1, &config_usart) != STATUS_OK) {}
void configure_usart_callbacks(void)
	usart_register_callback(&bluetooth_usart_instance, usart_read_callback, USART_CALLBACK_BUFFER_RECEIVED);
	usart_enable_callback(&bluetooth_usart_instance, USART_CALLBACK_BUFFER_RECEIVED);

in "main.c":

void enable_interrupts()
    //(...some other interrupts...)
	system_interrupt_set_priority(SYSTEM_INTERRUPT_MODULE_SERCOM1, 3);

while (1)

and in "conf_clock.h":

/* SYSTEM_CLOCK_SOURCE_OSC8M configuration - Internal 8MHz oscillator */
#  define CONF_CLOCK_OSC8M_ON_DEMAND              false
#  define CONF_CLOCK_OSC8M_RUN_IN_STANDBY         false

/* Configure GCLK generator 0 (Main Clock) */
#  define CONF_CLOCK_GCLK_0_ENABLE                true
#  define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY        false
#  define CONF_CLOCK_GCLK_0_PRESCALER             1
#  define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE         false

Besides this, I have an external 32 kHz oscillitor running the RTC module and fires an interrupt once a minute...


Does somebody of you has experience with that and an idea whats my mistake?


Thanks and Greetings,