XMEGA32e5 TWI interface - Makes the head hurt - NO MORE START!

Go To Last Post
87 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greets Freaks!

 

I have a possible commercial product in where I will be monitoring some sensors on an I2C bus, and some other items on digital I/O which I will be sending back to a host PC app over RS232.

 

I was going to use my trusty MEGA324 and Peter Fleurys code and move on with my life, but I elected to up my game and go with n XMEGA for this one.  Pretty steep learning curve here(more like a cliff really), but before I run home to mommy, I am still going to give it a go. 

 

I am going to try my luck with a PCF8574 I/O expander to learn the TWI interface on the X32e5.  I created a new START project and all it has is the driver for the TWI in it.  I picked what pins I wanted for my SCL and SDA lines and the bus speed >>100k<<, Chose Interrupt mode as I am not sure if it should be interrupt or polled mode, gave it a name and hit GENERATE.

 

HOLY CRAP!

 

I know from other experiments that a LOT of files would be generated, but what has me a little confused are two files:

 

I2C_master.h

I2C_Simple_master.h

 

And their respective .c files as well.

 

What I am getting a headache over is WHY two sets of files, where each seems to do what the other one does, and it looks like they interact with each other as well.  Which set of functions do I use?  I have to admit the doxygen files are not very helpful.

 

In the meantime, I shall see if I can get an LED to turn on and off with some more reading and guesswork.

 

Atmel START project attached

 

Jim

 

EDIT:  Uploaded correct Atmel Start Project

Attachment(s): 

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Fri. Dec 20, 2019 - 03:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well this is not going well.....

 

Heres my little program:

#include <atmel_start.h>
#include "util/delay.h"

int main(void)
{
	/* Initializes MCU, drivers and middleware */
	atmel_start_init();

	/* Replace with your application code */
	while (1) {
		I2C_0_write1ByteRegister(0x70, NULL, 0x10);
		_delay_ms(500);
		I2C_0_write1ByteRegister(0x70, NULL, 0x00);
		_delay_ms(500);
	}
}

 

I get a laundry list of errors:

 

Do not quite understand what is the problem.  It's an ATMEL START generated project imported and saved via AS7 to teh default folder.

 

Have no idea why the re is a permissions issue.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Ok, the issue with the errors is my Anti Virus kicking up a fuss.  I can bypass that but now I still have the warning:

 

Severity    Code    Description    Project    File    Line
Warning        implicit declaration of function 'I2C_0_write1ByteRegister' [-Wimplicit-function-declaration]    xmega32e5TWI    C:\Users\jgmDESIGNS\Documents\Atmel Studio\7.0\xmega32e5TWI\xmega32e5TWI\main.c    13

 

I do  not see what the issue is.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Is 'I2C_0_write1ByteRegister' declared somewhere? Like in I2C_master.h? Where is the actual function defined?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

ka7ehk wrote:
Where is the actual function defined?

 

Very good question.  Have you ever looked at an Atmel START project after it's been generated?  It could be ANYWHERE!

 

From the file i2c_simple_master.h:

i2c_error_t I2C_0_write1ByteRegister(i2c_address_t address, uint8_t reg, uint8_t data);

 

 

Now I have NO idea where all of these .h files are included.  I would assume START takes care of all of this as it generates teh core program.
 

ECJ

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Have never done a start project, though I will be facing that delight very soon with a 4809.

 

atmel.start.h must be the .h file that has the include statements for the various start #includes. Would not be surprised if it is an auto-generated file.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

ka7ehk wrote:
Would not be surprised if it is an auto-generated file.

It is auto-generated.

 

Contents of atmel_start.h:

#ifndef ATMEL_START_H_INCLUDED
#define ATMEL_START_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "include/driver_init.h"
#include "include/atmel_start_pins.h"

/**
 * Initializes MCU, drivers and middleware in the project
 **/
void atmel_start_init(void);

#ifdef __cplusplus
}
#endif
#endif

 

Contents of include/driver_init.h:

