Microchip livestream

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

We will be starting a livestream about AVR, Atmel Start, Atmel Studio and Click-boards shortly:

https://www.youtube.com/watch?v=...

Jacob

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

I found Atmel Start about an hour ago.  Configured an ATtiny1616, Atmel Start was quite easy to use.

 

EDIT: added context

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

Last Edited: Thu. Nov 30, 2017 - 10:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So from what I see we can start to expect more new members asking for help on MikroElectronika click board devices.

 

Guess I shall go take a peek at these things in anticipation.

 

Jim

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

Please Read: Code-of-Conduct

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

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

Informative presentation.  I do have some feedback on and questions about Atmel Start, is there a dedicated place to post them?  Microchip/Atmel representatives only please.

 

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

Last Edited: Thu. Nov 30, 2017 - 08:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larryvc wrote:
I do have some feedback on and questions about Atmel Start, is there a dedicated place to post them?

Thats a very good question....What sub forum here would that be?

 

larryvc wrote:
Microchip/Atmel representatives only please.

Well excuse the rest of us.....wink

 

Jim

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

Please Read: Code-of-Conduct

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

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

Isn't Atmel start just another name for ASF?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Hi Larryvc,

I will keep an eye on this thread. Otherwise the livestream@microchip.com address can also be used, but it is more fun for all of us if we have an open discussions that others can chime in on, right :-)

Jacob

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

Hi John,

Well, the intention with START is to have more compact code. The code is generated, which means that a lot of the run-time configuration that is used in ASF is not present in START code. This is IMO also making it more readable. If you haven't done it yet, try to generate a project and have a look at the generated code. We would really like to get feedback.

Jacob

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

If you haven't done it yet, try to generate a project

I think I have used Start with the TinyX817?? and the SAMD21  to play with but as I am semiretired now I no longer care to burn neurons on unnecessary stuff. cheeky

 

Anything above AVR ASM is unnecessary. wink

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

 

Jacob wrote:

I will keep an eye on this thread. Otherwise the livestream@microchip.com address can also be used, but it is more fun for all of us if we have an open discussions that others can chime in on, right :-)

Hi Jacob,

 

The intent was to not get a multitude of answers from the mode.. (peanut gallery;)  and to see if you guys had something already set up where we could have those open discussions.  I am fine with doing it here but perhaps a thread started by you with the title "Atmel Start Questions and Feedback" and a little invite for us would be useful in kicking it off.  The title "Microchip livestream" doesn't seem focused enough and besides, starting a new thread allows you to continue using this thread to notify us of future presentations.

 

Thanks,

Larry

 

EDIT: wording

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

Last Edited: Thu. Nov 30, 2017 - 10:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larryvc wrote:
  The intent was to not get a multitude of answers from the mode.. (peanut gallery) 

Thats a little insulting. surprise

 

Jim

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

Please Read: Code-of-Conduct

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

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

Jacob wrote:
Well, the intention with START is to have more compact code.

Seriously?  Has START been revamped as the last time I tried it for an AVR8 the bloat was unreal.

 

Same thing for SAM, but ASF does the same thing.

 

Please expand on this.

 

Jim

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

Please Read: Code-of-Conduct

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

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

Hi Jim,

I do not agree that START code is bloated. As example this is the generated ADC initialization. So except for having a return parameter, it is pretty much what you have to write to get the ADC configured.

