AVR to ARM threads

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

Can some nice person point me to threads discussing changing from AVR to ARM.  I am thinking it might be time for me to learn how to use an ARM, and I always have a hard time searching this site for threads.  This topic has been discussed to death, I'm sure, and I am looking for advice on choosing an ARM to start with.   I would like to stick with Atmel Studio, so that narrows it down some.

 

Thanks in advance.

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

Best bet is to use Google and add "site:avrfreaks.net" to the search. There have been literally hundreds of such threads so I think it'd be very difficult to pick out any particularly good ones.

Typically 3.3V and no EEPROM are what comes out of them but from then on it is win win

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

OK, thanks Cliff. 

 

How are the "kids" doing?  Any new pictures?

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

I suggest that you start with regular Arduino code for a Due or Zero.    And buy the Arduino board.    The Zero comes with its own EDBG chip.    The Due can be debugged with an ATMEL-ICE.     You don't need the debugger.    Due and Zero have a Serial-USB link.

 

Or you select an MBED board from NXP, ST, ... and use MBED code.

 

Once you have got projects up and running with Arduino or MBED,   you can think about baremetal on the ARM chip if that is what you want.

You will find this more productive than starting from scratch with the ARM.

 

David.

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

You could always just go here:

 

https://community.atmel.com/atme...

 

If you are the Freaks site click 'communities' at the top of the page and click on the SMART icon next to the AVRfreals icon.  You will find many of the gurus and contributors  there are gurus and contributors here so making friends will be easy smiley

 

I have started a thread or two in the Smart forum a couple of times on this subject, but I always seem to fizzle out.  I need to put my focus cap and glasses on and get into ARM as well.

 

MAybe you will have a better drive than I.

 

Cheers,

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

 

"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 user

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

Thanks Jim.  I looked for an ARM forum and didn't see one under FORUMS, which surprised me.

 

David, I really don't want to code in Arduino land, although I guess I can write C code there just as easily as in Visual Studio.  I don't want to do anything that is Arduino specific if I can help it.  I see the DUE and Zero both have 6 pin headers labeled SPI.  Can I download code to flash the way I always do using an ICE?  That way I can stay with Atmel Studio and do things the way I always do.  I think starting with a DUE is a really good idea

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

david.prentice wrote:
Or you select an MBED board from NXP, ST, ... and use MBED code. Once you have got projects up and running with Arduino or MBED, you can think about baremetal on the ARM chip if that is what you want. You will find this more productive than starting from scratch with the ARM.

 

 

I think I may explore this option myself!

 

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

 

"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 user

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

I see the 6 pin SPI header is not for programming a SAMx.  I guess I use the 10 pin JTAG for programming and debugging with the ICE.

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

The SPI header is for an external SPI bus e.g. a Shield with SD card or SPI TFT.    This is common to Uno, Leonardo, Mega, Due, Zero, ...

 

The 10-pin JTAG on a Due works with ATMEL-ICE debugging/programming.   But you normally use the Bootloader for uploading code.

 

David.

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

David, I have used the SPI header on the Nano and Uno for programming from Atmel Studio too.

 

Using the Bootloader for uploading code means I need to use the Arduino IDE, doesn't it?  I want to only use Atmel Studio and my ICE.

 

I just ordered a Chinese Due for $13.  That should get me started.

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

You only use MOSI, MISO, SCK, VCC, GND from the 3x2 header for the external SPI bus.    You use a GPIO pin for /CS on your Slaves

The mega328, mega2560 can use the 3x2 header for ICSP.    They use the same SPI bus but the RESET pin functions as /CS for the AVR programming.

 

In other words.    When you assert /RESET on an AVR,  the AVR responds as an SPI Slave.    Your AVRISP-2 sends a magic "Enter Programming State" command on the SPI bus.    This is the "Connect" on avrdude.

 

You do not need Arduino IDE to use the Bootloader on a Nano, Uno, ...

I use the bootloader from AS7

 

If you are using an ATMEL-ICE,  the bootloader gets destroyed anyway (on an AVR).   You can restore it at any time.  (with your ATMEL-ICE)

 