#ifndef DRIVER_INIT_H_INCLUDED
#define DRIVER_INIT_H_INCLUDED

#include <compiler.h>
#include <clock_config.h>
#include <port.h>
#include <atmel_start_pins.h>

#include <osc.h>
#include <ccp.h>

#include <clk.h>
#include <pmic.h>
#include <ccp.h>

#include <sleep.h>

#include <i2c_master.h>

#ifdef __cplusplus
extern "C" {
#endif

void system_init(void);

#ifdef __cplusplus
}
#endif

#endif /* DRIVER_INIT_H_INCLUDED */

 

Contents of i2c_master.h:

#ifndef I2C_MASTER_H
#define I2C_MASTER_H

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <i2c_types.h>

#ifdef __cplusplus
extern "C" {
#endif

#define TWIC_BAUD(F_SCL, T_RISE)                                                                                       \
	((((((float)2000000.0 / (float)F_SCL)) - 10 - ((float)2000000.0 * T_RISE / 1000000))) / 2)

void I2C_0_init(void);

i2c_error_t I2C_0_open(i2c_address_t address);

i2c_error_t I2C_0_close(void);

i2c_error_t I2C_0_master_operation(bool read);

i2c_error_t I2C_0_master_write(void); // to be depreciated

i2c_error_t I2C_0_master_read(void); // to be depreciated

void I2C_0_set_timeout(uint8_t to);

void I2C_0_set_baud_rate(uint32_t baud);

void I2C_0_set_buffer(void *buffer, size_t bufferSize);

// Event Callback functions.

void I2C_0_set_data_complete_callback(i2c_callback cb, void *p);

void I2C_0_set_write_collision_callback(i2c_callback cb, void *p);

void I2C_0_set_address_nack_callback(i2c_callback cb, void *p);

void I2C_0_set_data_nack_callback(i2c_callback cb, void *p);

void I2C_0_set_timeout_callback(i2c_callback cb, void *p);

#ifdef __cplusplus
}
#endif

#endif /* I2C_MASTER_H_INCLUDED */

 

 

Now there is another .h file that is not called out, i2c_simple_master.h:

#ifndef I2C_SIMPLE_MASTER_H
#define I2C_SIMPLE_MASTER_H

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <i2c_types.h>

#ifdef __cplusplus
extern "C" {
#endif

#define I2C_TIMEOUT 10000

#define TWIC_BAUD(F_SCL, T_RISE)                                                                                       \
	((((((float)2000000.0 / (float)F_SCL)) - 10 - ((float)2000000.0 * T_RISE / 1000000))) / 2)

uint8_t     I2C_0_read1ByteRegister(i2c_address_t address, uint8_t reg);
uint16_t    I2C_0_read2ByteRegister(i2c_address_t address, uint8_t reg);
i2c_error_t I2C_0_write1ByteRegister(i2c_address_t address, uint8_t reg, uint8_t data);
i2c_error_t I2C_0_write2ByteRegister(i2c_address_t address, uint8_t reg, uint16_t data);

i2c_error_t I2C_0_writeNBytes(i2c_address_t address, void *data, size_t len);
i2c_error_t I2C_0_readDataBlock(i2c_address_t address, uint8_t reg, void *data, size_t len);
i2c_error_t I2C_0_readNBytes(i2c_address_t address, void *data, size_t len);

#ifdef __cplusplus
}
#endif

#endif /* I2C_SIMPLE_MASTER_H_INCLUDED */

 

 

Hmmmmmmm.....

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Ok, I included the <i2c_simple_master.h> file, and now it builds without errors, but I see no activity on the i2c buss at all.  Checked resistors and power and all good.

 

Frustrating

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Is there an Arduino implementation for the xmega? Maybe i’m just lazy, but i’m doing a little project that has to sit between an i2c master and slave and insert messages from a serial port. Using the Arduino framework i can select from a number of cpus without changing my code.

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

Kartman wrote:
Is there an Arduino implementation for the xmega?

