I´m kind of new to programming Atmel chips

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

I have programmed before in PIC MCU but now I have to do a project with a Atmel328P. The thing is that I would like to program it in C and some assembler, so the arduino IDE is a no for me. I already bought the MCU. I have two questions:

1. The IDE that I should use is Microchip studio right?

2. I don´t have a programmer like the AVRISP MKII and I looked what should I do and many people talk about the arduino as an ISP, I can upload a program made in Microchip to the MCU using the arduino as an ISP?

This topic has a solution.
Last Edited: Fri. Nov 19, 2021 - 04:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

edimar369 wrote:
I would like to program it in C and some assembler,

See App Note  AT1886: Mixing Assembly and C with AVRGCC https://ww1.microchip.com/downlo...

 

Also: https://www.nongnu.org/avr-libc/...

 

edimar369 wrote:
The IDE that I should use is Microchip studio

Seems the obvious choice - probably the most widely used here

 

edimar369 wrote:
I don´t have a programmer

Get yourself an ATmega328P Xplained Mini board - it comes with a built-in programmer and debugger.

 

https://www.microchip.com/en-us/development-tool/ATMEGA328P-XMINI

 

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

Welcome to AVRFreaks!

The Arduino IDE has the same compiler as the MCS7....   Nothing in it prevents you from writing C code....  assembler may be more of a challenge....

As Andy said, get yourself an xplained mini board.  Good luck with your learning.

Jim

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

Lets go Brandon!

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

Thanks for your answers!! 

About the ATmega328P Xplained Mini board currently I live in Ecuador so I don't know if there is that product here. That's why I was asking about the arduino ISP. I found out I can use a Pickit because it is compatible but before buying one... If it is not possible then I'll have to buy the avr programmer :/

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

edimar369 wrote:
I live in Ecuador

do you not have on-line ordering there?

Sources:

Microchip

Digikey

Mouser

Amazon: https://www.amazon.com/MICROCHIP...

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

Lets go Brandon!

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