int8_t ADC_0_init()
{

	// ADC0.CALIB = ADC_DUTYCYC_DUTY50_gc; /* 50% Duty cycle */

	ADC0.CTRLB = ADC_SAMPNUM_ACC16_gc; /* Accumulate 16 samples */

	ADC0.CTRLC = ADC_PRESC_DIV64_gc     /* CLK_PER divided by 64 */
	             | ADC_REFSEL_INTREF_gc /* Internal reference */
	             | 0 << ADC_SAMPCAP_bp; /* Sample Capacitance Selection: disabled */

	// ADC0.CTRLD = 0 << ADC_ASDV_bp /* Automatic Sampling Delay Variation: disabled */
	//		 | 0x0 << ADC_SAMPDLY_gp /* Sampling Delay Selection: 0x0 */
	//		 | ADC_INITDLY_DLY0_gc; /* Delay 0 CLK_ADC cycles */

	ADC0.CTRLE = ADC_WINCM_ABOVE_gc; /* Above Window */

	// ADC0.DBGCTRL = 0 << ADC_DBGRUN_bp; /* Debug run: disabled */

	// ADC0.EVCTRL = 0 << ADC_STARTEI_bp; /* Start Event Input Enable: disabled */

	ADC0.INTCTRL = 1 << ADC_RESRDY_bp  /* Result Ready Interrupt Enable: enabled */
	               | 1 << ADC_WCMP_bp; /* Window Comparator Interrupt Enable: enabled */

	ADC0.MUXPOS = ADC_MUXPOS_AIN5_gc; /* ADC input pin 5 */

	// ADC0.SAMPCTRL = 0x0 << ADC_SAMPLEN_gp; /* Sample length: 0x0 */

	ADC0.WINHT = 0xc8; /* Window Comparator High Threshold: 0xc8 */

	// ADC0.WINLT = 0x0; /* Window Comparator Low Threshold: 0x0 */

	ADC0.CTRLA = 1 << ADC_ENABLE_bp     /* ADC Enable: enabled */
	             | 1 << ADC_FREERUN_bp  /* ADC Freerun mode: enabled */
	             | ADC_RESSEL_10BIT_gc  /* 10-bit mode */
	             | 0 << ADC_RUNSTBY_bp; /* Run standby mode: disabled */

	return 0;
}
int8_t ADC_0_init()
{

	// ADC0.CALIB = ADC_DUTYCYC_DUTY50_gc; /* 50% Duty cycle */

	ADC0.CTRLB = ADC_SAMPNUM_ACC16_gc; /* Accumulate 16 samples */

	ADC0.CTRLC = ADC_PRESC_DIV64_gc     /* CLK_PER divided by 64 */
	             | ADC_REFSEL_INTREF_gc /* Internal reference */
	             | 0 << ADC_SAMPCAP_bp; /* Sample Capacitance Selection: disabled */

	// ADC0.CTRLD = 0 << ADC_ASDV_bp /* Automatic Sampling Delay Variation: disabled */
	//		 | 0x0 << ADC_SAMPDLY_gp /* Sampling Delay Selection: 0x0 */
	//		 | ADC_INITDLY_DLY0_gc; /* Delay 0 CLK_ADC cycles */

	ADC0.CTRLE = ADC_WINCM_ABOVE_gc; /* Above Window */

	// ADC0.DBGCTRL = 0 << ADC_DBGRUN_bp; /* Debug run: disabled */

	// ADC0.EVCTRL = 0 << ADC_STARTEI_bp; /* Start Event Input Enable: disabled */

	ADC0.INTCTRL = 1 << ADC_RESRDY_bp  /* Result Ready Interrupt Enable: enabled */
	               | 1 << ADC_WCMP_bp; /* Window Comparator Interrupt Enable: enabled */

	ADC0.MUXPOS = ADC_MUXPOS_AIN5_gc; /* ADC input pin 5 */

	// ADC0.SAMPCTRL = 0x0 << ADC_SAMPLEN_gp; /* Sample length: 0x0 */

	ADC0.WINHT = 0xc8; /* Window Comparator High Threshold: 0xc8 */

	// ADC0.WINLT = 0x0; /* Window Comparator Low Threshold: 0x0 */

	ADC0.CTRLA = 1 << ADC_ENABLE_bp     /* ADC Enable: enabled */
	             | 1 << ADC_FREERUN_bp  /* ADC Freerun mode: enabled */
	             | ADC_RESSEL_10BIT_gc  /* 10-bit mode */
	             | 0 << ADC_RUNSTBY_bp; /* Run standby mode: disabled */

	return 0;
}
int8_t ADC_0_init()
{

	// ADC0.CALIB = ADC_DUTYCYC_DUTY50_gc; /* 50% Duty cycle */

	ADC0.CTRLB = ADC_SAMPNUM_ACC16_gc; /* Accumulate 16 samples */

	ADC0.CTRLC = ADC_PRESC_DIV64_gc     /* CLK_PER divided by 64 */
	             | ADC_REFSEL_INTREF_gc /* Internal reference */
	             | 0 << ADC_SAMPCAP_bp; /* Sample Capacitance Selection: disabled */

	// ADC0.CTRLD = 0 << ADC_ASDV_bp /* Automatic Sampling Delay Variation: disabled */
	//		 | 0x0 << ADC_SAMPDLY_gp /* Sampling Delay Selection: 0x0 */
	//		 | ADC_INITDLY_DLY0_gc; /* Delay 0 CLK_ADC cycles */

	ADC0.CTRLE = ADC_WINCM_ABOVE_gc; /* Above Window */

	// ADC0.DBGCTRL = 0 << ADC_DBGRUN_bp; /* Debug run: disabled */

	// ADC0.EVCTRL = 0 << ADC_STARTEI_bp; /* Start Event Input Enable: disabled */

	ADC0.INTCTRL = 1 << ADC_RESRDY_bp  /* Result Ready Interrupt Enable: enabled */
	               | 1 << ADC_WCMP_bp; /* Window Comparator Interrupt Enable: enabled */

	ADC0.MUXPOS = ADC_MUXPOS_AIN5_gc; /* ADC input pin 5 */

	// ADC0.SAMPCTRL = 0x0 << ADC_SAMPLEN_gp; /* Sample length: 0x0 */

	ADC0.WINHT = 0xc8; /* Window Comparator High Threshold: 0xc8 */

	// ADC0.WINLT = 0x0; /* Window Comparator Low Threshold: 0x0 */

	ADC0.CTRLA = 1 << ADC_ENABLE_bp     /* ADC Enable: enabled */
	             | 1 << ADC_FREERUN_bp  /* ADC Freerun mode: enabled */
	             | ADC_RESSEL_10BIT_gc  /* 10-bit mode */
	             | 0 << ADC_RUNSTBY_bp; /* Run standby mode: disabled */

	return 0;
}

