AVR128DB48 TWI 16bit read function

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

Good evening together

 

I need some help with one of my TWI implementations.

I want to read a 16 bit register from a ToF Sensore (VL6380x, STMicroelectronics).

However, i only get the first 8 bits of the sensor. The Acknowledge is set and with the Logig Analyzer the ACKN is sending on the bus.

In the Debug Mode with Jump Over/Into, the second 8bit register will be received. 

My function is listed below.

The TWI and the Sensor on the other functions works fine, so its a problem with the implemantation of the Software.

 

Setup: Global Interrupt Enabled, Read Interrupt Enabled, Write Interrupt Enabled, Baudrate 100kHz

 

 

<

uint16_t i2cReceive2ByteData2cmd(uint8_t addressuint16_t cmduint16_t *data){

    uint8_t adr = (uint8_t) address << 1;

    adr |= WriteI2C;

    uint16_t distance = 0;

    uint8_t tmp = 0;

    uint8_t tmp_MSB;

    uint8_t tmp_LSB;

    uint8_t r[2];

    r[0] = (cmd >> 8);

    r[1] = (cmd & 0xff);

    

    

    while(!(TWI0_MSTATUS & BitMask1)){

        TWI0.MSTATUS |= TWI_BUSSTATE_IDLE_gc; // wait until the I2C Bus is Idle

    }

    

    TWI0_MCTRLA |= TWI_WIF_bm;          // Clear the Write Interrupt Flag (write 1, to clear the Flag)

    TWI0_MCTRLA |= TWI_RIF_bm;          // Clear the Read Interrupt Flag (write 1, to clear the Flag)

    

    TWI0_MADDR = adr;

    while(!(TWI0_MSTATUS & BitMask6)){

        ;// wait until the transfer is complete

    }

    

    if(TWI0_MSTATUS & TWI_RXACK_bm){ // Check if Not ACKnowledge

        //TWI0_MCTRLA |= TWI_WIF_bm;            // Clear the Write Interrupt Flag (write 1, to clear the Flag)

        i2cStop();

        return EC_I2C_NAK;

    }

    

    TWI0_MCTRLA |= TWI_WIF_bm;          // Clear the Write Interrupt Flag (write 1, to clear the Flag)

    TWI0_MCTRLA &= ~TWI_RXACK_bm;       // Clear the RXACK Flag

    

    TWI0_MDATA = r[0];  // Send MSB bytes from Slave register

    

    while(!(TWI0_MSTATUS & TWI_WIF_bm){

        ;   // Wait until Write Interrupt Flag is set

    }

        

    TWI0_MSTATUS |= TWI_WIF_bm; // clear the Write interrupt Flag

    if(TWI0_MSTATUS & TWI_RXACK_bm){

        // Check if ACK has been received

        i2cStop();

        return EC_I2C_NAK;

    }

 

    TWI0_MDATA = r[1];  // Send LSB bytes from Slave register

 

    while(!(TWI0_MSTATUS & TWI_WIF_bm){

        ;   // Wait until Write Interrupt Flag is set

    }

    

    TWI0_MSTATUS |= TWI_WIF_bm; // clear the Write interrupt Flag

    if(TWI0_MSTATUS & TWI_RXACK_bm){

        // Check if ACK has been received

        i2cStop();

        return EC_I2C_NAK;

    }

    

    adr = (uint8_t) address << 1;       // set Address to Read

    adr |= ReadI2C;

    

    TWI0_MADDR = adr;   

    TWI0.MCTRLB &= !TWI_ACKACT_bm;      // ACKN setzen

        

    tmp_MSB = TWI0_MDATA;           // Reading first 8 Bit from slave

            

    TWI0_MSTATUS |= TWI_RIF_bm;     // delete Read Interrupt Flag

    

    TWI0.MCTRLB &= !TWI_ACKACT_bm;      // ACKN setzen

    

    while(!(TWI0_MSTATUS & TWI_RIF_bm){

        ;   // Wait until Read Interrupt Flag is set

    }

 

    tmp_LSB = TWI0_MDATA;

    

    distance = (tmp_MSB << 8);

    distance |= tmp_LSB;

        

    i2cStop();

    return distance;

 

}

>

 

I would appreciate your help and ideas to fix my problem.

Thank you vermi much.

 

Best regards Ste1n12

 

This topic has a solution.
Last Edited: Wed. Jun 9, 2021 - 10:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I could not read your multi-color listing:

uint16_t i2cReceive2ByteData2cmd(uint8_t address, uint16_t cmd, uint16_t *data){
	uint8_t adr = (uint8_t) address << 1;
	adr |= WriteI2C;
	uint16_t distance = 0;
	uint8_t tmp = 0;
	uint8_t tmp_MSB;
	uint8_t tmp_LSB;
	uint8_t r[2];
	r[0] = (cmd >> 8);
	r[1] = (cmd & 0xff);

	while(!(TWI0_MSTATUS & BitMask1)){
		TWI0.MSTATUS |= TWI_BUSSTATE_IDLE_gc; // wait until the I2C Bus is Idle
	}

	TWI0_MCTRLA |= TWI_WIF_bm;          // Clear the Write Interrupt Flag (write 1, to clear the Flag)
	TWI0_MCTRLA |= TWI_RIF_bm;          // Clear the Read Interrupt Flag (write 1, to clear the Flag)

	TWI0_MADDR = adr;
	while(!(TWI0_MSTATUS & BitMask6)){
		;// wait until the transfer is complete
	}

	if(TWI0_MSTATUS & TWI_RXACK_bm){ // Check if Not ACKnowledge
		//TWI0_MCTRLA |= TWI_WIF_bm;            // Clear the Write Interrupt Flag (write 1, to clear the Flag)
		i2cStop();
		return EC_I2C_NAK;
	}

	TWI0_MCTRLA |= TWI_WIF_bm;          // Clear the Write Interrupt Flag (write 1, to clear the Flag)
	TWI0_MCTRLA &= ~TWI_RXACK_bm;       // Clear the RXACK Flag

	TWI0_MDATA = r[0];  // Send MSB bytes from Slave register

	while(!(TWI0_MSTATUS & TWI_WIF_bm){
		;   // Wait until Write Interrupt Flag is set
	}

	TWI0_MSTATUS |= TWI_WIF_bm; // clear the Write interrupt Flag
	if(TWI0_MSTATUS & TWI_RXACK_bm){
		// Check if ACK has been received
		i2cStop();
		return EC_I2C_NAK;
	}

	TWI0_MDATA = r[1];  // Send LSB bytes from Slave register

	while(!(TWI0_MSTATUS & TWI_WIF_bm){
		;   // Wait until Write Interrupt Flag is set
	}

	TWI0_MSTATUS |= TWI_WIF_bm; // clear the Write interrupt Flag
	if(TWI0_MSTATUS & TWI_RXACK_bm){
		// Check if ACK has been received
		i2cStop();
		return EC_I2C_NAK;
	}

	adr = (uint8_t) address << 1;       // set Address to Read
	adr |= ReadI2C;

	TWI0_MADDR = adr;
	TWI0.MCTRLB &= !TWI_ACKACT_bm;      // ACKN setzen

	tmp_MSB = TWI0_MDATA;           // Reading first 8 Bit from slave

	TWI0_MSTATUS |= TWI_RIF_bm;     // delete Read Interrupt Flag

	TWI0.MCTRLB &= !TWI_ACKACT_bm;      // ACKN setzen

	while(!(TWI0_MSTATUS & TWI_RIF_bm){
		;   // Wait until Read Interrupt Flag is set
	}

	tmp_LSB = TWI0_MDATA;

	distance = (tmp_MSB << 8);
	distance |= tmp_LSB;

	i2cStop();
	return distance;

}

I used the "<>" code editor to input your code

 

Jim

I2C protocol says to read two bytes from slave, you read first byte and send ACK, then read second byte and send NAK, then send stop.

When reading data from a slave the last byte the master reads must be NAK'd so the slave knows to release the bus so the master can send stop!

 

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

Last Edited: Mon. Jun 7, 2021 - 08:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Jim, Sorry for the Multicolor Read

First thanks for your Answer :-)

 

My Proble is, i will send the Adress with the Read Direction, and after that, i send the Acknowledge. 
But after my Acknowledge, the second Byte Register is not sendig from the Slave.

 

Did i need first set the TWI Master to NACk, that the Sensor release the Bus??

 

Ste1n12

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

ste1n12 wrote:
Did i need first set the TWI Master to NACk, that the Sensor release the Bus??

The answer should be in the DS for the sensor, can you post a link to it please.

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

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


Here is the Datasheet of the Sensor.

 

https://www.st.com/resource/en/datasheet/vl6180x.pdf

 

What i understand of the Picture below is, that i must send an ACKN and the Slave will send automaticli the Data. Is that correct?

 

This Picture is found at Site 43 of the Datasheet

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

The previous page suggests: 

  • Ais an ACK from the Slave;
  • AM is an ACK from the Master; 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Without trying to figure out your code or where it is going wrong, I would first get squared away with dealing in the right registers, TWI0_MCTRLA is not TWI0_MSTATUS, and there are 3 instances of this such as-

    TWI0_MCTRLA |= TWI_WIF_bm; //WIF is in MSTATUS, not MCTRLA

 

the following is simply TWI0.MCTRLB = 0, as !4 is 0 and &= 0 is always 0, so may not be what you are after even though it probably ends up ok in this case if you wanted ACK-

    TWI0.MCTRLB &= !TWI_ACKACT_bm;

(you were probably wanting ~ instead of !, although see below as you do not need that either)

 

writing a command of 0 is harmless (for a reason), which means you can set ACKACT with a simple write instead of setting/clearing bits-

    TWI0.MCTRLB = TWI_ACKACT_bm; //NACK

    TWI0.MCTRLB = 0; //ACK

 

the RXACK bit is read-only, so no need to try and change it-

    TWI0_MCTRLA &= ~TWI_RXACK_bm;

 

I would also take note of when flags need to be cleared, and when the twi takes care of it for you. Read the datasheet MSTATUS register description, you will see most flag clearing is done by twi on its own. Also be consistent in the use of the registers- TWI0_MCTRLA is using a define, TWI0.MCTRLB is via struct. In c, use the struct version for register access.

 

 

The following is a simple interrupt drive twi driver for avr0/1 and da, although for the da the pins are using the same as what the mega uses, which is true in some cases but I have not checked out all the various dx parts and what pins they may be on (or if they have more than one twi instance). Maybe this code will give you ideas and how the twi works.

https://github.com/cv007/Avr01Dx...

 

Used such as-

 

//vlx.h

#include <stdint.h>

#include <stdbool.h>

bool vlx_distance(uint16_t*);

 

//vlx.c

#include "twim.h"

#include "vlx.h"

 

//--private--

enum { ADDRESS = 0x29, SPEED = 100000ul, ALTPINS = 0, TIMEOUT = 3000 };

enum { DISTANCE_REG16 = 0x52 };

 

static bool init(){

    if( twim_isBusy() ) return false; //if twi already in use by some other task

    if( ALTPINS ) twim_altPins(); else twim_defaultPins(); //pin pullups, portmux

    twim_baud( F_CPU, SPEED );

    twim_on( ADDRESS );

    return true;

}

 

static bool read16(uint16_t reg, uint16_t* v){

    if( ! init() ) return false;

    uint8_t wbuf[2] = { reg>>8, reg & 0xff }; //H:L

    uint8_t rbuf[2];

    twim_writeRead( wbuf, 2, rbuf, 2 );

    bool ok = twim_waitUS( TIMEOUT ); //allow up to TIMEOUT (us) to complete

    if( ok ) *v = rbuf[0}<<8 | rbuf[1]; //assuming H:L

    twim_off(); //pins have pullups on, so off is good in any case (errors or not)

    return ok;

}

 

//--public--

bool vlx_distance(uint16_t* v){

    return read16( DISTANCE_REG16, v );

}

 

 

//main.c

#include "vlx.h"

#include <avr/interrupt> //sei()

 

int main(){

    sei(); //twim_ requires interrupts on

    uint16_t data;

    while(1){

        if( vlx_distance(&data) ){ /* do something with data */ }

    }

}

 

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


That picture shows a multi-byte write operation, I thought you were asking about multi-byte read?

Jim

 

This seems wrong to me, the circled Ack, should be a NAK sent by the master to tell the slave the master is done reading data, release the bus and let the master send stop!

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

Last Edited: Tue. Jun 8, 2021 - 05:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


So here's the multiple read:

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your support 

Curtvm had right and i did a misstake with the TWI0_MStatus and the TWI0_MCTRLA Register. 

Also i deleted the while loops for the Flag Checks.

At the End, now it works fine :-)

 

Thank you very much

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

ste1n12 wrote:

At the End, now it works fine :-)

 

Then please mark the post that gave the answer as being the solution to your problem, so that in the future others can see this question actually has an answer.

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

meslomp wrote:
Then please mark the post that gave the answer as being the solution to your problem

Don't let Cliff see you saying that ...

 

cheeky

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Don't let Cliff see you saying that ...

I have no camera here, not even an office spy cam, so not worried that Cliff would see me saying it ;) Also I do not talk out loud when I type, so double secured on that one, but thanks for caring for me I really appreciate it.

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

 

I am trying out @curtvm twi lib from with an AVR128DA28.

 

The slave did not Ack the master, I see the address on my Oscilloscope, but that is all. I started to add a uart for debugging, but I better hold that idea for now. I recall being tripped up by missing sei(); the other was in twiPins.h where I changed the second define check to use PORTMUX_TWIROUTEA.

 

https://github.com/epccs/MacGyver/blob/master/Applications/Avr01Dx_Twi-main/twiPins.h#L23

 

One other thing I noticed in the DS has to do with the ENABLE bit in MCTRLA. For bus errors to be detected by the slave, the ENABLE bit needs to be on in ether TWI0.DUALCTRL or TWI0.MCTRLA, maybe the slave should turn on the bit in DUALCTRL. Anyway, thanks for sharing that it is the most information-dense TWI lib I have seen, and that seems to help me grok.

 

update: setting the ENABLE bit in DUALCTRL will split the master and slave, e.g. with PORTMUX.TWIROUTEA = PORTMUX_TWI0_ALT2_gc master is on PC2:PC3 and slave is on PC6:PC7.

 

 

 

Last Edited: Thu. Jun 10, 2021 - 11:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ron_sutherland wrote:
The slave did not Ack the master

So it didn't see its address

 

Quote:
I see the address on my Oscilloscope

And is it the correct address ?

 

This is an age-old problem: https://www.avrfreaks.net/commen...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I messed something up with latest changes, I'll fix it. I probably was changing something I thought was harmless and didn't test.

 

 

twis.c

 

I screwed up in typing- the error mask value I had was 0xC0, it should have been 0x0C, I changed it in the Github. Not sure how I did that, but I have lots of practice (it happened when I added another state- instead of putting errors in the STOPPED state, I created an ERROR state where I then got my C flipped).

static bool isError         (u8 v) { return (v & 0x0C); }          //COLL,BUSERR

I should probably make those values enums like I did in twim, I'll probably change that (and test)- (done).

 

Also changed the twipins ifdef for da to PORTMUX_TWIROUTEA.

 

Sorry about that.

 

I also added sei() to the examples, which I had forgot about (I removed from the twi code). I recently decided that letting peripherals have control of the interrupt bit is not a great idea. They are in no position to know whether the caller had interrupts off for a good reason, so now think there should be one point in time where sei() is used, and the one behind the keyboard makes that decision when/where (and there is only 1 sei). Any other code can certainly save/restore interrupt status, but no one can enable by their own 'authority'. The downside is there is no 'automatic' anymore, and if you use the twi in early code (init an lcd, for example), then you better use sei before that. In C++, that also means you have to think about what goes in a constructor (which may be global, run in startup), but that is a good thing to think about in any case.

 

I'm not sure if the slave needs to know about bus errors, so I would leave it alone until it becomes obvious it is needed. I assume the slave will continue about its business no matter what, and assume its engine gets halted on stop and started on a start, and in between it does its thing. I'm also assuming if it was important, they would have the bus error detection on in the slave also. The master, or masters, are in charge so they can deal with self-created bus errors or deal with multi-master bus errors. I'm not sure what the slave is going to do about it anyway. I guess it still gets to figure out if someone else is stomping on its bits, and tells you via the collision bit.

 

Last Edited: Thu. Jun 10, 2021 - 01:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

curtvm wrote:
Sorry about that.

 

Do not apologize; I have been staring at my i2c port for months, trying to sort out what was wrong; your code fits my mental buffer much better than what I was doing; going through it was a real eye-opener; it took a few hours (and some pain). Still, after that, I think code style is what I need to work on most.

 

I will give the changes a spin and report back in a few hours.

Last Edited: Thu. Jun 10, 2021 - 07:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice, it works; here is some image <<<links>>> for @awneil who made me get the phone out of the microwave.

 

https://github.com/epccs/MacGyver/blob/master/Applications/Avr01Dx_Twi-main/address_not_ack_by_slave.jpg

 

 

https://github.com/epccs/MacGyver/blob/master/Applications/Avr01Dx_Twi-main/address_ack_by_slave.jpg

 

 

For future reference the name of that folder will likely change to Avr01Dx_Twi. I don't know how the -main got on it, it may be from the zip I got form Github ¯\_ (:-/)_/¯

 

<<<>>>: forum will not upload probably for the same reason my phone was in microwave.

 

 

Last Edited: Thu. Jun 10, 2021 - 07:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

ron_sutherland wrote:
forum will not upload probably for the same reason my phone was in microwave

Or this: https://www.avrfreaks.net/forum/media-browser-you-are-not-authorized-access-page

 

As noted there, pasting & attaching should still work...

 

 

 

 

So is that the correct slave address?

 

Surely, your scope has a way to capture screenshots? That gives far better results than trying to photograph the screen!

(and you could've left the phone in the microwave)

 

Doesn't seem that this has anything to do with the OP's question - which seems to have been resolved at #10 ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Jun 11, 2021 - 07:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
OP's question - which seems to have been resolved at #10 ?

 

hmm

 

#10 is where the code I was trying was from

 

curtvm wrote:

Maybe this code will give you ideas and how the twi works.

https://github.com/cv007/Avr01Dx...

 

the images are a before and after of the change curtvm made to the repo linked in post #10, the code helped me and the OP marked that post as the solution so ... Welp, my mood has turned foul.

 

awneil wrote:
So is that the correct slave address?

 

What does the code say?

 

https://github.com/cv007/Avr01Dx_Twi/blob/351d4b4fba678b4d7ca6cdc13a1a040e76d32046/main.c#L93

 

update: link to a version so the line number will not change

 

 

Last Edited: Fri. Jun 11, 2021 - 06:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

So is that the correct slave address?

ron_sutherland wrote:
What does the code say?

I mean, is it the right address for your Slave ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

So is that the correct slave address?

ron_sutherland wrote:
What does the code say?

I mean, is that the correct address for your Slave?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


awneil wrote:
I mean, is that the correct address for your Slave?

 

What? The AVR128DA is mastering and slaving on the same chip (with itself). Try that on a 328p; after I sort out how to use the library, I plan to try a multi-master between an AVR128DA28 and an AVR128DB32; it will take a few days or weeks ... who knows. But man, are my happy curtvm posted that lib.

 

 

update: add an image curtvm added to that repo (I am trying the cut/paste, ha it seems to work, but will I recall for next time?)

 

Last Edited: Sat. Jun 12, 2021 - 02:20 AM