We have but it is more expensive the delivery than the product sometimes :( hahaha

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

edimar369 wrote:

We have but it is more expensive the delivery than the product sometimes :( hahaha

Same here sometimes, have any friends, maybe put together a group buy order! 

An inexpensive programmer for the M328 is the USBasp, from china, costs can be less then the shipping, more reliable then using an UNO as a programmer, plus it can program the fuses as well.

Get one with the 10pin to 6pin adapter for use with 2x3 ISP connectors...

https://www.ebay.com/itm/2225393...

Other source such as Aliexpress may be a bit cheaper then Ebay/Amazon etc.

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

Lets go Brandon!

Last Edited: Fri. Nov 19, 2021 - 04:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

Easy--- just get one of these xplained boards for around $11 (328P or newer 328PB) ...it includes the 328,  programmer, debugger and a serial port and some prototyping area...very cheap and useful

best part is just plug in the usb to  your PC and it will fire right up in Studio7 (or Microchip studio)  and ready to take your program.

 

The BEST PART is that it will 100% work, no messing around wondering about your wiring, connection, crystals, capacitors, flaky breadboards, etc...all the thing that shut everyone down

Studio will even recognize the board & bring up app notes, help, and maybe some sample training modules

 

https://www.mouser.com/datasheet...

 

 

 

 

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

Last Edited: Fri. Nov 19, 2021 - 04:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks  ki0bk !!

Would you explain me what are the fuses please? I've been reading a lot about microcontrollers but I don't get what are the fuses hahaha I learnt about microcontrollers in spanish so I got a little confusion here :(

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

 

edimar369 wrote:
We have but it is more expensive the delivery than the product sometimes

Still well worth it, though.

 

Put together an order of several things - so the shipping is less significant.

 

It seems they can be had on Amazon:

 

although that one seems to be nearly 3 times the price of the usual distributors and wants shipping on top!  surprise

 

also ebay ...

Top Tips:

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

Well it seems I'll have to buy some other things then, what a shame (not at all) hahahah 
I'll keep looking if there is a place in my country where I can buy the board since it seems as the best way to program the mcu, thanks a lot guys !

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

edimar369 wrote:
I live in Ecuador 

could be useful to add that to your profile ...

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

Ok I looked into the board you're telling me and it won't work, I think I forgot to mention that I have to do a PCB after all so I bought the dip version of the mcu, then I think buying the avr programmer will be the best option right? Or the USBasp  tha ki0bk said...

Last Edited: Fri. Nov 19, 2021 - 04:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You would still benefit from having the Xplained board - it gives you not only a programmer but also a debugger.

 

Alternatively, you could get an Atmel-ICE - but that is more expensive.

 

EDIT

 

And, of course, you want something to prototype on before doing your very first PCB with this chip ...

 

Thread on how to use the Xplained on-board debugger with external targets: https://www.avrfreaks.net/forum/low-cost-debugger-xplained-kits

Top Tips:

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

 

I think that you go back to the Arduino like the Pro MINI below:

 

This is a very thin,cheap, and light AVR bootloader development board.  It can be shipped in a letter-mail standard envelope.  They cost about $4 each on eBay shipped from China.

You can add assembly language code (using the in-line assembler functionality of GNU C++, on which Arduino IDE is based).  With Arduino you get access to all the hardware abstraction layer  libraries so you don't have to learn to program the AVR on the register level.  You can program the Pro MICRO though the USB port of your PC with an USB-UART adapter.

 

There is an Arduino program/sketch that turns the AVR into a ISP programmer.  You take the hex file generated by the compiler and send it to the AVR-under-program using the AVRdude.exe program.

 

On the AVR, fuses are programmable non-volatile configuration switches.  They don't have memory addresses.  They set up how the AVR hardware will operate.  For example, the clock speed and whether the system clock is the internal resistor-capacitor oscillator or an external crystal, Brown-out reset voltage level, and other adjustable parameters. 

Last Edited: Fri. Nov 19, 2021 - 04:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

And, of course, you want something to prototype on before doing your very first PCB with this chip ...

Yes you're right, I made the prototype in arduino but it's not the same
I think I should buy the board then

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

 

I was about to mention, in my first post (was looking around for this info)

 

WITH A FEW EASY MODS ...you can use this board to program and debug  "any" (mostly)  AVR that you can put on your breadboard 

https://www.avrfreaks.net/forum/...

 

try www.microchipdirect.com for the best deal (maybe shipping too)

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

Last Edited: Fri. Nov 19, 2021 - 04:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


edimar369 wrote:
I don't get what are the fuses

Look in the data sheet under Memory Programming, the fuse bits setup the micro, what clock source (i.e. internal R/C, or external xtal for example), what voltage level trigger for the BOD (Brown Out Detector), bootload flash space size, etc...  A bare M328 can come with the internal R/C osc as the clock, or it may be setup for Arduino use with it set to external xtal. 

The lock bits are used to "Lock" the memory from being read by a programmer to protect your coded from being copied, not needed for hobby projects, so avoid these for now...

Before you change fuses or lock bits, post on AVRFreaks what it is you want to do, so someone here can verify you have it set up correctly, BEFORE YOU write any fuses, you can "brick" your AVR if it is set wrong.

 

Good luck, have fun, ask questions if you need help.

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

Lets go Brandon!

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

Ok you convinced me, I have to buy it then haha it looks so useful

Thanks to all of you guys who answered this forum!!

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

Thanks Jim now I get it haha the fuse bits have another name in spanish but now I get it 
And definetly I'll keep asking for help here!!

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

avrcandies wrote:
WITH A FEW EASY MODS ...you can use this board to program and debug  "any" (mostly)  AVR

I think the on-board debugger (mEDBG?) only does debugWIRE - so that's "any AVR which uses debugWIRE"

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

ki0bk wrote:
The Arduino IDE has the same compiler as the MCS7.... 
more recent

https://github.com/arduino/toolchain-avr/blob/master/build.conf#L19

 

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

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

edimar369 wrote:
Or the USBasp  tha ki0bk said...
Pololu's AVR ICSP is approximately three times the price of a USBasp though has greater functionality and integration (STK500v2)

Pololu USB AVR Programmer v2.1

Pololu - Distributors - Ecuador

 


Pololu AVR Programmer v2 | The Little Projects Page

Pololu USB AVR Programmer V2.x - Case - v1.1 (48SVARGJP) by Zipcom

 

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