I would doubt it.  Arduino seems to only handle AVR and SAM.

 

 

 

On another note back to the topic of sorts....

 

This function:

i2c_error_t I2C_0_write1ByteRegister(i2c_address_t address, uint8_t reg, uint8_t data);

Is not really useable for the PCF8574 as there is no register to chose from to write to.  the sequence is to send the address with the write bit, and after the ACK, send the data byte.  I tried using NULL for teh register but the compiler issued a warning about a CAST so I wrote the data for both the REG and DATA, even though it compiles without errors, I have no activity on the data bus

 

 

I suppose a simple list of what functions to use/are available is too much to ask.  I have to wade through a bunch of files to find them, and guess.

Damn this is frustrating.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Didn't you get a set of driver usage examples?

/Jakob Selbing

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

jaksel wrote:
Didn't you get a set of driver usage examples?

 

I dont know.  Where would I find this in teh sea of files?

 

Jim

 

EDIT:

 

You mean this, from i2C_master_example.c:

/**
 * \file
 *
 * \brief I2C Master driver example.
 *
 (c) 2018 Microchip Technology Inc. and its subsidiaries.

    Subject to your compliance with these terms,you may use this software and
    any derivatives exclusively with Microchip products.It is your responsibility
    to comply with third party license terms applicable to your use of third party
    software (including open source software) that may accompany Microchip software.

    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
    PARTICULAR PURPOSE.

    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
    BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
    FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
    ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
    THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
 *
 */

#include <atmel_start.h>
#include <i2c_types.h>
#include <i2c_simple_master.h>
#include <utils/atomic.h>

#define slave_adr 0x4f
#define slave_reg_adr 0x0

uint8_t read_data[2];

/** Structure passed into read_handler to describe the actions to be performed by the handler */
typedef struct {
	uint8_t *data;
	uint8_t  size;
} transfer_descriptor_t;

/** This callback is called when the initial write of the pointer register has finished.
    This callback controls the second phase of the I2C transaction, the read of the
    targeted register after a REPEATED START.
*/
i2c_operations_t I2C_0_read_handler(void *d)
{
	transfer_descriptor_t *desc = (transfer_descriptor_t *)d;
	I2C_0_set_buffer((void *)desc->data, desc->size);
	// Set callback to terminate transfer and send STOP after read is complete
	I2C_0_set_data_complete_callback(i2c_cb_return_stop, NULL);
	return i2c_restart_read; // Send REPEATED START before read
}

/** Performs the following transfer sequence:
1. Send SLA+W, Data1
2. Send RepeatedStart, SLA+R, Read Data1, Read Data2
3. Send Stop

This transfer sequence is typically done to first write to the slave the address in
the slave to read from, thereafter to read N bytes from this address.
*/
i2c_error_t I2C_0_do_transfer(uint8_t adr, uint8_t *data, uint8_t size)
{
	/* timeout is used to get out of twim_release, when there is no device connected to the bus*/
	uint16_t              timeout = I2C_TIMEOUT;
	transfer_descriptor_t d       = {data, size};

	while (I2C_BUSY == I2C_0_open(slave_adr) && --timeout)
		; // sit here until we get the bus..
	if (!timeout)
		return I2C_BUSY;

	// 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_0_set_data_complete_callback(I2C_0_read_handler, &d);
	// If we get an address NACK, then try again by sending SLA+W
	I2C_0_set_address_nack_callback(i2c_cb_restart_write, NULL);
	// Transmit specified number of bytes
	I2C_0_set_buffer((void *)&adr, 1);
	// Start a Write operation
	I2C_0_master_operation(false);
	timeout = I2C_TIMEOUT;
	while (I2C_BUSY == I2C_0_close() && --timeout)
		; // sit here until finished.
	if (!timeout)
		return I2C_FAIL;

	return I2C_NOERR;
}

uint8_t I2C_0_test_i2c_master(void)
{

	I2C_0_do_transfer(slave_reg_adr, read_data, 2);
	// If we get here, everything was OK
	return 1;
}

 

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Sun. Dec 15, 2019 - 06:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Is there an Arduino implementation

 

