TWI with SAM4SXPlained pro

Moderator: nferre

Posts: 1
Joined: Tue Dec 01, 2015 3:18 pm

TWI with SAM4SXPlained pro

Tue Dec 01, 2015 3:52 pm

Hi everybody,

Recently, I bought a SAM4SXPlained pro to start in the microcontrollers world :). After running a LED blinking program, I am involved now with TWI communication. I am try to communicate with a I2C temperature sensor ( LC74 of Microchip) but I can't and I would need some help. I am using for that the header EXT1 y the pins 11(TWD0) , 12 (TWCLK0) 19 (GND) and 20 (Vcc)

This is the code

#include <asf.h>
#include <twi.h>
int main (void)
/* Initialize the SAM system */

uint8_t buffer;

twi_options_t opt = {
.speed = 100000,
.master_clk =sysclk_get_cpu_hz(),
twi_packet_t packet = {
.addr = 0x00,
.addr_length = 1,
.buffer = (void*)buffer,
.chip = 0x48,//address of the slave
.length = 8

while (1)



Is the code right?
Apparently I am not receiving the NANK of the register status in the function twi_master_read but I don't know why. I think that the connexion between the LC74 and the board is ok

Thank you for you help

Return to “SAM9-based”

Who is online

Users browsing this forum: No registered users and 1 guest