TWI with SAM4SXPlained pro

AT91EB40A, EB55, EB42 Evaluation Boards , AT91RM9200-DK, RM3400-DK will be the focus of the discussions: hardware guidance, embedded software, use,...

Moderator: nferre

Txinde
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)
{
board_init();
/* Initialize the SAM system */
SystemInit();
sysclk_init();
pmc_enable_periph_clk(ID_TWI0);


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)
{

twi_enable_master_mode(TWI0);
twi_master_init(TWI0,&opt);
twi_master_read(TWI0,&packet);


}


}
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 “Evaluation and Development Boards”

Who is online

Users browsing this forum: No registered users and 1 guest