Programming Atmega1284p

Go To Last Post
74 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello AVR freaks,

I am a student and decided to design a system using the atmega1284p cause it is awesome, I really don't have any experience with microcontrollers and never programmed one but my issue currently is how to get the software on the uC,

my college has a pinmaster 48 programmer that is compatible with alot of uCs, it has direct pin interface and jtag/ISP.

My worry is the software is old and the 1284p is not on the list but the 664p is which I hear is similar.

Are there any way to use this machine to program the uC?

Thanks
I am starting to think I should I have just got 89s52 but it is not nearly as powerful.

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

I do not know hat a '664p' is.

The whole point of modern flash based MCUs is that you can program them in-circuit. i.e. ICSP or ISP.

You really do not want to be pulling chips in and out of a PCB for programming.
You just put a small 6-pin ISP header on your pcb and use a regular Atmel programmer like AVRISP-2 or usbasp.

If your mega1284P is on a dev board with USB or RS232 connections, you install a bootloader and never need an external programmer again. (you do need a programmer to program the bootloader)

If you are too poor to buy an AVRISP-2 or usbasp, you will need the 'Pinmaster 48' to be available to you. Will the college approve ?

Ask the manufacturer for an update to its software to handle the ATmega1284P.

David.

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

Quote:

pinmaster 48

The 1284 does not appear on this list:

http://www.mqp.com/text/devs48.txt

but many older mega AVRs do so I'm guessing this list may simply be out of date. The chances are the firmware of the programmer has an upgrade to cover the more modern ATmega too - worth asking at mqp.com

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

david.prentice wrote:
I do not know hat a '664p' is.

The whole point of modern flash based MCUs is that you can program them in-circuit. i.e. ICSP or ISP.

You really do not want to be pulling chips in and out of a PCB for programming.
You just put a small 6-pin ISP header on your pcb and use a regular Atmel programmer like AVRISP-2 or usbasp.

If your mega1284P is on a dev board with USB or RS232 connections, you install a bootloader and never need an external programmer again. (you do need a programmer to program the bootloader)

If you are too poor to buy an AVRISP-2 or usbasp, you will need the 'Pinmaster 48' to be available to you. Will the college approve ?

Ask the manufacturer for an update to its software to handle the ATmega1284P.

David.

by 664p I ment the 644p and the pinmaster has ISP connections but the uC is not in the list of the pinmaster software

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

Don't drink cokes for a couple weeks. Every time you get thirsty, put that buck in your pocket. After a week or so, you can buy your very own Atmel AVR ISP mkii for $35 from the Atmel store. Durable goods. You can take it with you to your first engineering job.

Imagecraft compiler user

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

Quote:

After a week or so

You don't need to wait the entire week:

$1.63 gets this delivered to your door: http://www.ebay.com/itm/USB-to-R...

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

Thanks guys so it seems it won't work, I thought since it had ISP it would just program via software but each microcontroller is different ISP? Still confused but

What is my cheapest and most simplest alternative, I did look at the programmer on the atmel website AVRmkII, it costs too much for me, especially since this is a college project and is assigned a small budget, I could buy it myself but still not sure it is worth that much.

Please recommend a cheap ISP programmer or any programmer in fact that will work with 1284p, the simpler the better as I have no clue and really dont want to run into problems.

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

You wrote:

Please recommend a cheap ISP programmer

Previously I wrote:

$1.63 gets this delivered to your door: http://www.ebay.com/itm/USB-to-R... ... d=ViewItem

Is $1.63 still too expensive for you then?

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

clawson wrote:
You wrote:

Please recommend a cheap ISP programmer

Previously I wrote:

$1.63 gets this delivered to your door: http://www.ebay.com/itm/USB-to-R... ... d=ViewItem

Is $1.63 still too expensive for you then?

ofcourse not but what I see is a usb to serial cable, looks nothing like avr mkII, how would it even work?, I am lookimg for something u can use with avr studio most likely

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

Quote:

ofcourse not but what I see is a usb to serial cable, looks nothing like avr mkII, how would it even work?, I am lookimg for something u can use with avr studio most likely

Apologies - wrong ebay link. Sorry. :oops: I meant this one:

http://www.ebay.com/itm/USBASP-U...

The price has, I'm afraid gone to $4

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

I am sure that there will be an upgrade file for your 'Pinmaster 45'. Just ask the makers.

The main consideration is: "Can you take it home with you?"

Spend a whole $4 and you can use the usbasp whenever you like.
From Studio4, you use a .BAT file to control the usbasp via the Tools menu.
From Studio5.1, I think you should be able to run directly from the Tools menu.

David.

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

david.prentice wrote:
I am sure that there will be an upgrade file for your 'Pinmaster 45'. Just ask the makers.

The main consideration is: "Can you take it home with you?"