In fact,   I destroy my Zero bootloader intentionally.    And deliberately upload applications to start at 0.

The Due Bootloader is in a different place to a Zero.

 

David.

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

DAvid,

I just looked at the MBED site and I see Atmels ARM XPLAIN boards there alongside the LPC and others.  According to MBED I need to use Studio in order to program the D21 XPLAIN.

 

I also saw this one which I am interested in:

 

https://developer.mbed.org/platf...

 

 

I already have a few D21 XPLAINS lying around so cost is $0.00, but if the other unit would be a better fit to get me going I would appreciate your insight.

 

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

 

"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 user

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

I have the Arduino adapter that plugs into an XPRO. But you can buy a complete FRDM or NUCLEO board for less money than the Atmel adapter.
From a prototyping point of view, the NUCLEO boards are infinitely more convenient. All pins are accessible, even with an Arduino shield plugged in. You can migrate from M0, M3, M4 painlessly. ST has pretty good support.
.
The Arduino Due, Zero are probably the easiest to learn on. Especially if you are familiar with Arduino Uno, Mega.
FRDM and NUCLEO boards come with onboard debugger. So you can have full hardware control. And use the regular ARM IDEs that are better "developed" than AS7.
.
David.

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

Great information David.

 

I looked at some of the demonstrations last night and reviewed some of the code examples and I get the feeling that MBED is similar to Arduino in the respect that you need to use an MBED.h file, and an MBED_OS file in the code.  The MBED.h reminds me of WIRE.h, but for the purpose of learning I can live with that

 

The other item that I will have to live with I guess is that it appears that this is all cloud based so I cannot work on this while I am on a train back from NYC for example.  Which is disappointing considering I spend a considerable amount of time on the train.

 

Baby steps I guess.....Baby steps

 

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

 

"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 user

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

You can export an MBED project to Keil and several other IDEs.   In which case you can build locally.

Does your train not give you WiFi ?

 

Arduino builds locally.

I am currently using a NUCLEO-F103 board with Stm32duino.    However,  stm32duino is not as robust as the official Arduino platforms.

The same hardware can use MBED.

And I normally use Rowley CrossWorks IDE.

ST provide SW4STM32 IDE but it is probably more flaky than AS7

Keil is robust and easy to use.    However the code size is restricted.   Fine for most simple projects.

 

David.

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

No the train does not provide WiFi.....we are fortunate to get close to on time performance most of the time.

Thanks for the update

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

 

"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 user

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

When dealing whith ARM lack of choise is not a problem :)

I found the info available quite overwhelming actually.

Mbed supports probably more than 100 different boards...

 

For me, compatibility with Atmel was not a must. In fact, I wanted something else than atmel.

I also did not want to invest much money as it's just a hobby for me.

So I bought some STM32F103C8T6 boards and dome ST-Links from Ali for less than the postage stamps.

Downloaded CMSIS from ST, and the compiler too probably, or I used the one with my package manager.

paul@dualcore ~ $ apt search none-eabi
i A binutils-arm-none-eabi          - GNU assembler, linker and binary utilities
p   binutils-arm-none-eabi:i386     - GNU assembler, linker and binary utilities
i   gcc-arm-none-eabi               - GCC cross compiler for ARM Cortex-A/R/M pr
p   gcc-arm-none-eabi:i386          - GCC cross compiler for ARM Cortex-A/R/M pr
p   gdb-arm-none-eabi               - GNU debugger for ARM Cortex-A/R/M processo
p   gdb-arm-none-eabi:i386          - GNU debugger for ARM Cortex-A/R/M processo
p   libnewlib-arm-none-eabi         - C library and math library compiled for ba

CMSIS does not do "bare bones" well but I got it going in a reasonable amount of time with the excellent tutorial from pandafruits. (which handles link scripts, programming, etc).

http://pandafruits.com/stm32_pri...