This link is for the Arduino m4809 that I am planning to try for a future project.

 

https://github.com/arduino/ArduinoCore-megaavr/blob/master/libraries/Wire/src/utility/twi.c

 

A few Wiring commands (pinMode) can be changed to register manipulation to remove the Arduino dependency.

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

The ZIP that you attached in #1 appears to be a CodeVision project for an ATxmega128A1

 

Nothing to do with xmega32E5 or Start.

 

If your project is to talk to some I2C slaves and report back over USART it will be trivial.    Just use the Codevision Wizard to write the initialisation code for MCU clock, TWI, USART, ...

 

Then call the library functions:

bool twi_master_trans(

            TWI_MASTER_INFO_t *twi,

            unsigned char slave_addr,

            unsigned char *tx_data,

            unsigned char tx_count,

            unsigned char *rx_data,

            unsigned char rx_count)

 

            performs a TWI transaction using the master module.

 

I googled for Atmel Start I2C and found this web doc

I spent a few minutes trying to find whether the functions required a 7-bit or 8-bit Slave address without success.

 

So I suggest that you simply try their functions and use the status return value.

 

There is no point in using any I2C functions if you ignore the return values.

And that applies to the CV library functions too.

 

David.

 

Edit.   It looks as if the Start functions expect a 7-bit Slave address.   e.g. 0x38 for a PCF8574A

You are using 0x70 in #2 and ignoring any error return.

Last Edited: Sun. Dec 15, 2019 - 10:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Whoops! I attached the wrong zip. Will fix that when I get home later. Thanks for pointing that out David!

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

david.prentice wrote:
Edit.   It looks as if the Start functions expect a 7-bit Slave address.
Likewise in ASF3 with the option of XMEGA's TWI 10-bit addresses.

10 Bit Addressing - I2C Bus

Quick start guide for XMEGA TWI driver | ASF Source Code Documentation

[bottom]

We create a packet for the data that we will send to the slave TWI:

twi_package_t packet = {
    .addr_length = 0,
    .chip        = TWI_SLAVE_ADDR,
    .buffer      = (void *)data,
    .length      = DATA_LENGTH,
    .no_wait     = false
};

 

"Dare to be naïve." - Buckminster Fuller

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

I could not find any reference to 7-bit or 8-bit Slave addresses in your link.

It seems to be a common feature of I2C documentation.

 

Chip makers hide the slave-address values in the data sheets.

I would expect to see bus speed and Slave address on the front page.

 

The wrong address is the most common cause of failure in I2C projects.

Multiplied by ignoring the status return value.

 

I am familiar with I2C but I am horrified by ASF and Start documentation.

Hey-ho.   I expect that young people have a greater pain threshold.

 

David.

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

"Dare to be naïve." - Buckminster Fuller

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

"Dare to be naïve." - Buckminster Fuller

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

I appreciate your links.   However,  Firefox could find TWI chip address to communicate with but nowhere could I find 7-bit

 

As I have said in earlier I2C threads: I2C is very easy to debug.   

But you need to know the form of any arguments before functions work 100% out of the box.    e.g. 7-bit or 8-bit address.

And you must use the return values.

 

Of course you can find the correct bit-width by trial and error.   i.e. examine the status.

 

David.

 

 

Last Edited: Sun. Dec 15, 2019 - 04:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I uploaded teh correct project.

 

david.prentice wrote:
The wrong address is the most common cause of failure in I2C projects.

Agreed, but in this case, my logic analyser is showing no activity on teh bus at all.  I have confirmed the pullup resistors are there and connected and metered the lines and they are holding high

 

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

jgmdesign wrote:
I picked what pins I wanted for my SCL and SDA lines

I'm not sure you have a choice on the matter.
If I recall correctly, 1 set is only available for the special bridge mode. Maybe try the other 2 pins.

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

Picked the default...but I will check again

 

Jim

 

