SAMG55 I2S slave mode write operation help

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

All,

 

I have the SAMG55 Xplained Pro board and I'm trying to test the I2S module's write capability. So far I have been unable to get it to successfully transmit anything. My code is as follows:

 

enum status_code configure_i2s_slave(void) {
	enum status_code code;
	struct i2s_config i2s_conf;
	i2s_get_config_defaults(&i2s_conf);
	i2s_conf.data_format = I2S_DATE_24BIT;
	i2s_conf.fs_ratio = I2S_FS_RATE_256;
	i2s_conf.master_mode = false;
	i2s_conf.master_clock_enable = false;
	code = i2s_init(&i2s_instance, I2SC1, &i2s_conf);

	i2s_enable(&i2s_instance);
	//i2s_enable_reception(&i2s_instance);
	i2s_enable_transmission(&i2s_instance);
	i2s_enable_clocks(&i2s_instance);
	return code;
}

int main (void)
{
	sysclk_init();
	board_init();
	
	Enable_global_interrupt();
	g_ul_ms_ticks = 0;
	//volatile uint32_t sysclk = sysclk_get_peripheral_hz();
	while (SysTick_Config(sysclk_get_cpu_hz() / 1000000));

	configure_i2c_master();
	init_pcm9211_registers();
	configure_i2s_slave();
	
	uint32_t test_buffer[1] = {0xAAAAAA};
	volatile enum status_code code;

	/* This skeleton code simply sets the LED to the state of the button. */
	long count = 0;
	while (1) {
		code = i2s_write(&i2s_instance, test_buffer);
		if(count < 1000000) {
			ioport_set_pin_level(LED_0_PIN, LED_0_ACTIVE);
		} else {
			ioport_set_pin_level(LED_0_PIN, !LED_0_ACTIVE);
		}
		if(count > 2000000) {
			count = 0;
		}
		++count;
	}
}

All of the status codes have come back as OK so I feel like maybe I'm making a wrong assumption about the pins being set up correctly? Any help is appreciated. 

This topic has a solution.
Last Edited: Sat. Sep 8, 2018 - 06:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some additional details:

 

None of the pins seem to be producing any kind of signal. I would expect when I call i2s_write so see the main clock, bit clock, and work sink to at least produce some form of signal even if my data is bad.

 

I did not switch pins PA02 or PA22 from their default functionality to I2SDI but since I am not trying to receive a signal I would not think it matters.

 

i2s_write completes without errors and reaches the last like which returns STATUS_OK. I confirmed this with the debugger.

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

I've solved the issue, it was because I did not define CONF_BOARD_I2S1 in the conf_board.h file (or anywhere else).

 

However, I now have another problem where the voltage of my master clock is getting reduced from ~3V to ~1V. I tried switching the  I2S1_MCK pin from PA24 to PA26 but it caused the same issue. The reduction in voltage only occurs if ioport_set_pin_peripheral_mode(I2S1_MCK_GPIO, I2S1_MCK_FLAGS) is called to set the pin mode, otherwise the voltage drop does not happen when the MCK line is attached to the pin.

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

Don't know SAM chips but your description sounds like an output drive problem. And that implies incorrect pin configuration. The configuration of an I2S port HAS to change according to whether the transmitter or receiver is the master. The master supplies the clock so the transmitter's clock output has to be turned into an input if it is NOT master. If you don't handle that correctly, you might get the results you describe.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

So it looks like the MCLK voltage level might actually be normal for the SAMG55 because I can produce a correct output from SDO. It looks like the problem might be some of the circuitry on the Xplained Pro interfering with the SDI signal coming in. I'll have to remove some parts to confirm if it fully solves my issue or not.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Removing the SW0 resistor and capacitor fixed the issue. Everything works correctly now!