I also had a quick peek at the debugger and it seemd to work then (even though apt now says it's not installed).

 

Just for completeness. CooCox is another popular ide for ARM development.

 

Just as me, all the other nice guys seem to share some personal experiences. If you want better advice suited to you needs tell us more about what you have in mind, such as budget, ease of setup/use, flexibility.

 

P.S. I also don't like the arduino thing much, but I'm afraid we're going to get stuck on that horrible pinout for a long time to come.

(Just look at the board JGM seems to like).

 

About board layout...

About half a year ago I made a pcb design (untested yet) in KiCad for the STM32F103C8T6 with 1x RJ45 (RS485 & power) and an IDC connector to break out all other signals.

Interested?

Attachment(s): 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Sat. Dec 3, 2016 - 04:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your help, David.  As I said before, you are a real gentleman.

 

I agree with Paul about the Arduino thing.  I have the pinout for the ATmega328 boards on my wall, so when I write code I know which port and pin corresponds to the Arduino pin numbers.  Pain in the butt.  I guess going away from ports and pins is easier for new users, but hides the underlying structure.  I am just a hobbyist and have used a lot of bare ATmega328s in my projects.  It is fast enough and has enough flash for most of my needs, and is cheap.  I have found myself using Chinese Nano's recently, as they don't cost much more than a bare ATmega328, and I don't have to solder in a crystal, FTDI chip, ICSP headers, reset button, etc...  The pinout is annoying, but the small package is just too convenient.  I guess I am just stuck with it.

 

It will be interesting to see what writing code for a 32 bit Cortex M3 is like.  I will be starting out with a Due, AS6.2, and an ICE.  That should be enough for me to get an LED blinking. 

 

I see that chip has no internal EEPROM.  Interesting.

 

Thanks Ya'all 

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

The pin numbering of arduino's is even much more annoying than the connector layout.

"arduino" stuff usually initialises peripheral stuff in the constructor and the pin numbers are passed as parameters.

This is just too much for the optimiser :)

 

MarkThomas wrote:
It will be interesting to see what writing code for a 32 bit Cortex M3 is like

Some pointers:

Oscillator options have to be handled in software before any decent work can be done.

I/O pins have a "set / Reset" register to change multiple pins in the same clockcycle.

A uart has about 20+ different 32 bit registers to intialise it.

Configurable DMA and lots of other goodies to keep you busy for years to come.

Datasheets are >1000 pages.

 

I'm not sure (yet) about the EEPROM, but I believe ARM has a flat memory model and the FLASH is writable so there is no need for EEPROM.

It's also common for ARM's to have a built in clock (a bit like those I2C chips). Including a bunch of freely usable scratch registers with battery backup.

 

Even if you don't want to use an STM32... have a look at the tutorial from pandafruits. It's just a few pages and it will give you a decent overview on starting with (low level) embedded ARM.

https://duckduckgo.com/html?q=pa...

http://pandafruits.com/stm32_pri...

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Sat. Dec 3, 2016 - 09:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paul, Thanks so much for the pointers.  I really appreciate it. 

 

This project is going to be a little more intense than using an AVR.  I spent 40 years as a high level algorithm developer in FORTRAN, C, and C++.  I never really understood what was going on underneath that, which makes things difficult for me learning microcontrollers, where an understanding of what is happening in hardware is pretty much mandatory for doing advanced things.  I have done a lot of struggling to get the ATmega328 to do what I want, but have eventually been successful doing things like SPI, UART, I2C, and such.  Twenty 32bit registers to initialize UART is a little daunting.  I use UART a lot to talk to my laptop using an FTDI chip and the terminal emulator PuTTY to tell the microcontroller what I want it to do and for setting parameters. 

 

When I go to create a new project in AS6.2 for the SAM3X8E it shows no EEPROM.  When I look at the data sheet (1400+ pages) you are right about the flash acting as EEPROM.  The data sheet says this:

 

The Fast Flash Programming Interface provides solutions for high-volume programming using a standard gang

programmer. The parallel interface is fully handshaked and the device is considered to be a standard EEPROM.

 

Otherwise, the only mention of EEPROMs are for external devices.

 

I suspect this site will be getting a lot of newbie questions from me as I try to create a simple program.  I prefer writing in C to C++, as it is my native language.  I was over 50 years old when I started learning C++, and spent a lot of time being confused.  The idea of objects only started to make sense about 5 years after I retired.

 

