ATMEGA4809 Nano Doesn't reset after programming

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

When programming the board, after the download the program doesn't start writing to the PC terminal (PuTTY).  Works fine if power cycled.

 

Interestingly, if run with the debugger, the program steps through the code, but still no output on the terminal.

This topic has a solution.
Last Edited: Wed. Nov 14, 2018 - 11:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried both PuTTY and TeraTerm.  Same result.

 

However, resetting the terminal emulator on the PC also allowed the continuation of the output to appear on the terminal emulator.

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

 

Is anyone using the AtMega4809 Nano Curiosity Nano board?

 

With the attached program I have the problem that the CDC which goes through the nEDBG does not seem to reset properly.

 

When I program the board from AS7.0.1931 I only get the first printf ( which is from the program already running and due to the reset being asserted).

 

Then there is no output.  Program is running as shown by the blinking Led.

 

If I restart the terminal emulator ( PuTTY or Teraterm) the the output commences.

 

#define F_CPU 20000000ul
#define PRESCALE 1
#define F_PER (F_CPU / PRESCALE)
#define BAUD_RATE3 38400ul
#define USART3_BAUD_RATE (F_PER * 4 / BAUD_RATE3)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdlib.h>
#include <util/delay.h>
#include <string.h>
static int uart_putchar(char c, FILE *stream);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_RW);
volatile uint32_t knt;
int main(void)
{
	CPU_CCP = 0XD8;
	CLKCTRL.MCLKCTRLB = 0;   //1
	knt=0;
	while ((CLKCTRL.MCLKSTATUS & 1)){};    //wait for clk change
	stdout = &mystdout;
	//setup LED
	VPORTF.DIR |= PIN5_bm;
	PORTF.OUTTGL = PIN5_bm;
	//setup USART3
	PORTB.PIN1CTRL &= ~PORT_PULLUPEN_bm;  //PB1 no pullup
	VPORTB.OUT |= PIN0_bm;  //P0 out = 1;
	VPORTB.DIR |= PIN0_bm;   //PB0 out
	VPORTB.OUT &= ~PIN0_bm;  //PB0 out = 0;
	knt = USART3_BAUD_RATE;
	USART3.BAUD = USART3_BAUD_RATE;
	USART3.CTRLB = USART_TXEN_bm;	//enable rx & tx;
	sei();
	printf("M4809printfa\r\n");
    while (1) 
    {
		knt = 0;
		for (uint8_t ii = 0;ii <3;ii++)
		{
			for(uint8_t ia = 0;ia < 255;ia++ )
			{
				for(uint8_t ib = 0;ib < 255;ib++ )
				{
					knt++;
				}
			}
		}
		PORTF.OUTTGL = PIN5_bm;
		printf("knt: %lu\r\n",knt);
    }
}

static int uart_putchar(char c, FILE *stream)
{
	while ((USART3.STATUS & USART_DREIF_bm) == 0);
	USART3.TXDATAL = c;
	return 0;
}

this code runs correctly on a ATTiny817 Xplained Mini

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

Looks like your on the Bleading Edge!

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Which firmware version of the nEDBG are you using?

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

nEDBG
Debug host        127.0.0.1
Debug port        51113
Serial number     ATML3094051800001796
Connection        com.atmel.avrdbg.connection.cmsis-dap
Features          1
Firmware Version  1.02
Hardware Version  255

 

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

It might be that when programming the chip the USB connection is lost. Then also the windows driver looses its channel, but as it seems the pull-up stays active the thing just goes unresponsive. I know teraterm will not always detect that. Had a few problems with that in the past with ARM controllers. When I reprogram them I need to first disconnect the terminal program. flash the chip and then I can reconnect the terminal program. forgetting to disconnect the terminal program might indeed look like nothing is happening after the restart. Also I have had that I needed to shutdown the terminal program and actually first disconnect the processor and then reconnect before things would start working again. 

 

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

My other boards work normally.  ATtiny817 Xplained Mini, ATtiny105 mini, ATmega328PB Xplained Mini.

 

Same behavior using PuTTY, TeraTerm, and AS Data Visulizer.

 

I have changed USB ports, and changed to a new USB cable.

 

The LED keeps blinking while there is no output to the PC.

 

The Debugger functions work normally, runs the code just fine, can see values going into USART3.TXDATAL. But no ouput until I reset the terminal emulator.

 

Note: That the ATmega4809 Curiosity Nano board uses a SamD21 for the nEDBG.

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

Ah-ha.    I had wondered whether it used ATmega32U4 like the XMINI or UC32 like the EDBG boards. 

 

Serial Terminals tend to use RTS, DTR or None.    Just experiment.

 

David.

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

I tried using all settings for DTR,None, on all 3 terminal emulators and RTS on the Data Visualizer also.

 

Doesn't seem to make much difference on PuTTY or TeraTerm, requires DTR on the Data Visualizer then still stops displaying until the terminal emulator is restarted.

 

I opened a support case with Microchip # 00351478 .

 

The Microchip engineers saw no problems on an ATmega4809 Xplained Pro which uses an AVR32 for nEDBG.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

nEDBG firmware version 1.5 was released with MPLABX 5.10 recently.  You can dig it out of a jar from an install, or download it directly here:

nedbg_fw-1.5.322.zip

Either way, do the upgrade using: atfw.exe -t nedbg -a <zipfile>

 

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

The upgrade has fixed the problem - Thanks

 

nEDBG
Debug host    127.0.0.1
Debug port    52091
Serial number    ATML3094051800001796
Connection    com.atmel.avrdbg.connection.cmsis-dap
Features    1
Firmware Version    1.05
Hardware Version    255

 

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

Good to hear!

The FW is listed under "documents" on the kit's page:

https://www.microchip.com/Develo...