ATSAMR34-XPRO SERCOM5 I2C DMA compilation error

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

I am trying to test SERCOM5 I2C DMA write command but I am getting compilation error:

 

expected expression before ';' token

 

on the line 91, config.peripheral_trigger = CONF_I2C_DMA_TRIGGER;

 

/**
* \file
*
* \brief Empty user application template
*
*/

/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* This is a bare minimum user application template.
*
* For documentation of the board, go \ref group_common_boards "here" for a link
* to the board-specific documentation.
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# Minimal main function that starts with a call to system_init()
* -# Basic usage of on-board LED and button
* -# "Insert application code here" comment
*
*/

/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
/*
* Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
*/
#include <asf.h>

/* master sercom pinmux setting */
#define CONF_I2C_MASTER_MODULE    SERCOM5
#define CONF_MASTER_SDA_PINMUX    PINMUX_PB02D_SERCOM5_PAD0
#define CONF_MASTER_SCK_PINMUX    PINMUX_PA23D_SERCOM5_PAD1

#define CONF_I2C_DMA_TRIGGER      SERCOM5_DMAC_ID_RX	// Index of DMA RX trigger defined in sercom5.h

#define DATA_LENGTH 8
// UBX-NAV-POSLLH command for u-blox ZOE-M8Q GPS to get LAT, LON; originally there was DATA_LENGTH i.e. 10 bytes 0 to 9
static uint8_t buffer[DATA_LENGTH] = {
	0xB5, 0x62, 0x01, 0x02, 0x00, 0x00, 0x03, 0x0A,
};
#define SLAVE_ADDRESS 0x42
#define TIMEOUT 1000

// Globally accessible module structure:
struct i2c_master_module i2c_master_instance;

// Function for setting up the module:
static void configure_i2c_master(void)
{
	/* Initialize config structure and software module. */
	struct i2c_master_config config_i2c_master;
	i2c_master_get_config_defaults(&config_i2c_master);
	/* Change buffer timeout to something longer. */
	config_i2c_master.buffer_timeout = 10000;
	//#if SAMR30
	config_i2c_master.pinmux_pad0    = CONF_MASTER_SDA_PINMUX;
	config_i2c_master.pinmux_pad1    = CONF_MASTER_SCK_PINMUX;
	//#endif
	/* Initialize and enable device with config. */
	i2c_master_init(&i2c_master_instance, CONF_I2C_MASTER_MODULE, &config_i2c_master);
	i2c_master_enable(&i2c_master_instance);
}

// Globally accessible DMA module structure:
struct dma_resource example_resource;
// Globally transfer done flag:
static volatile bool transfer_is_done = false;
// Globally accessible DMA transfer descriptor:
COMPILER_ALIGNED(16)
DmacDescriptor example_descriptor SECTION_DMAC_DESCRIPTOR;

// Function for transfer done callback:
static void transfer_done(struct dma_resource* const resource )
{
	UNUSED(resource);
	transfer_is_done = true;
}

// Function for setting up the DMA resource:
static void configure_dma_resource(struct dma_resource *resource)
{
	struct dma_resource_config config;
	dma_get_config_defaults(&config);
	config.peripheral_trigger = CONF_I2C_DMA_TRIGGER;
	config.trigger_action = DMA_TRIGGER_ACTION_BEAT;
	dma_allocate(resource, &config);
}

// Function for setting up the DMA transfer descriptor:
static void setup_dma_descriptor(DmacDescriptor *descriptor)
{
	struct dma_descriptor_config descriptor_config;
	dma_descriptor_get_config_defaults(&descriptor_config);
	descriptor_config.beat_size = DMA_BEAT_SIZE_BYTE;
	descriptor_config.dst_increment_enable = false;
	descriptor_config.block_transfer_count = DATA_LENGTH;
	descriptor_config.source_address = (uint32_t)buffer + DATA_LENGTH;
	descriptor_config.destination_address =
	(uint32_t)(&i2c_master_instance.hw->I2CM.DATA.reg);
	dma_descriptor_create(descriptor, &descriptor_config);
}



int main (void)
{
	system_init();

	/* Insert application code here, after the board has been initialized. */
	
	configure_i2c_master();
	configure_dma_resource(&example_resource);
	setup_dma_descriptor(&example_descriptor);
	dma_add_descriptor(&example_resource, &example_descriptor);
	dma_register_callback(&example_resource, transfer_done,
	DMA_CALLBACK_TRANSFER_DONE);
	dma_enable_callback(&example_resource, DMA_CALLBACK_TRANSFER_DONE);
	
	dma_start_transfer_job(&example_resource);
	i2c_master_dma_set_transfer(&i2c_master_instance, SLAVE_ADDRESS,
	DATA_LENGTH, I2C_TRANSFER_WRITE);
	
	while (!transfer_is_done) {
		/* Wait for transfer done */
	}

	/* This skeleton code simply sets the LED to the state of the button. */
	while (1) {
		/* Is button pressed? */
		if (port_pin_get_input_level(BUTTON_0_PIN) == BUTTON_0_ACTIVE) {
			/* Yes, so turn LED on. */
			port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
			} else {
			/* No, so turn LED off. */
			port_pin_set_output_level(LED_0_PIN, !LED_0_ACTIVE);
		}
	}
}

How to fix it?

Attachment(s): 

This topic has a solution.
Last Edited: Mon. Jun 1, 2020 - 12:09 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fixed already. The problem was in using SERCOM5 witch doesn't have defined SERCOM5_DMAC_ID_TX Index of DMA TX trigger. When I changed it to SERCOM1_DMAC_ID_TX it has Index of DMA TX trigger = 4 and program compiled without any errors.

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

Kevil wrote:
Fixed already

Thanks for the feedback.

 

Now please mark the solution - see Tip #5 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...