Thanks again for your pointers.  I will for sure check them out when I get going.  I am currently working on a hardware project without a microcontroller using 555s and 74LSxx logic chips, and an IR detector.  It is kind of fun.  I am setting up an array of LEDs to illuminate my cat's litterbox when he walks through the door, so he can see when he is pooping and I can see when I have to scoop his box.  It is sort of a silly project, but as I said, kind of fun.

 

Thanks again for the pointers.  I will take whatever you can give me.  Twenty registers for UART is making me worry a little.  I guess that will be my second project after getting an LED to blink.

 

Mark 

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

I'm sorry I frightend you about the uart. I was confused a bit myself so I did a double check.

I count 7 registers (For STM32F103C8T6) and none of them use more than half the bits in them.

Most bits also look familiar and you probably would not be needing IrDa, LIN, Smartcard mode or DMA in the beginning.

So if you ignore those it's pretty similar to an AVR uart.

 

Your comment about Flash / EEPROM seems to be that your chip presents itself to an external programmer as an eeprom chip.

Don't search for "EEPROM" in the data sheet (there is none!) Search for "FLASH" and the ways it can be used.

In my STM32 I saw that FLASH can be an endpoint for the DMA controller to write data to.

I also saw flash related interrupt vectors. Both suggest that flash is accessable by the user.

 

About TTL:

When I was young I spend some hours desoldering hundredths of TTL chips. Most LS some F or without suffix.

They are still collecting dust.

Shipping to San Francisco would be prohibitively expensive (from Europe) I guess...

 

PS:

Maybe your cat likes to shit in the dark.

Attachment(s): 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

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

A friend gave me a big jar of TTL chips of all kinds when I got started.  Some are old, like the 7404 with no LS or HCT or anything.  Those chips go for a fair price on eBay and other places as they are so old and getting hard to get.  I have hundreds of them too. 

 

A trick I learned desoldering chips from a board is instead of using one or two soldering irons is to use a little butane torch, that tends to melt the solder on all the pins so the chip is easy to remove, but doesn't even get the chip hot.  It is a good tip, although it does tend to burn the board, so I do it with the door open so it doesn't stink up the place.

 

What is the difference between an STM and SAM ARM?  Am I choosing a good one to learn on with the SAM3X8E?

 

He may like to shit in the dark, but I don't like to scoop the box in the dark, and it is in a dark corner of the garage, so it is mostly for me.

Last Edited: Sat. Dec 3, 2016 - 11:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paul,

If your comment about shipping to San Francisco is because you would sent old TTL to me, it would probably be pretty cheap just sending it regular parcel post.  It would take forever to get here, but what's the rush.  I would put money for postage in your PayPal account if that is what you were thinking.  I never have enough old components.  I am sort of a pack rat for stuff like that.  You should see the capacitor collection I have.  My friend/mentor who helped me get started in electronics gave me three big boxes of random components of all kinds.  It took me months to sort through it all and put it in bags and sorted into storage containers.  I have pretty much everything a beginner would need for just about any project.  We have a play date scheduled for the new year and he has some more boxes of high frequency components so I can start getting into the radio world.  My wife said, "Oh great.  He is cleaning out his garage and is giving you all the junk he doesn't want."  My take on it is, one man's junk is another mans treasure.

 

I am interested in analog electronics.  I was trained in physics, and Heisenberg had something to say about the analog world.  I get the front end of a circuit working, and when I hook up the load everything changes.  Analog electronics involves a lot of magic.  So different from the digital world.  I think the biggest mistake I ever made was to study theoretical physics in graduate school instead of experimental physics.  The skill I walked away with was knowing how to write code, which served me well, but if I had gone the experimental route I would know how to do so many things electronics, which I am trying to learn now as an older man.  I guess it keeps me out of the bars.

 

Thanks for your help,

mark 

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

I would've thought there was no shortage of old stuff in the Bay area. Places like Halted and so on.

I've found a hot air gun works a treat for removing components from pcbs. About the only time i do it these days is when i want an ethernet, sata or usb connector from a dud motherboard.

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