EDIT:  Checked the project in START and I have the choice of PortC0 and PortC1, or PortD0 and PortD1.  I picked PortC

 

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Sun. Dec 15, 2019 - 11:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on.   You could ZIP up your AS7.0 project and attach the ZIP.   30 seconds from your life.

 

I don't have a 32E5 but I do possess 32A4U, 128A4U and 128A1 as well as M4809 or T817

 

Likewise,  you could attach a CV project.    Then we could see where you are going wrong.  (easily)

But it would be a good exercise for me to struggle with Start.     If I get my head around Start,   it would be good experience.

 

David.

 

Edit.  My apologies.   You have attached to your original Post.   Please mention your edit.

Don't expect an immediate solution.    I am in the last throes of Death.   (i.e. man-flu)

Last Edited: Mon. Dec 16, 2019 - 02:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WARNING!

 

On E5's, starting pwm on port C goofs up peripherals using the top 4 bits of port C. It's called a "safety feature."

The largest known prime number: 282589933-1

Without adult supervision.

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

david.prentice wrote:
Please mention your edit.

 

I did mention it in the OP, but I suppose I should have mentioned it further on as well.

 

Torby wrote:

WARNING!

 

On E5's, starting pwm on port C goofs up peripherals using the top 4 bits of port C. It's called a "safety feature."

 

Good to know!  By any chance have you ever managed to get the TWI to work using START?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Well, I am lost.

 

I changed my simple little piece of code to use a different function:

 

#define F_CPU 2000000UL
#include <atmel_start.h>
//#include <avr/io.h>
#include <util/delay.h>
#include <i2c_simple_master.h>

uint8_t on = 0x10 ;
uint8_t off = 0x00;
int main(void)
{
	/* Initializes MCU, drivers and middleware */
	atmel_start_init();

	/* Replace with your application code */
	while (1) {

		I2C_0_writeNBytes(0x38, &on, 1);
		_delay_ms(500);
		I2C_0_writeNBytes(0x38, &off, 1);
		_delay_ms(500);
	}
}

Which I had a feeling would not work, and it did not.  All the pins on the PCF8574A are still sitting low, and there is no activity on the I2C bus as per my Saleae analyser.  I went witht eh above function as it does not have a register to write to as the PCF does not have any registers other than teh one.

 

In the I2C_simple_master.h file there are the following functions defined:

#ifndef I2C_SIMPLE_MASTER_H
#define I2C_SIMPLE_MASTER_H

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <i2c_types.h>

#ifdef __cplusplus
extern "C" {
#endif

#define I2C_TIMEOUT 10000

#define TWIC_BAUD(F_SCL, T_RISE)                                                                                       \
	((((((float)2000000.0 / (float)F_SCL)) - 10 - ((float)2000000.0 * T_RISE / 1000000))) / 2)

uint8_t     I2C_0_read1ByteRegister(i2c_address_t address, uint8_t reg);
uint16_t    I2C_0_read2ByteRegister(i2c_address_t address, uint8_t reg);
i2c_error_t I2C_0_write1ByteRegister(i2c_address_t address, uint8_t reg, uint8_t data);
i2c_error_t I2C_0_write2ByteRegister(i2c_address_t address, uint8_t reg, uint16_t data);

i2c_error_t I2C_0_writeNBytes(i2c_address_t address, void *data, size_t len);
i2c_error_t I2C_0_readDataBlock(i2c_address_t address, uint8_t reg, void *data, size_t len);
i2c_error_t I2C_0_readNBytes(i2c_address_t address, void *data, size_t len);

#ifdef __cplusplus
}
#endif

#endif /* I2C_SIMPLE_MASTER_H_INCLUDED */

And there is a second file called i2c_master.h which as this:

#ifndef I2C_MASTER_H
#define I2C_MASTER_H

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <i2c_types.h>