Can you give some specific examples of what is bloated Jim?

Jacob

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

THats for a SAM device correct?  I ask because I am not aware of being able to select a sample capacitor in AVR8:

 

ADC0.CTRLC = ADC_PRESC_DIV64_gc     /* CLK_PER divided by 64 */
	             | ADC_REFSEL_INTREF_gc /* Internal reference */
	             | 0 << ADC_SAMPCAP_bp; /* Sample Capacitance Selection: disabled */

 

And I did say AVR8 first,  Keep in mind Jacob this discussion regarding START/ASM = BLOAT has been spit up here numerous times in the past.

 

Maybe the bloat I see in SAM is acceptable, but I am still in my early stages with SAM devices so I will concede on the SAM, but from what I have seen from some examples from others that do not use ASF/START they do not need nearly the lines START generates.  I have to go look for an example that someone sent me for the SAM, maybe we can see what start generates and compare?

 

Back to AVR8...... based on the video, is Micromel-Atchip expecting us to use START for AVR8 devices?

 

Jim

 

 

 

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

Please Read: Code-of-Conduct

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

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

Hi Jim,

 

This code example I gave you is for the ATtiny817.

 

We would like to see people use START for the AVR products. Initially START was only able to configure the peripherals, but we have added some actual drivers as well now so that you have functions to use the peripheral at run-time, and not only configure them at start-up.

Jacob

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

I saw the YouTube video utilized the Tiny817.

 

I wondered if I can use my favorite programmer, the Atmel AVR ISP MkII to program the Tiny817?

I'm using Studio 6.2.1548 SP2 currently.

 

I did not see the Tiny817 on the pull down list.

 

JC

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

Jacob wrote:
This code example I gave you is for the ATtiny817.
Jacob wrote:
Can you give some specific examples of what is bloated Jim?

The Tiny817 seems to be more in line with Xmegas than AVR8 .  THere is a long running thread on the T817 here:

http://www.avrfreaks.net/forum/a...

Where some agree the T817 behaves a little more like an XMEGA device, but thats another argument for another time wink

 

Jacob wrote:
Can you give some specific examples of what is bloated Jim?

I can try.

 

I created a project using START(which is opened in AS7), and one using Studio6_2.  I admit up front that I used the Codevision Wizard to configure the USART and pasted the result into the Studio project, but it's of no matter as I would have wrote the same thing had I done it myself.

 

I chose the Mega328P as its a pretty common part.  The only thing in the 'application' is initialising the USART, nothing more.

 

Mt AS6_2 project code looks like this:

/*
 * GccApplication1.c
 *
 * Created: 11/30/2017 9:35:02 PM
 *  Author: jgmDESIGNS-Laptop
 */ 


#define F_CPU 11059000ul
#include <avr/io.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <util/delay.h>
#include <avr/interrupt.h>



void usart_init(void)
{
	// USART initialization
	// Communication Parameters: 8 Data, 1 Stop, No Parity
	// USART Receiver: On
	// USART Transmitter: On
	// USART0 Mode: Asynchronous
	// USART Baud Rate: 9600
	UCSR0A=(0<<RXC0) | (0<<TXC0) | (0<<UDRE0) | (0<<FE0) | (0<<DOR0) | (0<<UPE0) | (0<<U2X0) | (0<<MPCM0);
	UCSR0B=(0<<RXCIE0) | (0<<TXCIE0) | (0<<UDRIE0) | (1<<RXEN0) | (1<<TXEN0) | (0<<UCSZ02) | (0<<RXB80) | (0<<TXB80);
	UCSR0C=(0<<UMSEL01) | (0<<UMSEL00) | (0<<UPM01) | (0<<UPM00) | (0<<USBS0) | (1<<UCSZ01) | (1<<UCSZ00) | (0<<UCPOL0);
	UBRR0H=0x00;
	UBRR0L=0x47;

}
int main(void)
{
	usart_init();
	
    while(1)
    {
        //TODO:: Please write your application code 
    }
}