Yeah, I don't have a heat gun, but the mini butane torch works pretty fast, but like I said, it burns the board beneath.  I use a cigarette lighter on shrink tubing.  I would like a heat gun, but have never gotten around to getting one.

 

I like Excess Solutions for finding parts.  It is in San Jose.  Their stock is always changing, and they have a warehouse about the size of a football field.  Good prices, and lots and lots of product.   Halted is good if you are looking for a particular resistor.  Excess Solutions has lots of all kinds of components.  If anyone is in the bay area they should check it out.  It makes Halted look small, but maybe a litter better for precision resistors.

 

I always buy a lot of something I find there because it may not be there next time I go in.  It is a liquidator after all.

 

mark

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

Oh, the difference between STM and SAM devices is the manufacturer.  Duh.

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

MarkThomas wrote:

Oh, the difference between STM and SAM devices is the manufacturer.  Duh.

 

Even if the cores are ARM for different manufacturers, the peripherals can be very different. I like analog too, so I always look for good analog peripherals, like opamps, comparators, programmable gain differential amplifiers, voltage references and stuff like that.

 

The stuff from Atmel is pretty decent in that regard and has been improving steadily (I hope it will get excellent once they include some Microchip tech, they are strong in the analog department), but I'm currently playing with ADUC7060 from Analog Devices, the ARM core is an older ARM7TDMI, but they are so easy to program (don't need an actual programmer, just a USB to serial adapter), excellent analog peripherals (obviously)... love it.

 

Now I'm looking at the PSoC series from Cypress, I looks amazing (in terms of analog versatility), I have to get myself some dev boards for Christmas smiley

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

El Tangas wrote:
Now I'm looking at the PSoC series from Cypress, I looks amazing (in terms of analog versatility), I have to get myself some dev boards for Christmas

 

I have used PSoC's on occasion and while they are impressive they can be expensive, and a pain in the butt to use.  the software has improved dramatically over the years thankfully, and the support community is pretty good too.

Best of luck

 

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

 

"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 user

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

I probably should have gone for a development board instead of the Arduino Due, which is sort of like a development board with issues.  The Atmel Xplained SAM boards look to be around $50.  The Chinese Due was $12.  I guess for my purposes I can write code for the Arduino Due and use AS6.2 and my ICE, and learn most of what I want to know.  I am just playing around, anyway. 

 

I should probably upgrade to AS7, but it seems it still has issues.  AS6.2 has been good to me, so I am not in that big of a hurry to upgrade.  I think I will wait until it is a little more mature.  It is sort of like never buy the first year of a new motorcycle design.  Although, I did do that once and it was fine.

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

I finally got my Due in the mail, and I can look at things with my ICE via JTAG, but I cant figure out how to configure a pin for output and turn it on and off to blink an LED.  Can someone give me a sample Atmel Studio project for a SAM3?  A simple blinkey would be cool.  I don't know why I am having such a hard time with this.  Probably because I am lazy and my Google searches have given me nothing simple.  I should probably go to the ARM community and start asking dumb questions and embarrass myself.  At least here people are used to me being dumb.

 

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

Why not just start with Arduino projects on the Due?

 

You can replace simple sequences with regular C statements.

e.g. find how to replace a pinMode() statement with PIOB->PIO_OER

or digitalWrite() with PIOB->PIO_CODR or PIOB->PIO_SODR

 

You are familiar with GPIO on an Xmega.   ARM is similar.  i.e. PIO_PDSR as a data register and PIO_SODR as a "steering register"

The datasheet explains.  

 

Manipulating a GPIO port is similar on a Xmega or ARM.   Multiplexing peripherals to a pin varies considerably e.g. using a pin for ADC, SPI, DAC, ... or plain GPIO.

 

David.

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

I don't really want to put another layer between me and the ARM, and I don't want to learn Arduino.

 

The syntax PIOB->PIO_OER reminds me of C++ where PIOB is a pointer to an object and PIO_OER is an element of that object.  Is that what it means?  I would rather not write in C++.  I don't think -> is a C operator, is it?  I am having an elder moment. 

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