Spend a whole $4 and you can use the usbasp whenever you like.
From Studio4, you use a .BAT file to control the usbasp via the Tools menu.
From Studio5.1, I think you should be able to run directly from the Tools menu.

David.

My bad, I forgot to mentioned I send the company of the pinmaster an email and they replied saying they no longer support the universal programmer, the latest atmega supported was the 644p. Still nice of them to reply so soon, they do usb analyser and stuff now.

I got AVR studio 5.0 installed right now will the usbasp work with that?

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

Quote:

I got AVR studio 5.0 installed right now will the usbasp work with that?

You can define a post build step in AS5 to invoke "avrdude.exe -c usbasp..." but this will run avrdude (which is what you use with the USBAsp) outside of AS5 - though it will just seem like it's happening inside.

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

Quote:
My bad, I forgot to mentioned I send the company of the pinmaster an email and they replied saying they no longer support the universal programmer, the latest atmega supported was the 644p. Still nice of them to reply so soon, they do usb analyser and stuff now.

I am surprised that they do not support it. After all, they are still trading.

At least they had the honesty to tell you. (I guess it would take them 1 minute to add support for the ATmega1284P)

David.

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

david.prentice wrote:
Quote:
My bad, I forgot to mentioned I send the company of the pinmaster an email and they replied saying they no longer support the universal programmer, the latest atmega supported was the 644p. Still nice of them to reply so soon, they do usb analyser and stuff now.

I am surprised that they do not support it. After all, they are still trading.

At least they had the honesty to tell you. (I guess it would take them 1 minute to add support for the ATmega1284P)

David.

I know it is very disappointed, my thought right now is why can't I use avr studio or avrdude with the pinmaster, since it has an ISP/JTAG interface.

Also another idea is I could use an arduino, I think it would be wiser to pay high cost for arduino then just mkII programmer.

The usbasp ones are ok but they are all from china and it will take weeks, I read the feedback and found some of them even lie saying they are based in uk but really they are in china.

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

any ideas on that?

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

Quote:

why can't I use avr studio or avrdude with the pinmaster,

Atmel talks various protocols (AVR069, AVR109) to it's programmers and debuggers. The chances are "pinmaster" have chosen not to implement one of these protocols - remember this thing is not Atmel specific but "talks" to about 50 manufacturers chips so why would they feel bound to specifically use an Atmel protocol? My guess is that they have a proprietary protocol that covers everything all those chips might require and are therefore tied to their own PC software.
Quote:

Also another idea is I could use an arduino, I think it would be wiser to pay high cost for arduino then just mkII programmer.

This is very true - it's easy to turn an Arduino into an ISP programmer. (where do you get "higher cost"? AVRISPmkII is $34 - you can get Arduinos for less than that).
Quote:

The usbasp ones are ok but they are all from china and it will take weeks,

Experience suggests 6 or 7 days to Europe. Presumably the same to any worldwide destination.

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

clawson wrote:
Quote:

Quote:

Also another idea is I could use an arduino, I think it would be wiser to pay high cost for arduino then just mkII programmer.

This is very true - it's easy to turn an Arduino into an ISP programmer. (where do you get "higher cost"? AVRISPmkII is $34 - you can get Arduinos for less than that).
Quote:

The usbasp ones are ok but they are all from china and it will take weeks,

Experience suggests 6 or 7 days to Europe. Presumably the same to any worldwide destination.

Yh thats what I ment arduino is cheaper then mkII so why pay for a programmer when you can get a whole system.

Also a week is not too bad for delivery from china will look it to that more.

I had my eye on AVR dragon seems cool, debugger and programmer in one, bad point you have to buy ZIF socket and headers to use it as a programmer.

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

Quote:

you have to buy ZIF socket and headers to use it as a programmer.

Just to note that you don't need a ZIF socket - I've never added on to mine.

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

You need to buy / make proper 10-way and 6-way JTAG and ISP cables for a Dragon.
I put a sheet of clear polycarbonate top and bottom with cut-outs for USB, JTAG, ISP.

Only masochists mess around with HVPP.
If you mess up a chip, it is cheaper to buy a new chip than to buy and solder headers, sockets, jumper wires.

Of course, some people enjoy messing up chips. It is not necessary.

David.

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

Got too many choises,

AVRISP MKII
AVR DRAGON
AVR STK500
AVRISP/ASP CLONES
AVR STK500 CLONES
ALL THEESE OTHER ONES PARALLEL AND SERIAL Bit banging etc
AVRJTAGICE CLONES
A COUPLE AVRISP MKII CLONES

my only concern is will they work atleast with the official product you know it will work with the 1284p

its driving me nuts

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

If you have $5 buy a USBAsp
If you have $35 buy an AVRISPmkII
If you have $50 buy a Dragon
If you have $80 buy an STK500

Simple as that. (IMAO).

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