And my solution explorer window looks like this:

 

Pretty simple and straightforward

My build output says:

 

166 bytes program memory used.

 

 

Now in the START project I have this:

 

And in my solution explorer window I have this:

 

Thats a lot more stuff!  But where is the initialisation routine for the USART?

Ok, if I GOTO IMPLEMENTATION on the call it takes me to  'Atmel_start.c"  And in that file I have:

 

Another call to another function!  I GOTO IMPLEMENTATION for 'System_init()' and it takes me to 'driver_init.c' and in that file I have:

 

More calls!  So I GOTO IMPLEMENTATION for USART_0_initialization() and it takes me to the same file where the actual code sits:

/* configure pins and initialize registers */
void USART_0_initialization(void)
{

	// Set pin direction to input
	PD0_set_dir(PORT_DIR_IN);

	PD0_set_pull_mode(
	    // <y> Pull configuration
	    // <id> pad_pull_config
	    // <PORT_PULL_OFF"> Off
	    // <PORT_PULL_UP"> Pull-up
	    PORT_PULL_OFF);

	// Set pin direction to output
	PD1_set_dir(PORT_DIR_OUT);

	PD1_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

	USART_0_init();
}

Now here is where its a little funny.  The code goes and sets the PD0 and PD1 pins as input and output, which is really unnecessary as once you enable the Receiver and Transmitter the hardware automatically  takes over those pins so setting them is really not needed, but I will grant its not a deal breaker.

 

BUT THERE IS YET ANOTHER CALL!  Right at the end.  THis takes me yet to ANOTHER file called 'usart_basic.c' and in this file we find:

int8_t USART_0_init()
{

	// Module is in UART mode

	/* Enable USART0 */
	PRR &= ~(1 << PRUSART0);

#define BAUD 9600

#include <utils/setbaud.h>

	UBRR0H = UBRRH_VALUE;
	UBRR0L = UBRRL_VALUE;

	UCSR0A = USE_2X << U2X0 /*  */
	         | 0 << MPCM0;  /* Multi-processor Communication Mode: disabled */

	UCSR0B = 1 << RXCIE0    /* RX Complete Interrupt Enable: enabled */
	         | 0 << UDRIE0  /* USART Data Register Empty Interupt Enable: disabled */
	         | 1 << RXEN0   /* Receiver Enable: enabled */
	         | 1 << TXEN0   /* Transmitter Enable: enabled */
	         | 0 << UCSZ02; /*  */

	// UCSR0C = (0 << UMSEL01) | (0 << UMSEL00) /*  */
	//		 | (0 << UPM01) | (0 << UPM00) /* Disabled */
	//		 | 0 << USBS0 /* USART Stop Bit Select: disabled */
	//		 | (1 << UCSZ01) | (1 << UCSZ00); /* 8-bit */

	return 0;
}

Four calls to finally get to the actual USART configuration using START  One call the other way.

 

When I hit BUILD>SOLUTION my output screen has this:

 

302 bytes to configure the USART.  Almost double.  

 

Now in the grand scheme, this little test does not impact a 32k device, but as applications grow, a few hundred bytes here and there start to add up.

 

I added to both projects configuring PORTC0..5 as outputs.

 

Heres the build for START:

 

20 bytes, not bad...

 

Standard Studio project:

 

6 bytes more.

 

Non-START project code:

void avr_init(void)
{
	
	// Port C initialization
	// Function: Bit6=In Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out
	DDRC=(0<<DDC6) | (1<<DDC5) | (1<<DDC4) | (1<<DDC3) | (1<<DDC2) | (1<<DDC1) | (1<<DDC0);
	// State: Bit6=T Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0
	PORTC=(0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0);
	
	// USART initialization
	// Communication Parameters: 8 Data, 1 Stop, No Parity
	// USART Receiver: On
	// USART Transmitter: On
	// USART0 Mode: Asynchronous
	// USART Baud Rate: 9600
	UCSR0A=(0<<RXC0) | (0<<TXC0) | (0<<UDRE0) | (0<<FE0) | (0<<DOR0) | (0<<UPE0) | (0<<U2X0) | (0<<MPCM0);
	UCSR0B=(0<<RXCIE0) | (0<<TXCIE0) | (0<<UDRIE0) | (1<<RXEN0) | (1<<TXEN0) | (0<<UCSZ02) | (0<<RXB80) | (0<<TXB80);
	UCSR0C=(0<<UMSEL01) | (0<<UMSEL00) | (0<<UPM01) | (0<<UPM00) | (0<<USBS0) | (1<<UCSZ01) | (1<<UCSZ00) | (0<<UCPOL0);
	UBRR0H=0x00;
	UBRR0L=0x47;

}
int main(void)
{
	avr_init();
	
    while(1)
    {
        //TODO:: Please write your application code 
    }
}

