Programming Hardware

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

Hi, I done a bit of programming on Atmel ATMega chips over 10 years ago and now have an application where I would like to try and use them again.

Can I ask has much changed? From memory I was using an STK500 and Atmel studio software (little ladybird..?)

Should I be looking at the same hardware and software?

If I can get this sorted I am pretty sure I can get myself started again.

Thanks

JT

Last Edited: Mon. Mar 15, 2021 - 12:00 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino boards are probably the simplest and cheapest entry. Uno is a mega328 and a Mega is a mega2560. These have built in serial bootloaders, so no need for a isp device. There’s plenty of clone boards that can be got for a couple of $$$.

There’s microchip studio, Arduino and the likes of platformio for writing/compiling the code.

Last Edited: Sun. Mar 14, 2021 - 10:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

justint wrote:
Can I ask has much changed?
Yes and no (megaAVR follow-on [AVRxt architecture], not much has EOL'd even after the acquisition of Atmel by Microchip Technology)

justint wrote:
From memory I was using an STK500 and Atmel studio software (little ladybird..?)
Likely AVR Studio; STK500 still exists though some of the STK500 plug-in boards have EOL'd.

justint wrote:
Should I be looking at the same hardware and software?
Depends on the AVR.

AVR Studio 4 -> Microchip Studio 7

STK500 -> STK600, Microchip Curiosity Nano, etc

 


Migration from the megaAVR® to AVR® Dx Microcontroller Families

Instruction Set Summary | AVR® Instruction Set Manual

 

STK500

 

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

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

I still use my STK500 but Kartman is right, Arduino is probably the way to go these days.

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

Glad to see you are still here Cliff

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

So I actually have an Arduino Uno SMD edition laying around.
I see 2 Atmega chips on there, can i use Atmel studio with this as i used to and use either of the chips to test inputs and outputs?
I see a few examples of the Arduino being used like an STK500, can i do that with this to a seperate chip via MISO, MOSI etc...?

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

justint wrote:
Should I be looking at the same hardware ...
How much data space is required?

(mega1284 are popular, AVR128Dx is the follow-on, both have 16KB local RAM for data)

justint wrote:
... and software?
Do you like the Microsoft Visual Studio look-and-feel?

(AVR IDE are, now, nearly numerous)

 

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

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

Sorry for hardware I meant programming hardware.

My application is not very resource heavy and is really using an input to switch an output but I would like to play with how long the output stays on for and maybe use an analogue input and comparator instead of digital input.

I would say a Tiny would even do the job but I would like to just have a play and get a feel for my options.

It would be nice if i can use this Arduino board to test and also to program as i used to with SLK500.

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

justint wrote:
... can i use Atmel studio with this as i used to ...
Somewhat (AVRDUDE as the loader to an Arduino UNO bootloader)

justint wrote:
... and use either of the chips to test inputs and outputs?
The USB megaAVR provides a USB CDC bridge to mega328P UART (bootloader, application)

justint wrote:
... can i do that with this to a seperate chip via MISO, MOSI etc...?
Yes; instead of a mega328P in PDIP-28, consider AVR128Dx in PDIP-28 with a debugger (AVR ISP replaced with AVR UPDI)

 


UNO-TH_Rev3e.sch (Arduino UNO through-hole schematic)

 

Arduino to Atmel Studio 7 external programmers, ISP and serial programming | AVR Freaks

 

ATmega328P - 8-bit Microcontrollers

AVR128DA28 - 8-bit Microcontrollers

AVR128DB28 - 8-bit Microcontrollers

 

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

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

I meant programming hardware.

Recent changes  Programmers (and also chips) with high voltage requirements have mostly disappeared.  Some of the low-pin-count chips still have it so that they can use the programming/reset pin as an IO, but even those tend to be neglected in favor of chips with more pins in smaller packages (why use a DIP8 chip when you can fit far more functionality in less PCB space by using a QFN32?)

 

Microchip has new lines of "evaluation boards" (Xplained Mini, Curiosity Nano) that include debugger support and are very cheap.

 

Arduinos and clones are wonderful development platforms, and a simplified IDE.  You lose on-chip debugging, but gain a solid infrastructure that lets you do internal SW debugging (ie "print" statements) instead.  That seems to be sufficient, usually (a topic of much debate.)  Very cheap "Arduino Clones" ship from China and a pretty good platforms containing the basic HW environment, often for cheaper than you could build yourself.

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

justint wrote:
... and maybe use an analogue input and comparator instead of digital input.

I would say a Tiny would even do the job but I would like to just have a play and get a feel for my options.

tinyAVR also have follow-on (tinyAVR 0-series, 1-series, 2-series, Microchip Curiosity Nano); tinyAVR 2-series is the most recent.

 

ATtiny417 / ATtiny814 / ATtiny816 / ATtiny817 | AVR Freaks

ATTINY1627/26/25/24 availability | AVR Freaks

 

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

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

westfw wrote:
... that lets you do internal SW debugging (ie "print" statements) instead.
PlatformIO has an AVR GDB stub.

westfw wrote:
... (a topic of much debate.)
Concur.

 


avr-stub — PlatformIO 5.1.1a3 documentation

 

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

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

Oh, right.  Two more "new trends in hardware":

  1. Two interrupt priority levels.
  2. lack of external high-frequency crystal support.  (but, more accurate internal clock sources.)

 

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

Clock Sources | Migration from the megaAVR® to AVR® Dx Microcontroller Families

[last paragraph]

Not all AVR Dx devices provide the option for a High-Frequency crystal oscillator (XOSCHF), ...

 

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

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

justint wrote:
Glad to see you are still here Cliff
cheeky
justint wrote:
I see 2 Atmega chips on there, can i use Atmel studio with this as i used to and use either of the chips to test inputs and outputs?
I see a few examples of the Arduino being used like an STK500, can i do that with this to a seperate chip via MISO, MOSI etc...?
The Arduino is basically: an AVR, a clock circuit, a power supply, a USB-UART bridge. If you see two chips on the board one is the main AVR CPU and one will be acting as the USB-UART bridge. 

 

The reason the USB-UART bridge is there is not only to make it easy for your code to "print" stuff and have it come out on the PC but the fact s that all Arduinos contain a bootloader and the usual way of programming them is not with ISP/JTAG/debugWire/etc but simply for a program on the PC end to have a dialog with the bootloader in the AVR (via the bridge) and send the code into it that way. The program on the PC end usually used is avrdude.exe. If you are actually using the whole Arduino infrastructure (IDE, library code etc) then when you "Upload" the GUI program simply launches avrdude in the background.

 

If you want to use the Arduino but not the IDE/libraries then you can build in some other environment (AS7/MCS7, MPLABX, Codevision, etc) but when you are done building you would then invoke avrdude to have the same kind of conversation with the bootloader to deliver the code as it might have done inside Arduino. There are loads of internet tutorials about this and many show you how to add this step as an additional command/menu/button in an IDE such as MCS7 so it "feels" like everything is happening inside the IDE anyway.

 

To a large extent this is part of the appeal of Arduino. All those days of fiddling about with MOSI/MISO and 6/10 way ISP cables and STK500's are generally gone. The one time you might use the STK500 is to setup a "raw" chip by setting fuses and putting an Arduino bootloader into it so you can then put down a design and just talk to it from then on like it was an Arduino. As long as you don't do ISP again you can't really "lose" the bootloader so the chip should remain programmable from then on.

 

(of course a bootloader does need a USB-UART bridge in the picture - when it's an actual Arduino board this is kind of guaranteed as part of the design - but if it's a chip on a breadboard you either need to put down a USB-UART alongside or, more likely, you get a $2 USB-TTL cable from eBay).

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

Thanks so much for this, I am hoping to get stuck in this week.
If I wanted to be able to program a chip when on a PCB what does that interface physically look like? Pins?

Is it possible to debug an installed chip live?

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

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

Last Edited: Mon. Mar 15, 2021 - 10:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:
Dependent on the debugger or programmer

 

 

justint wrote:

Is it possible to debug an installed chip live?

Yes

 

Well, within limits. You can't see things change as the program is executing. So, in that sense, NO. But, you can run it and do a "break" or set a breakpoint that it runs into. Once the break happens, it stops but is still "living". You can check register states, values of variables, and such, then continue from that point. But not "live while running".

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

You can't see things change as the program is executing

The data sheets imply that the UPDI interface can access memory, PC, SP, and STATUS without stopping the CPU...

(But I can't find just how that's done.  Or how to set registers, breakpoints, and other stuff, either.  While the documentation of UPDI is a lot better than DebugWire ever was, it doesn't seem complete.  (The implication is that UPDI interacts with the OCD (on-chip debug) controller.  But I don't see the OCD module documented at all.  Sigh.))

 

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