I strongly recommend that you make the effort to learn Arduino.
.
Arduino sketches know about their target processor. i.e. they #include avr/io.h or equivalent.
So you can use statements like DDRC = 0xFF in a Uno sketch.
PIOB is the equivalent of &PORTB on an Xmega. i.e. you access the individual registers with pointer syntax.
.
You have probably written generic USART functions for the Xmega. e.g. to work on USART0, USART1, USART2, ...
.
ARM cpus have lots of peripherals. You normally access them as members of a struct.
.
David.

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

MarkThomas wrote:

I don't really want to put another layer between me and the ARM, and I don't want to learn Arduino.

 

The syntax PIOB->PIO_OER reminds me of C++ where PIOB is a pointer to an object and PIO_OER is an element of that object.  Is that what it means?  I would rather not write in C++.  I don't think -> is a C operator, is it?  I am having an elder moment. 

 

Other way round. Pointers are the quintessential feature of C, it's Unique Selling Point that makes a lot of people thing it is fantastic, and a lot of other people think that C is the worst thing ever invented.

 

But C++ co-opted the same syntax for objects. The first C++ compilers emitted C code. Objects are literally just C structs. A dynamic object is accessed as a pointer to a struct.

 

If you don't like interface layers, then download the SAM3X8E[1] user manual and start coding, it's what everyone who wrote those interface layers did. But at 1458 pages, you might start to think that using one of those interface layers could save a bit of time... at least the register addresses could be useful.

 

[1] http://www.atmel.com/Images/Atme...

Bob.

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

With the AVR, the i/o is tightly coupled to the cpu. With ARM it is just a memory address that happens to talk to the outside world.
Adressing via a struct is quite efficient in ARM as it has good indexed addressing instructions. The base pointer gets loaded into a register and a load or store instruction can index via that register.
-> is most certainly a C operator. Both MBED and Arduino are C++. It solves a number of problems in a cleaner fashion than C. Maybe I'm just lazy, but i like it when the compiler can do labourious stuff consistently and correctly.

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

Actually Mbed has a low level API that is pure C, but there is a set of C++ wrapper classes on top.

 

So if you don't like the fact Arduino has a wrapper layer, Mbed has two! But generally Mbed has a much nicer abstraction than Arduino.

Bob.

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

MarkThomas wrote:

Can someone give me a sample Atmel Studio project for a SAM3? 

My Atmel Studio installation currently has 54 example projects for Due, i.e., "New"/"Example Project..." then enter "Due" in the search box. The led blinker is called "Getting Started-Application on SAM/Arduino Due/X".

/Lars

 

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

OK, thanks for all the input.  I was under the influence of heavy pain meds when I wrote yesterday.  I have some periodic medical issues, and I wasn't thinking too clearly.  Of course -> is a C operator, used with structures to point to an element.  It's funny, but all the years I wrote C code I never used a structure.  Weird for 30 some years of writing C.  I was usually hired to implement some algorithm in a big piece of existing code that the company's implementers were having trouble with, and none of the code I started with ever used structures.  I never started a project from scratch until I started playing with the ATmega.  I made my own "Markduino" before I knew about Arduino, and use it for all my prototyping.  The ATmega is in a socket, so I could program the chip from AS and then put it into whatever project I need it for.

 

Now it looks like I will get some practice, if as Kartman says, the registers are easily accessed as structures then I am good to go with the abstraction, and should have no trouble with the syntax.  I am starting to get excited.  It will be good for me to do some structure stuff in C.

 

I have taken some of my C code from AS and copied it into an Arduino sketch to make use of an Arduino library, and then did a verbose build to get the hex file I could put into the bare ATmega328 I was using with an AVR ISP mkII, so I know something about Arduino land.  I just don't want to go there.

 

I got the example program suggested by Lajon.  Thanks for that.  Now I have something to get a grip on.

 

Thanks again for all your help, gentlemen(women).  I think I have enough now to get started.

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

David said:  I strongly recommend that you make the effort to learn Arduino.