#ifdef __cplusplus
extern "C" {
#endif

#define TWIC_BAUD(F_SCL, T_RISE)                                                                                       \
	((((((float)2000000.0 / (float)F_SCL)) - 10 - ((float)2000000.0 * T_RISE / 1000000))) / 2)

void I2C_0_init(void);

i2c_error_t I2C_0_open(i2c_address_t address);

i2c_error_t I2C_0_close(void);

i2c_error_t I2C_0_master_operation(bool read);

i2c_error_t I2C_0_master_write(void); // to be depreciated

i2c_error_t I2C_0_master_read(void); // to be depreciated

void I2C_0_set_timeout(uint8_t to);

void I2C_0_set_baud_rate(uint32_t baud);

void I2C_0_set_buffer(void *buffer, size_t bufferSize);

// Event Callback functions.

void I2C_0_set_data_complete_callback(i2c_callback cb, void *p);

void I2C_0_set_write_collision_callback(i2c_callback cb, void *p);

void I2C_0_set_address_nack_callback(i2c_callback cb, void *p);

void I2C_0_set_data_nack_callback(i2c_callback cb, void *p);

void I2C_0_set_timeout_callback(i2c_callback cb, void *p);

#ifdef __cplusplus
}
#endif

#endif /* I2C_MASTER_H_INCLUDED */

 

 

It looks like i2c_simple_master's functions call i2c_master functions.

 

I am missing something easy in all of this but I don't know what.....

 

This cannot be that difficult....Or can it?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Tue. Dec 17, 2019 - 03:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't help with the C or the Start, but once you get this working I'll throw out a reminder regarding the E series interrupts.

 

On some of the Interrupts YOU have to write a bit to manually clear the interrupt from within your ISR, as just executing the ISR does not automatically clear them.

 

The data sheet does say this, but it is different from the classic Mega's and Tinies, and therefore worth being aware of.

 

JC 

 

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

DocJC wrote:
I can't help with the C

I think you are selling yourself a little short.  I looked at BASCOM, and it looks a lot like C in many instances.

 

DocJC wrote:
YOU have to write a bit to manually clear the interrupt from within your ISR, as just executing the ISR does not automatically clear them.

 

Good to know, and I am ASSuming START takes care of this.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Do you even get to the I2C functions? The OSC_init()

int8_t OSC_init()
{

    OSC.XOSCCTRL = OSC_FRQRANGE_9TO12_gc        /* 9 - 12 MHz */
                     | 0 << OSC_X32KLPM_bp        /* 32.768 kHz XTAL OSC Low-power Mode: disabled */
                     | 1 << OSC_XOSCPWR_bp        /* Crystal Oscillator Drive: enabled */
                     | OSC_XOSCSEL_XTAL_1KCLK_gc; /* 0.4-16 MHz XTAL - 1K CLK */
	// Wait for the Oscillators to be stable

	while (!(OSC.STATUS & OSC_XOSCRDY_bm)) {
		/* Wait for External Oscillator to be stable */
	}

looks made for a board with external crystal, is that available on your board?

/Lars

 

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

THIS IS MADNESS!!!!

 

I am not getting any activity on the buss at all.  NOTHING.  I allowed START to set all of this up hardware wise so that should be fine(note I did type SHOULD).  I am guessing at what function will write a single address and a data byte so barring START not configuring the damned chip properly I have no idea what it could be.

 

For sanity check I set up a mega 328 with the PCF8574A and Peter FLeurys code and it worked no issues.....GRRRRRR

 

 

This is beyond frustrating.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Comment out the  OSC_init()  call to rule that out as the problem (unless you are running in the debugger and know you get to the I2C functions).

/Lars

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

Lajon wrote:

Comment out the  OSC_init()  call to rule that out as the problem (unless you are running in the debugger and know you get to the I2C functions).

/Lars

Not running the debugger, but I can if that would answer a bunch of questions.

 

Will try both and get back to you.  THank you!

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Did you notice the question in #30, do you have a crystal on the board (and not a 32k crystal)?

/Lars

 

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

I allowed START

....no comment.... angry when I started to use the E5 I was getting more and more confused with the ASF examples that were supposed to make things easy. Fortunately I was able to get the product working without ASF/START but unfortunately I never used the TWI so can't help.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
getting more and more confused with the ASF examples that were supposed to make things easy.

What I found easiest with trying to understand ASF examples was to use the debugger to step through the code.

 

That way, you can see where it's going - which is difficult to do "statically".

 

But that was just plain ASF  3 -  I haven't tried with START.

 

 

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

How much time does START actually save you?  Maybe they should call it STOP?? I prefer just to look a the datasheet, find the registers I need to use & use them...not sure what start is going to do for you beyond this...maybe set up some queues/buffers or state machine??

So what does using start for I2C work actually provide beyond what is already provided by the chip?

 

With that said, I successfully used Microchip's  "Harmony" to set up and read an ADC channel on a PIC32...it only took about a week to get my reading working (largely due to about 10 pages of ADC errata & 10 pages of Harmony errata working together to create a harmony of frustration)  This must be the trumpeted developers utopia I remember reading about a few years ago.  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Lajon wrote:

Did you notice the question in #30, do you have a crystal on the board (and not a 32k crystal)?

/Lars

 

 

Yes, the XMEGA is on my STK600 using the on board oscillator.  I have confirmed the part is receiving the clock with a scope, and I am also able to program the part.

 

I have also tried this learning experiment using the internal oscillator as well.

 

Will debug late tonight.  THanks!

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Isn't there something about needing to be more explicit on the settings for the port pins than with classic Mega/Tiny? If so, can you confirm that they are all in the right configuration (and, no, I don't know what that might be). One would hope the manual says something. Also, is there an XMega app note about I2C? Maybe

 