As an impecunious student, it is really two choices:
1. USBasp @ $3.99 is hardly going to break the bank.
2. Dragon + some jumper wires is the cheapest way to debug ALL chips.

The USBasp can be added as a 'Tool' but is not directly integrated into Studio. No real inconvenience.
The Dragon is fully supported by Studio and every third party software ever invented.

Of course if you are rich, the choices are more varied. e.g. A reliable dev board.

If you buy from abroad, it can be cheaper but you wait a few days.
Beware carriage and customs charges.

David.

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

Hi David, Will the usbasb you will lend come with the isp cable and is it six pin or 10 pin interface?

I will probably try to setup part of the system this week.
The isp header for the target board should be male right.

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

All usbasp boards use a 10-pin male header, and a 10-way ribbon cable.
You download the pin-out and USB driver from fischl.de/usbasp

I suggest that you wire a matching male header on your pcb (you can leave pins 4, 6, 8, 3 as n/c). Mark a RED dot for pin#1 with a permanent marker. Then you have a reliable connection with your ribbon cable.

Pin #2 will supply 5V power from the usbasp. So you must not supply power to your board in any other way.

Alternatively, leave #2 as n/c if you already have power on your pcb.

David.

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

Hi,

Is this the right pinout?

I thought I might as well build a connector from the usbasp to uC.
Still haven't recieved the microcontroller, so little time so much to do :(

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

Where are you buying your microcontroller from?

Farnell deliver next day.
RS might take 2 days.

I always reckon that an Arduino is a very convenient and useful dev board.

It should be easy to get your University project up and running with an Arduino.
If you spend your time on good documentation of your project, you will get good marks.

A 'clever' design with bad or absent documentation is no good to anyone.

David.

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

Yh, it was ment to have arrived last week but some complication happened and now they need to place order again.

Arduino was a choice but isn't it very simple and you would learn less about the hardware side of it. It is still a backup plan in case everything goes wrong, hopefully it wont. At first I was thinking of 8051, the avr was a big step up without going as far as arduino.

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

Quote:

Arduino was a choice but isn't it very simple and you would learn less about the hardware side of it.

Au contraire - it's almost undoubtedly the simplest AVR development board there is - they couldn't have made it easier to use.

And while you are right that if you use library code you don't learn so much about the hardware - but you only do that to get started. When you are confident about overall program structure you can then switch to direct hardware access for each peripheral in turn and learn about that.

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

A project starts with an idea, and then you design the solution.

The coding is the last step and fairly trivial.

Why not use the coding system that is easiest?

e.g.

 Serial.begin(9600);
 Serial.println("Hello World");

You can always write the equivalent in C or ASM. More work, but it does the same thing.

They all run on the same Arduino hardware. You need no extra wires for the UART.
The Arduino board already has headers that can connect to extra hardware.

David.

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

If I was to use arduino instead which model would be similar to a atmega1284p.

The prime reason I chose the 1284p was because it had built in adc, 4k eeprom to store data. I want to be able to log information from several sensors onto the eeprom and then periodicly extract it via serial interface to the pc which then converts it to an appropiate format and the send it off to a website.

I have a very little understanding of arduino, I know two things, it is easy to use and it uses atmega chips.

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

The "big" Arduinos are based on the mega1280 and mega2560. They have ADC and they have 4K of EEPROM. The main deficiency compared to the 1284 is they only have 8K of SRAM while the 1284 is the only mega AVR that has 16KB.

From boards.txt in the Arduino software:

mega2560.name=Arduino Mega 2560 or Mega ADK
mega.name=Arduino Mega (ATmega1280)

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

I seriously advise a regular Arduino with a mega328P.
95% of all accessories are designed for the standard Arduino.

If you want some local storage, add a 24C512 or 23C256 (3.3V) on a shield or breadboard.

It is surprising how much you can 'log' to ordinary SRAM or external eeprom.
The internal eeprom is ok for occasional use but is VERY slow for logging purposes. e.g. 320ms for 64 bytes when a 24C512 takes 4ms. Or a 23C256 takes microseconds.

The Arduino has libraries to handle pretty well any hardware ever invented.
They may not all work with the mega2560 boards.

David.

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

Hi, I got the uC and usbasp setup, I am just wondering will I brick the uC if I flash without changing fusebits or lockbits on avrdude.

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

Do not touch the fuses yet.

Just practice uploading program to flash.
Your chip will run at 1MHz.

You can make it run at 8MHz by adding these two lines to the start of your program.

    // Crystal Oscillator division factor: 1
    CLKPR = 0x80;
    CLKPR = 0x00;

or with avr-gcc:

#include 
    ...
    clock_prescale_set(0);
    ...

David.

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

is there any advantage to using the code instead of disabling the divide by 8 fuse, to let it run at 8mhz?

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

Quote:

is there any advantage to using the code instead of disabling the divide by 8 fuse, to let it run at 8mhz?

Yes you don't risk crewing the chip by making a wrong fuse setting!

The downside of the code solution is that if you do it as:

int main(void) {
    // Crystal Oscillator division factor: 1
    CLKPR = 0x80;
    CLKPR = 0x00; 

then there could be several thousand instructions executed before main() that will run at the slow 1MHz rather than the new, fast 8MHz speed.

If using avr-gcc you can mitigate this by putting the lines in a separate function:

__attribute__((naked,section(".init3"))) void setclk(void) {
    // Crystal Oscillator division factor: 1
    CLKPR = 0x80;
    CLKPR = 0x00; 
}

That will then be done before any "long" work in the pre-main code.

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

Hey, I got the 1284p with internal clk and a arduino both setup to blink led every second.

They are not running at the same speed. I had lots of problems with the _delay function in avr toolchain so I am currently using delay_x.h from here.

What could be the problem?

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

How different ?

Unless you specifically set the CLKPR in software (or remove the CKDIV8 fuse) your chip will run at 1MHz.
The Arduino will run at 16MHz. i.e. 16x faster.

If your Toolchain is recent, you should have a working _delay_ms(). Of course you have to tell Studio 5 that you are running at 8MHz or whatever.

David.

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

Quote:

Unless you specifically set the CLKPR in software (or remove the CKDIV8 fuse) your chip will run at 1MHz.
The Arduino will run at 16MHz. i.e. 16x faster.

Just to say that this alone should not affect the LED blink rate AS LONG AS you specify F_CPU correctly for each program. The _delay() routines use F_CPU to determine how many loops they should do and therefore need to be told accurately how fast the CPU is running at - this is done when you #define F_CPU. So the error is likely that the value you specify for F_CPU does not match reality. If you get it right then:

 LED_on();
 for(i=0; i<10; i++) {
   _delay_ms(1000);
 }
 LED_off();

should light up an LED for exactly 10 seconds as shown on the sweep second hand of your wristwatch. If not F_CPU is not set to the actual CPU speed.

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

I'm using avr studio 5.0, At the top of the code I define F_CLK 8000000UL and I disable the div/8 fusebit and it runs too fast.
When I use the delay_x.h instead it works ok, I don't have a accurate way or measuring the time.

When I try setup them up to blink at the same time the avr gets a head fairly quickly. so it is definantly blink faster than the arduino.

It just comes down to how accurate the arduino clk is compared to the avr.

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

Quote:

I'm using avr studio 5.0,

Quote:

When I use the delay_x.h instead it works ok

All the warning signs are here. Atmel made a mistake in 5.0 and set the default build optimisation to be -O0, this almost never works. They corrected this in 5.1 (and now 6.0) so that the default build ("Debug") now uses -O1. Suggest you try the same.

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

The delay macros use F_CPU.
They will not care what value to give to F_CLK. It is irrelevant.

Even Studio5 gives a Build report.
Examine any Warnings or Error messages.

David.

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

Thanks I thought it was F_CLK for the avr delay.h and F_CPU for the delay_x.h, but I had both defined so my resut above it true.

did the test with the for loop and it turned out the avr is 9.7s and arduino is 10s.

Anyway to fix this ?

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

Quote:

Anyway to fix this ?

As I say, what optimization setting are you using? The delay.h delays will not work properly at -O0 (which is what 5.0 mistakenly defaults to)

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

I am not sure maybe debug?

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

I'm talking about this...

(what is yours set to?)

Attachment(s): 

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

Cliff,

Surely you should choose -O1 for the Debug build.
And -Os or -O3 for the Release build.

It is important to test the final version after you have finished debugging. You might select -Os for these final tests of the Debug version. (and learn how to follow a mixed ASM and C view)

David.

Last Edited: Sat. Mar 3, 2012 - 03:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks clawson, it was said to -O0, I changed it to -O1 and the standard util/delay.h is now working but it is still not exactly 10seconds, just like the delay_x.h, could it be the uC internal clock is not running at exactly at 8MHz?

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

You will not discover any calibration errors with your wristwatch. They should be fairly minimal anyway.

I suppose that -3% is within a margin of calibration accuracy. You must be pretty good with your reactions to detect 0.3 seconds in a 10 second period. 3 seconds in a 100 sec period, yes.

Does it really matter anyway?

David.

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

Quote:

Surely you should choose -O1 for the Debug build.

Not me - I always use -Os everywhere. I simply don't see the point in fannying about with some code that does not reflect what you plan to finally deploy?!? Spend hours getting some timing sequence right in a -O1 build then switch to -Os and start all over again? No thanks. The only downside of debugging -Os (the optimizer is acting at it's most aggressive) simply means that toys like watch windows don't work. Again - big deal?

Pages