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
I2C PINMUX
Moderator: nferre
Post
Re: I2C PINMUX
Hello,
Could you post the whole i2c init ? It will helps us to know what's going on.
Regards
Could you post the whole i2c init ? It will helps us to know what's going on.
Regards
Post
Re: I2C PINMUX
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);
}
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);
}
Post
Re: I2C PINMUX
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
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 0 guests