http://www.microchip.com//wwwApp...

http://www.microchip.com//wwwApp...

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

ka7ehk wrote:
Isn't there something about needing to be more explicit on the settings for the port pins than with classic Mega/Tiny?

 

YES

 

ka7ehk wrote:
If so, can you confirm that they are all in the right configuration

 

DUNNO, I relied on START to set up the outputs, which it looks like it did, but I really don't understand some of the logic.

 

ka7ehk wrote:
ne would hope the manual says something.

THe manual(s) are quite large so yes a lot is said(written), but does it explain anything......That is the question.

 

ka7ehk wrote:
Also, is there an XMega app note about I2C?

Of course there is, but from teh links you posted one needs to configure teh pins manually....but I think those app notes are written for the IAR compiler....why the hell would app notes be done for 3rd party compilers and not their own is....oh nevermind.

 

 

 I have created a new project in START that runs on the internal 2MHz clock rather than an external one.  the code has become even more simple, witht he only real change being the pointer to a variable...not sure why I did this but ok.

 

I now get the following error:

Severity    Code    Description    Project    File    Line
Warning        implicit declaration of function 'I2C_0_writeNBytes' [-Wimplicit-function-declaration]   

 

THE offending code:

#include <atmel_start.h>

int jim = 0x10;  //turns on a single bit
int *point;


int main(void)
{
	/* Initializes MCU, drivers and middleware */
	atmel_start_init();
point = &jim;

	/* Replace with your application code */
	while (1) {
		I2C_0_writeNBytes(0x38, point,1);
	}
}

New project attached.

 

JIm

 

 

Attachment(s): 

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

"implicit declaration" means that you have called the function without having first defined or declared (ie, prototyped) it.

 

Presumably, it is supposed to be provided via the #include <atmel_start.h> ?

 

Sorry, I know that doesn't help you much - it's hard to find something that isn't there when you're not sure where it should be!

 

If you do a 'find in files' search through the entire Solution, can you find a definition (or even just a declaration) of that function anywhere ?

 

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


jgmdesign wrote:
New project attached

Atmel Studio doesn't trust you!

 

surprise

 