One call does it all

 

Atmel START project code:

	/* PORT setting on PC0 */

	// Set pin direction to output
	PORTC0_set_dir(PORT_DIR_OUT);

	PORTC0_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

	/* PORT setting on PC1 */

	// Set pin direction to output
	PORTC1_set_dir(PORT_DIR_OUT);

	PORTC1_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

	/* PORT setting on PC2 */

	// Set pin direction to output
	PORTC2_set_dir(PORT_DIR_OUT);

	PORTC2_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

	/* PORT setting on PC3 */

	// Set pin direction to output
	PORTC3_set_dir(PORT_DIR_OUT);

	PORTC3_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

	/* PORT setting on PC4 */

	// Set pin direction to output
	PORTC4_set_dir(PORT_DIR_OUT);

	PORTC4_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

	/* PORT setting on PC5 */

	// Set pin direction to output
	PORTC5_set_dir(PORT_DIR_OUT);

	PORTC5_set_level(
	    // <y> Initial level
	    // <id> pad_initial_level
	    // <false"> Low
	    // <true"> High
	    false);

But there are calls for every pin which takes you to a .h file, which then takes you to another .h file

 

 

jgmdesign wrote:
Jacob wrote: Well, the intention with START is to have more compact code. Seriously?  Has START been revamped as the last time I tried it for an AVR8 the bloat was unreal.

 

START seems to generate code thats twice the size to do the same thing with 4X the complexity = BLOAT

 

 

 

One more thing I noticed with start.  When i imported the project back to START to add the PORTC initialisation, I noticed that it does not ask if you want to save it under the same name as what you imported, unless you catch it, it saves it as a new project called MyProject.  Good safety system as it prevents one from not having a 'last known good backup' in case the new additions fail miserably.

 

 

Jim

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

Please Read: Code-of-Conduct

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

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

larryvc wrote:
I do have some feedback on and questions about Atmel Start, is there a dedicated place to post them?

How about, "Atmel Software Framework (ASF) and Atmel Start (ASFv4), all architectures": http://www.avrfreaks.net/forums/atmel-software-framework-asf-and-atmel-start-asfv4-all-architectures

 

Again, stupid forum structure which buries this under "AVR" - so hidden from  the SAM, IoT, and CapSense communities.

 

<rolls-eyes>

 

 

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

Hi Jim,

 

I agree the IO access can be improved, in the same way we improved the general initialization of peripherals, i.e. in as few lines as possible (this is however only accounting for 20-ish bytes). The extra function call... well, I do not see that as a big issue, but it all sums up, so I see your point.

 