EDBG

westfw wrote:
But I don't see the OCD module documented at all.
There was a bit more on ASI in the tiny817 first data sheet.

OCD is value-added; likely difficult to make OCD small (die area, so proprietary)

 


https://github.com/mraardvark/pyedbglib/blob/master/pyedbglib/protocols/avr8protocol.py#L412

 

debugWIRE via USB UART | AVR Freaks

 

Block Diagram | UPDI | tinyAVR® 1-series

 

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

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

OK, so I have downloaded Microchip studio. I am finding it hard to grasp the next step, firstly where can I download avrdude?

 

- On the Arduino Uno is this purely for debugging i.e. a chip on a board that has easily accessible pins to connect things to? Can I use it for programming other chips not on that board? What does that look like?

 

- I don't see Arduino or AVR dude in the list of supported tools in Studio where I would have selected STK500 in the past...

 

- I see what you say Clawson about 1 chip being the  USB-UART bridge, is this out of the box? I am not sure who had the Uno before me or how it was left, could there be the possibility that I need to reinstall the USB-UART bridge?

 

Ta

 

JT

Last Edited: Mon. Mar 22, 2021 - 08:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

justint wrote:
where can I download avrdude?
Multiple places :

  • edit : GNU for AVRDUDE 6.3
  • Arduino IDE 1
  • Windows packages
  • MSYS2 packages
  • Linux packages via WSL 2