So I downloaded the latest version of the IDE and opened one of my old sketches that did a blinkey and played around with that.  I am not a newbie with Arduino.  I shouldn't have said I didn't want to learn Arduino.  I should have said I didn't want to use Arduino.  I am tempted to drink the coolaid and go over to the dark side and do more Arduino.  The learning curve is almost flat.  It is just a matter of finding the function call you want to do the work.  Easy Peasy.  It is perfect for beginners, and especially good for Advanced users who don't want to deal with all those pesky registers; they have done it all before; they just want the results quick and dirty.  I know some retired Cal Tech EE graduates who use Arduino that way; quick and dirty.  I'm still a nerd and want to know about the register structure.

 

I guess I can write some code and look at what include files are used.  I cant run any programs now since I installed a program with my ICE and erased the bootloader.  A friend of mine has the Tiny AVRISP that powers the board through the programmer.   My AVRISP mkII doesn't work for that.  So I can burn the bootloader.  I just want to write a 4 line program that sets the appropriate PIOC registers.  I am procrastinating.  It looks easy from the data sheet.

 

Off I go now.  I'm happy the holidays are over.  My next project is 100MHz amplifier.  I made a nice one that starts to drop off above 10MHz but it works down to 2Hz, so I am pretty happy with it.

 

Happy new year everyone!

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

Now that I remember, when I started  out with ARM as a hobbyist, there was a guide by Jim Lynch considered a standard reference, it can still be downloaded http://www.atmel.com/dyn/resourc.... It's great because it takes you through every step of installing and running some code in detail. The problem with that is that it is very specific to particular hardware and software, and rapidly becomes out of date. I am not sure any of the details still apply.

 

Nowadays there is so much information around, and installing the tools is pretty easy, so there is not really any one go to guide. There are some "bare metal" guides on the web such as https://batchloaf.wordpress.com/... and for assembler https://ioprog.com/2015/10/05/mi...

 

Some people recommend books, e.g. https://www.amazon.co.uk/Definit... and many others. I've never looked at any of them, so couldn't make a recommendation.

Bob.

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

Amazing that you could use C without structures! I think pretty much everything I've ever written has used structures, in fact I'm probably guilty of over use. If you get into the habit of grouping data the next step up to C++ will be a fairly natural step.

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

Likewise,   I can't believe anyone could use C without structures.

 

Or 68000 ASM code without stack frames.

 

Regarding Arduino Due.   You can write to the Due SFRs with regular C statements.    Just like you can write to the ATmega328P SFRs in a Uno sketch.

You lose all portability but you can play with a single low-level SFR even though your main App was constructed with Arduino libraries.

 

David.

Last Edited: Fri. Jan 6, 2017 - 03:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I worked with an experienced C programmer who didn't know how to use strings. This seemed improbable, but his background was DSP algorithms, so had never needed them!

 

His knowledge of numerical programming was far better than mine, so I ended up learning more from him I think.

Bob.

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

donotdespisethesnake wrote:
http://www.atmel.com/dyn/resourc.... ... The problem with that is that it is very specific to particular hardware and software, and rapidly becomes out of date.

Indeed: 10 years old - that's an age in this business!

 

it's ARM7, which is now "legacy" - Cortex-M is the flavour of this decade...

 

I am not sure any of the details still apply.

You're probably right.

 

 

 

Top Tips:

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

I know, it is sort of crazy; I think not using structures made it that much harder to learn C++.  I wrote C++ code for about 7 years and then retired.  I had a hard time with it.  It seemed so strange. 

 

I also didn't know how to use strings until I started playing with AVRs.  Now I am OK with them.  I never needed them.  I also wrote DSP algorithms.  We sent a spacecraft to Venus and mapped the surface through the clouds with Synthetic Aperture Radar.  It was a cool project with nary a structure or string in sight.  My last project was solving Maxwell's equations for light reflecting off structures built up on silicon wafers by places like Intel.  That was all C++, and we used a 512 core cluster.  I was lost a lot of the time on that project, but luckily I had a supervisor who knew my weaknesses.

 

Now I play around with little tiny processors, and am still lost a lot of the time.  Luckily, I have you guys to help me out when I get lost.

 

Happy New Year