The project does build:

 

	Done executing task "RunCompilerTask".
	Using "RunOutputFileVerifyTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\7.0\Extensions\Application\AvrGCC.dll".
	Task "RunOutputFileVerifyTask"
				Program Memory Usage 	:	1968 bytes   5.3 % Full
				Data Memory Usage 		:	76 bytes   1.9 % Full
	Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "xmega32E5_TWI_INT2MHz.cproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "C:\Program Files (x86)\Atmel\Studio\7.0\7.0\Vs\Avr.common.targets" from project "C:\***\xmega32E5_TWI_INT2MHz\xmega32E5_TWI_INT2MHz.cproj" (entry point):
Done building target "Build" in project "xmega32E5_TWI_INT2MHz.cproj".
Done building project "xmega32E5_TWI_INT2MHz.cproj".

Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

But there is that pesky warning.

 

But the Solution does contain both a declaration & a definition of that function:

 

gives:

 

 

So are you supposed to have included the i2c_simple_master.h header in your main.c ?

Or some other header which contains it?

 

If I do that:

#include <atmel_start.h>

#include "i2c_simple_master.h"

int jim = 0x10;  //turns on a single bit
int *point;


int main(void)
{
	/* Initializes MCU, drivers and middleware */
	atmel_start_init();
point = &jim;

	/* Replace with your application code */
	while (1) {
		I2C_0_writeNBytes(0x38, point,1);
	}
}

it does build cleanly ...

 

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 are you supposed to have included the i2c_simple_master.h header in your main.c ?

Or some other header which contains it?

 

Good question.  I would have guessed that START would include the appropriate files, I mean that would be logical(no pun) right?

 

Anyway, I included the file as you did and it builds clean, but still no activity on the buss.  I am using my Atmel ICE, and when I stopped it I hit the disassembly window.

 

DAMN!

 

awneil wrote:
Atmel Studio doesn't trust you!

That comes up all the time anytime the original source is not from the local hard drive.  ie, the internet(START).  I have copied the project to the local Studio>7.0 folder and I still get the warning.

 

 

The frustration continues.....

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Wed. Dec 18, 2019 - 01:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
I would have guessed that START would include the appropriate files, I mean that would be logical(no pun) right?

Yes,  that's what I'd have thought!

 

Seems stupid to have a tool like START - which is supposed to do all this stuff for you - and then have to manually add the header which, presumably, it created for you?

 

EDIT: It seems that this is a flaw with START - another case here: https://www.avrfreaks.net/commen...

 

frown

 

builds clean, but still no activity on the bus

sad

 

Never used XMega, and don't have any - so can't really help there.

 

 I am using my Atmel ICE, and when I stopped it I hit the disassembly window.

Does that suggest it's crashed? Unhanded interrupt or something?

 

If you just step it in the debugger, can you see where it goes "off into the weeds" ... ?

 

 

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: Thu. Jan 16, 2020 - 11:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Does that suggest it's crashed? Unhanded interrupt or something?

 

If you just step it in the debugger, can you see where it goes "off into the weeds" ... ?

 

Trying to.....

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

So Single stepping through things shows nothing to kick up the disassembly.  I have it running and I pause it once in a while and there is no disassembly window so maybe a glitch...whatever.

 

I see NO activity on the data lines.  START configured them so again, I am assuming they are correctly setup.

 

I have metered the SDA and SCL lines and they are in good order.

 

There has to be something I am misisng here....

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

jgmdesign wrote:
START configured them

Maybe it's another case that it's just written the code  - but has left it to you to explicitly insert the call(s) to that code?

 

If you step into the atmel_start_init() - and into all the nested bits within that  it calls - can you see it doing stuff that should configure pins ... ?

 

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

Well this is new:

 

10:38:27: [ERROR] Failed to initialize ASF distribution 'Object reference not set to an instance of an object.'

Shows up during loading of project

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

This is what I get

 

Not completely expected, I don't have a device with address 38 so the NAQ is expected but the clock should not be held low (and nothing else happens on the bus).

It's running on a xPlained E5.
/Lars

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

YOu are getting that with the project I uploaded?

 

Which project?  Teh first one, or the last one?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

It is the latest with the 0x38 write, not touched in any way.

/Lars

 

Pages