though the AVRDUDE minor version will vary (been quite sometime since the release of AVRDUDE 6.3)

justint wrote:
- I don't see Arduino or AVR dude in the list of supported tools in Studio where I would have selected STK500 in the past...
AVRDUDE is accessed via external tools.

 


Software | Arduino

Chocolatey Software | AVR Downloader/UploaDEr 6.3

Package: mingw-w64-x86_64-avrdude - MSYS2 Packages

Package: mingw-w64-i686-avrdude - MSYS2 Packages

Debian Package Tracker - avrdude

Install Windows Subsystem for Linux (WSL) on Windows 10 | Microsoft Docs

 

avrdude returns 53 | AVR Freaks (on Windows 10)

 

Arduino to Atmel Studio 7 external programmers, ISP and serial programming | AVR Freaks

 

edit :

Index of /releases/avrdude/ ('avrdude-6.3-mingw32.zip')

 

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

Last Edited: Mon. Mar 22, 2021 - 09:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

justint wrote:
- I see what you say Clawson about 1 chip being the  USB-UART bridge, is this out of the box? I am not sure who had the Uno before me or how it was left, could there be the possibility that I need to reinstall the USB-UART bridge?
If it's an UNO it presumably looks a lot like this?:

On the whole the "other" multi-pin device (likely SMT) that isn't the actual AVR and that is often positioned between the USB connector and the AVR is the USB-UART bridging chip. It may be something like an FTDI FT232 or Prolific PL2302, CH340G, MCP2200, Silabs CP210x etc etc. On the PC facing USB side it just connects to your PC USB port. On the AVR facing side it simply has TX and RX pins that connect to the AVR's UART TXD/RXD pins.

 

On the PC you run avrdude.exe (which for my money is easiest obtained by installing the Arduino IDE - which you are kind of bound to do if you own an Arduino Uno anyway). Studio 7 does not know ANYTHING about avrdude. However what it does have is a way to add commands to it that can appear as either a menu entry or a toolbar button (also triggered by some function key combination) . You use this mechanism to add knowledge of avrdude to Studio 7. When you have built code you then select the menu entry or button and that triggers avrdude.exe to run so it can have a chat (via USB and the bridge chip) with the bootloader in the AVR on your Arduino.

 

You use "External Tools" in Studio 7:

I haven't completed the process here as all I've done so far is point it to the location in my Arduino installation where avrdude.exe is located. The command line will need some more arguments to tell it to program an arduino (-c arduino), the COM port to use (-P), which AVR is at the heart of the Arduino (-p atmega???).

 

There are tons of internet tutorials about how to set this up.

 

When you have set up an external command like this you can use Tools-Customize :

 

which allows you to achieve things like:

also:

So now, after building the code I can either pick a menu entry or click a toolbar button and have it invoke avrdude to send the .HEX file that has been built to the Arduino bootloader.

 

This post just gives you a taste of what is possible - google for more detailed tutorials of all the steps involved. Passing the right things on the command line of avrdude is kind of key to the whole process!

 

PS Google says: http://web.engr.oregonstate.edu/... - I only skimmed it but most looks right.

Last Edited: Tue. Mar 23, 2021 - 10:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok Clawson, think I am making a bit of progress.

 

It looks like when I activate the command the Rx and Tx lights are flashing on the Arduino.

 

I don't have anything physical to connect to the Arduino yet to check and see outputs doing things but have ordered a few bits that should be here on Monday.

 

Out of interest I do have 2 AVRs on the Arduino, the one closest to the USB port is a Mega16U2 and the furthest from the USB is Mega328P (as Kartman mentioned earlier in the thread). The 16U2 must be preloaded as a USB to UART bridge?

 

Anyway progress made, hopefully next week Ill be a few steps further.

 

Thanks

 

JT

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

Exactly, 16U2 will just act as a CDC-ACM to UART Bridge.

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

I got a few bits and pieces, bread board, resistors, LEDs and am trying to get a light to switch on.

