I2C PINMUX

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

cventu
Posts: 2
Joined: Mon Mar 28, 2016 10:54 pm

I2C PINMUX

Mon Mar 28, 2016 11:07 pm

Hi All,

First time on this forum for me. I have been taking a look but couldnt find an answer to my question so decided to create my own.

I am currently working with my SAMD20 (and the xplained board) to interface the Si7020 (temperature and humidity sensor) using I2C.
The sensor is working completely fine, I wrote my code based on the ASF example, but now I need to change the pins where the device is connected.
In the ASF example it is connected on PA08 (SDA) and PA09 (SCL) which belongs to SERCOM2.

I want to place my sensor on PB12 and PB13 which belong to SERCOM4. I know that not all SERCOMs can be used as I2C, but I checked the datasheet and these pins should be fine.

So, I updated my configure_i2c_master function with the following:

config_i2c_master.pinmux_pad0=PINMUX_PB12C_SERCOM4_PAD0;
config_i2c_master.pinmux_pad1=PINMUX_PB13C_SERCOM4_PAD1;

i2c_master_init(&i2c_master_instance, SERCOM4, &config_i2c_master);

But that is not working, any idea on what can be happening?

Many thanks for your help in advance
dlad
Posts: 20
Joined: Mon Jul 27, 2015 4:27 pm

Re: I2C PINMUX

Tue Mar 29, 2016 2:49 pm

Hello,
Could you post the whole i2c init ? It will helps us to know what's going on.

Regards
cventu
Posts: 2
Joined: Mon Mar 28, 2016 10:54 pm

Re: I2C PINMUX

Tue Mar 29, 2016 3:20 pm

Ok, I just find the solution to my problem. I was using the sensor without pull up resistors on SDA and SCL lines and it was working fine when connected on PA08 and PA09. (not sure why)

But when I updated my code to use the I2C on PB12 and PB13 it wasnt working. I added 6K8 resistors on those lines and problem fixed.

Hope it helps someone in the future. I will add my I2C initialization below:

void configure_i2c_master(void)
{
struct i2c_master_config config_i2c_master;
i2c_master_get_config_defaults(&config_i2c_master);

config_i2c_master.buffer_timeout = 10000;

config_i2c_master.pinmux_pad0=PINMUX_PB12C_SERCOM4_PAD0;
config_i2c_master.pinmux_pad1=PINMUX_PB13C_SERCOM4_PAD1;

i2c_master_init(&i2c_master_instance, SERCOM4, &config_i2c_master);
i2c_master_enable(&i2c_master_instance);
}
dlad
Posts: 20
Joined: Mon Jul 27, 2015 4:27 pm

Re: I2C PINMUX

Tue Mar 29, 2016 3:27 pm

There are two external pull-up resistors on the SAMD20-xplained on PA08 & PA09 (R305 and R306).
You can also use internal pull-up.
Regards

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 2 guests