When we talk about general code size, you are not comparing apples to apples: the START code configure the IO and peripherals in the state that minimizes the power consumption. (You can argue that this should have been the default setting for the device from device, but it isn't, so we deal with it). The below is 36 bytes.

 

static inline void mcu_init(void)
{
	/* On AVR devices all peripherals are enabled from power on reset, this
	 * disables all peripherals to save power. Driver shall enable
	 * peripheral if used */

	PRR = (1 << PRSPI) | (1 << PRTIM2) | (1 << PRTIM0) | (1 << PRTIM1) | (1 << PRTWI) | (1 << PRUSART0) | (1 << PRADC);

	/* Set all pins to low power mode */
	PORTB_set_port_dir(0xff, PORT_DIR_OFF);
	PORTC_set_port_dir(0x7f, PORT_DIR_OFF);
	PORTD_set_port_dir(0xff, PORT_DIR_OFF);
}

 

Looking through the code I did however realize that we still have code lines that initializes the registers to their default values. That is not necessary... (30 bytes)

static inline int8_t sysctrl_init()
{
	/* Set up system clock prescaler according to configuration */
	protected_write_io((void *)&CLKPR, 1 << CLKPCE, (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0));

	SMCR = (0 << SM2) | (0 << SM1) | (0 << SM0) | // Idle
	       (0 << SE);

	MCUCR = (0 << PUD);

	return 0;
}

That said, I was not able to figure out where the additional 150-ish bytes comes from, but I'll ask the START team to have a look at.

Thanks for pushing us to improve further Jim.

Jacob

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

Hi JC,

 

Sorry, the AVR ISP mkII will not support the ATtiny817, and other devices with the UPDI interface. You will need the Atmel ICE.

Jacob

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

Jacob wrote:
When we talk about general code size, you are not comparing apples to apples:

I know I am not comparing two apples...I am comparing the difference between what START generates, and what a person would generate,  My example was to simply configure the USART in it's simplest form for the Mega328, and nothing else.  START generated a application 302 bytes in size, the AS6_2 project for the exact same AVR was 166 Bytes in size.  I added something even simpler by configuring PORTC0..5 as outputs and START used 20 bytes where I used 6 bytes.  I also compared how easy it would be to find the configuration routines themselves and me not being fluent in where ASF (the START project certainly looks like ASF) puts things, I had to hop through 4 files in order to find the actual configuration routine.  I'll know better next time, maybe.

 

Jacob wrote:
the START code configure the IO and peripherals in the state that minimizes the power consumption.

At power up doesn't the AVR already do that?  Everything is pretty much shut off.

 

/* Set all pins to low power mode */
	PORTB_set_port_dir(0xff, PORT_DIR_OFF);
	PORTC_set_port_dir(0x7f, PORT_DIR_OFF);
	PORTD_set_port_dir(0xff, PORT_DIR_OFF);

This I assume is for the Tiny817,  again I admit I am not very familiar with the 817, but in the AVR,  "PORTB_set_port_dir" to me is DDRB, and 0xff sets the pins as outputs.  Can you clarify?

 

Jim 

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

Please Read: Code-of-Conduct

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

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

awneil wrote:

How about, "Atmel Software Framework (ASF) and Atmel Start (ASFv4), all architectures": http://www.avrfreaks.net/forums/atmel-software-framework-asf-and-atmel-start-asfv4-all-architectures

 

Again, stupid forum structure which buries this under "AVR" - so hidden from  the SAM, IoT, and CapSense communities.

 

Thanks, that works.  Don't get me started discussing the forum or the editor...

 

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

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

Take forum structure and editor issues to the site feedback forum where they belong.wink

Jim

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

Please Read: Code-of-Conduct

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

Last Edited: Sat. Dec 2, 2017 - 03:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Jim,

 

It is ATmega328P code.

The PORT_DIR_OFF set the pins to input and enables the internal pull-ups for the masked pins, so that the pins are not floating. (yes, I know that the default direction is input... an improvement point...). Floating inputs cause the digital input buffer to draw a quite significant amount of current (relative to the sleep current). We experience that many users are not aware of this, and see it as a good way to help users. It could potentially have be made optional, so that expert users can choose to exclude this kind of code. Expert users can always comment out some of these function call and do thing as they want to, or, as you did with the CodeVision config tool, only copy the part of the code from the tool that you find useful.

	case PORT_DIR_OFF:
		DDRB &= ~mask;
		PORTB |= mask;

Btw, you mentioned that you copied the code from the CodeVision configuration tool, which is a really nice tool. That you can do with START as well, if you don't want to go all in with START.

Jacob

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

Jacob wrote:
Expert users can always comment out some of these function call and do thing as they want to,

Providing they wade through 4 or five files to find the function(s) wink

 

Jacob wrote:
Floating inputs cause the digital input buffer to draw a quite significant amount of current (relative to the sleep current). We experience that many users are not aware of this, and see it as a good way to help users

All well and good, but I think you miss my point. 

 

/* Set all pins to low power mode */
	PORTB_set_port_dir(0xff, PORT_DIR_OFF);
	PORTC_set_port_dir(0x7f, PORT_DIR_OFF);
	PORTD_set_port_dir(0xff, PORT_DIR_OFF);

jgmdesign wrote:
in the AVR,  "PORTB_set_port_dir" to me is DDRB, and 0xff sets the pins as outputs.  Can you clarify?

 

Writing a '1' to the DDRx bit makes the corresponding pin an output, writing a '1' to the PORTx bit drives it high.  If that pin is connected to an output of another IC your power savings idea now is not worth anything as two outputs are trying to drive each other.

 

Can you save me the trouble of searching the project for PORTC_set_port_dir(0x7f, PORT_DDR_OFF); is located?  Otherwise I'll go look of course.  Because based on the two code snippets I think there might be an inversion in there.  


 

 

if the MASK for PORTB is 0xff, (All outputs) then the line:

DDRB &= ~mask;

turns all of the pins into inputs as the ~ inverts the 0xff to 0x00, and the next line:

PORTB |= mask;

Turns on the pull up resistors

 

This is somewhat backwards IMO since setting the DDRx to '1' signifies OUTPUT.  The way I read the code, using a '1' signifies INPUT(something Mchip does with PICs)  Is START following 'The other brothers' way of doing things?

 

Jacob wrote:
Btw, you mentioned that you copied the code from the CodeVision configuration tool, which is a really nice tool.

It's an excellent tool, and it was worth the license just for the configuration wizard alone as it's a simple, straightforward GUI configuration utility tha........ I shall stop there LOL!

 

Jacob wrote:
That you can do with START as well, if you don't want to go all in with START.

Based on this little experiment, I would be copy/pasting a lot, and not quite sure I got all the bits(pun intended)  I also wouldn't know where to start on that anyway...not interested at the moment either.

 

Jim

 

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

Please Read: Code-of-Conduct

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

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

I like to use code foundations such as ASF, Atmel Start and others because they provide a path to productivity.  Use them to get your code up and running, then after it works spend the time to fine tune what needs fine tuning.  I do think code foundations get maligned too often and with that in mind I'll continue to provide feedback on Atmel Start to try to make it a better tool for all.

 

Larry

 

EDIT: content change

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

Last Edited: Sat. Dec 2, 2017 - 06:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will say no unless you are a real beginner and don't have a meaning about the structure.

 

This is the same problem I have with others about C and ASM that say that you only save a small amount (a word/clk here and there). The structure of a good (for this job) ASM program will be very different from what it is for a C program.

 

The problem is that the structure of your program when it first work will never get changed even if it's bad, perhaps small changes here and there.

 

So either live with it or don't use it.

(that said you can play with it for a new function and then get an idea of how it works and then implement that specific function in your own project.)

 

 

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

larryvc wrote:
I do think code foundations get maligned too
Only when it's justified. There are several "code libraries" for tiny/mega. Of them all I don't think you'll find too many people ever criticizing Fleury or Stang library code as it's tight and does a great job. Even Arduino is highly regarded if you can get around the gross inefficiency of pinMode() and digitalWrite(). The only libraries that attract criticism are those that are not targetting actual use cases but trying to provide an "all things to all men potentially on any platrform" solution leading to bloat and over complication. From what I've seen, both ASF and Start fall into that category so if I wanted to use library code I'll stick to Fleury or Stang or similar.

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

clawson wrote:

Only when it's justified. 

 

Note that I changed the content of my post to be more user friendly.  To be quiet honest what I wrote before was pretty much the same as your assessment though a bit more negative.

 

Both ASF and Atmel Start are not much different from some of the other vendors' "code libraries", they all come with the do it all "kitchen sink included" bloat.  As Jim noted above, they add layers of obscurification resulting from the inclusion of numerous header files containing the static inlined functions.  I use them to get things going then I yank out the bloat for the finished code.

 

The real issue I find disconcerting is that all the vendors are using a "flavor of the year" approach with these "code libraries" and with the recent assimilations* in the industry that is happening at a quicker pace.  What "code library" does one use for a new project, and how long will that library be supported?  Until they provide some stable time frame as the answer many will continue to avoid using them.

 

* Thinking about the Borg

 

Edit: sentence in wrong paragraph

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

Last Edited: Sat. Dec 2, 2017 - 07:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larryvc wrote:
Both ASF and Atmel Start are not much different from some of the other vendors' "code libraries", ...
There's one who may agree with that

Jay Carlson

The Amazing $1 Microcontroller

Code Generation Tools

https://jaycarlson.net/microcontrollers/#codegen

Microchip's MCC, or its follow-on, may be the future for an initial cut at AVR configuration code.

 

P.S.

larryvc wrote:
... and with the recent assimilations* in the industry that is happening at a quicker pace.
IIRC, may be less M&A due to reduced cash reserves.

An acquisition usually results in identity reduction or loss; a merger is less so (an instance of that could be Linear Technology and Analog Devices)

 

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

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

I've never used START, and been away from ASF for a while.

 

Jacob wrote:
Well, the intention with START is to have more compact code. The code is generated, which means that a lot of the run-time configuration that is used in ASF is not present in START code. 

 

Well, that would certainly be a good thing!

 

ASF has (had?) an awful lot of nasty macro magic obfuscating stuff, and which made debugging (almost) impossible.

IMO, this should never have been given to customers - it might have been useful to Atmel internally, but was a pain to use.

 

And ASF wasted a lot of time looking-up tables to find, say, which physical SERCOM it wanted.

This made the SPI stuff too slow for me - so I just kept the initialisation, and (as Larry says) then re-wrote the actual running stuff to get the performance.

 

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

gchapman wrote:

P.S.

 

larryvc wrote:

... and with the recent assimilations* in the industry that is happening at a quicker pace.

 

IIRC, may be less M&A due to reduced cash reserves.

An acquisition usually results in identity reduction or loss; a merger is less so (an instance of that could be Linear Technology and Analog Devices)

 

I had a feeling that complete sentence was missing some punctuation, had to run off so left it as it was.  What I meant; Because of the assimilation, the vendors are now in the process of creating newer "code libraries" and/or merging IDEs at a more rapid pace.  End result, more work for us to learn how to use them.

 

Totally agree with your viewpoint in the context given.  Thanks for the link, good read.

 

 

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." - Marcus Aurelius               

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

Jacob wrote:
I will keep an eye on this thread

Please take a look at this thread:

 

Loading existing project to Atmel Start and reconfiguring Sercom ports

 

ScottMN wrote:

Go to http://start.atmel.com and click on the "Load Project From File" button.  Browse to your project, select it, and if you are lucky, update your project as needed.

 

Unfortunately it's more likely that START will throw an error trying to load your previous project and you are screwed.  This happens because Atmel has not thought through the process of reloading projects into START.  Atmel rightfully so will update the server code that START is running on.  They likewise update the code generating portions underneath it.  Newly created projects should work fine with each update.  But they often break the ability to reload older projects with each update.  And to make it worse there is no selection available to use an older version of START to match it to the one you used with your project.

 

What to do?  Painfully recreate your project from scratch if you want to add a module to an existing project.  Then back merge the source code changes by hand into your project.  And pray Atmel gives us the ability to select the version of START on their server or better yet releases an offline version of START so you can be assured of its version.

 

Atmel - if you are reading this - you need versioning capabilities on the START server.  What good is the START code generator if two weeks later I can't reload my project and add a module simply because the START server that you control was updated?!?

 

That seems to be an absolutely fundamental flaw in START!

 

surprise

 

I think that renders it all but useless to any significant project!

 

<rolls eyes>

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

Hi Awneil, I have passed on the message to the START team. I agree that versioning is a significant issue that must be resolved.

Jacob

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

Here's another one for you:

 

I wrote:
The trouble I find with most such library documentation - and ASF is no exception - is that it give a close-in view of individual functions, but no overview of how to put it all together into a system.

 

It's like a car user manual which describes the buttons, pedals, and levers individually - but doesn't tell you how to drive.

 

http://www.avrfreaks.net/comment...

 

Which is not helped by:

I wrote:
To be honest, the so-called "documentation" is just the source comments (Doxygen) anyhow

 

http://www.avrfreaks.net/comment...

which does tend to give a close-in view.

 

And, just to show it's not just Atmel: http://www.avrfreaks.net/comment...

 

See also: http://www.avrfreaks.net/comment...

 

 

 

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

awneil wrote:
The trouble I find with most such library documentation - and ASF is no exception - is that it give a close-in view of individual functions, but no overview of how to put it all together into a system.

By coincidence I stumbled on this PDF just the other day: http://ww1.microchip.com/downloa...

 

A new and shiny document from 2017! It seems to give some of the "how to use it" documentation.

 

The amazing thing is that, for what I can see it is not linked to from the Atmel Start page. I mean, what would be more natural?

 

I actually found it from this passage in the online Atmel Start Users Guide (Contents, Getting Started, Documentation Resources) :

The major sources of documentation are Getting Started projects, the Atmel START User Manual, as well as reference manuals for ASF4 and AVR8 Code framework content.

That sentence is published on a web server, and "reference manual for ASF4" refers to a document available on the web. Still it's text only and not a link. Sigh..

 

Now, Googling for "AVR8 Code framework reference manual" gives nothing at all. I can't even recall seeing "AVR8 Code" mentioned as a product ever before. What is it?

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:
I actually found it from this passage in the online Atmel Start Users Guide (Contents, Getting Started, Documentation Resources) :

Microchip

Atmel START User Guide

http://atmel-studio-doc.s3-website-us-east-1.amazonaws.com/webhelp/GUID-4E095027-601A-4343-844F-2034603B4C9C-en-US-1/index.html?GUID-31CAFDCB-DD38-462B-893D-B5A7DC63B24A

via

Microchip

Atmel START

http://start.atmel.com/

Help

which also has

ASF4 API Reference Manual

http://atmel-studio-doc.s3-website-us-east-1.amazonaws.com/webhelp/GUID-2A8AADED-413E-4021-AF0C-D99E61B8160D-en-US-1/index.html?GUID-819376C9-5C19-4F1E-9320-ED29CF2A0627

 

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

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

In case my previous post was misunderstood:

 

  1. In plain text the Atmel Start Users guide tells there is a reference manual for ASF4, but it is told in plain text. This is the Web, so why not have a web link (rather than having the user Google for it, and risk coming up with the wrong or outdated document)?
  2. The formulation also implies that there should be a separate reference manual for something called (approximately) "AVR Code". I have not been able to locate that despite extensive Googling. Where is it? Does it at all exist?

 

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sat. Dec 9, 2017 - 11:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jacob wrote:
I will keep an eye on this thread

Here's another one that needs looking at - the stupid things that are broken on the other communities, but not here:

 

http://www.avrfreaks.net/forum/not-so-dear-atmelmicrochip