I have connected my meter to some the pins attached to portB on the arduino (8-13) and made a small simple program:

 

.INCLUDE "M328PDEF.INC"
.ORG 0000

start:
    ldi        r16,    0b11111111
    out        ddrb,    r16                ;set portb pins as outputs

    ldi        r17,    0b11111111
    out        portb,    r17                ;make portb pins high

    rjmp start
 

The code seems to be downloading as far as the bridge as the Rx/Tx lights flash but no voltage out from the port pins.

 

Could it be that the bridge is talking but the Mega is not responding? 

 

Thanks

 

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

Welcome (back) to AVRFreaks!

 

Your moving fast, but the quickest way to test your Uno is to go download the Arduino IDE and run the "blinky" example sketch (they call them sketches in Ardunio land, but they are really C++ or C programs).

This will prove your h/w works and opens a whole new world of sketches you can play with to learn new things.   Have fun!

Jim

PS: here is the schematic for your uno, it will help you identify which pins connect to the outer rows of pin connectors!

most of the portB pins are found on arduino pins 8 through 13

Attachment(s): 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Tue. Mar 30, 2021 - 08:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, blinky works. I used the following in the arduino ide:

 

void setup() {
 pinMode(LED_BUILTIN, OUTPUT);

}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

}

 

This turns on off the little on board LED so i suppose I can concentrate on that instead of external stuff for a while.

 

Again, the program seems to be going down but the LED stays on no matter what changes I make to portb in its entirety (0b00000000 or 0b11111111).

 

In the external tools set up I get that the Command is directed at an avr dude location but for the Arguments part is there something specific here that needs to be right for the mega to open its door wen Im knocking or is the fact that the Rx/Tx lights are flashing enough to prove that the Arguments are set up correctly?

 

Attachment(s): 

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

justint wrote:
... but for the Arguments part is there something specific here that needs to be right for the mega to open its door wen Im knocking or is the fact that the Rx/Tx lights are flashing enough to prove that the Arguments are set up correctly?
typo for COM?

Arduino to Atmel Studio 7 external programmers, ISP and serial programming | AVR Freaks

 

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

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

Success! I don't fully understand everything in the Argument field but I took some that I found on line and tweaked to suit my own setup:

 

-CC:\arduino\hardware\tools\avr/etc/avrdude.conf -v -v -v -patmega328p -carduino -Pcom4 -b115200 -U flash:w:"$(TargetDir)$(TargetName).hex":i -v -v

 

My simple code now goes down and I can change the status of the Uno on board LED.

 

So now I can develop and debug using the Uno. The next step is understanding the transfer to a chip in actual installation.

 

I used to install the 6 ISP pins on the final installation, can I now include Rx/Tx pins and loop over from the Uno to these?

 

 

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

I'm over month late to this conversation, but here's my 2 cents.

 

If you are getting back into AVR and want to play with the newer AVR DA and DB parts, I suggest dropping the $100 on a Atmel-ICE basic kit and downloading Atmel/Microchip Studio 7. Both the ICE and Studio 7 support the DA/DB family UPDI programming and debug with the proper service pack installed. The only issue I have come across is a CPU bug that prevents the memory controller (thus UPDI) from reading flash mapped into the data space. It's documented in the AVR DA chip errata so no way around that one. Not a big deal for most debugging though.

 

I'm still wanting to move my development environment to Linux. But, I'm not impressed with the UPDI/AVR DA support in Linux capable tools. Seems the best you can do right now is programming the part with jtag2updi or pyupdi. Each has it's quirks. I haven't seen any debugging support yet. If Avarice supported the AVR DA/DB parts, I'd be moving to Linux today.

 

For now, Studio 7 w/Atmel ICE is still a very capable very professional level development environment. I'm just sick of Windows.

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

RacerXR wrote:
I haven't seen any debugging support yet.
pyedbglib

RacerXR wrote:
If Avarice supported the AVR DA/DB parts, ...
The AVR GDB proxy in atbackend.exe completed; not quite Windows-less though may be good enough.

RacerXR wrote:
I'm just sick of Windows.
The ones at Microsoft successfully competed against netbooks by a low price OEM Windows XP; round two as Microsoft and Google compete (Windows 10X vs Chrome OS)

 


Linux systems | GitHub - mraardvark/pyedbglib: Python Interface to Microchip EDBG-based Bug Removal Units

https://github.com/microchip-pic-avr-tools/pyedbglib/blob/main/pyedbglib/protocols/avr8protocol.py#L383

 

Microchip Studio 7.0.2542 | AVR Freaks

How do you debug avr code on non-windows platforms (Free Pascal)

Come Join Us (MPLAB Now Supports AVRs) | Page 8 | AVR Freaks

 

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