Unable to get Atmel START I2C Master for ATMega328PB working.

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

Hello,

We've been working on a project that utilizes both I2C interfaces (TWI0 and TWI1), althought we've been unable to get either one working. We've been trying every single option related to TWI/I2C in Atmel START and have been through the source code she generates. It seems it gets stuck in an infinite loop in the following function: (generated by START):

 

void I2C_do_transfer(uint8_t adr, uint8_t *data, uint8_t size)
{
	transfer_descriptor_t d = {data, size};
	while (!I2C_open(slave_adr))
		; // sit here until we get the bus..

	// This callback specifies what to do after the first write operation has completed
	// The parameters to the callback are bundled together in the aggregate data type d.
	I2C_set_data_complete_callback(I2C_read_handler, &d);
	// If we get an address NACK, then try again by sending SLA+W
	I2C_set_address_nack_callback(i2c_cb_restart_write, NULL);
	// Transmit specified number of bytes
	I2C_set_buffer((void *)&adr, 1);
	// Start a Write operation
	I2C_master_operation(false);
	while (I2C_BUSY == I2C_close())
		; // sit here until the entire chained operation has finished (WHICH DOESN'T!!!)
}

We've switched interrupts on and off, globally and for the TWI only, nothing helps.

 

It's also strange that START produces code that traps execution in multiple places it seems. We're close to going nuts over this. Is anyone able to point us in the right direction? There's devices and (4k7)pullups at the other ends of the bus on both modules.

 

Sincerely,

yasuo and MrAlfabet

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

Surely it must be possible to get the Fleury lib to work on a 328PB ?

 

I think you'll find it a lot more pleasant experience than Atmel Start!

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

clawson wrote:
Surely it must be possible to get the Fleury lib to work on a 328PB ?

Look here for Peter's I2C software: http://homepage.hispeed.ch/peter...

 

 

 

 

 

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

All right I'll give it a go asap. Funny how my colleague suggested this but we both waved it off before even getting started. Should this work for both TWIs?

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

yasuo wrote:
Should this work for both TWIs?

As it was written for AVR's with one TWI, I don't know, but should give you a good base to mod if needed.

It's the TWI code almost all Freaks use.

Jim