Full Version : AVR BUTTERFLY Q&A FAQ
avr >>BEGINNERS & BUTTERFLIES >>AVR BUTTERFLY Q&A FAQ


AVR_Admin- 05-09-2006
BUTTERFLY EXTERNAL POWER SUPPLY CABLE:

The BUTTERFLY datasheet talks about a possible use of an external power supply for specific uses ( programmation...).As described here :http://www.avrfreaks.net/filednload.php?url=/Tools/ToolFiles/462/Programming_butterfly_for_dummies.pdf

I 'd like to know the different kinds of compatible power cables .
Is it possible to find such cables in electronic shops ( on the Web ) ?

QUOTE
I don't know of any prebuild cable but it's not too difficult to solder one or try to find someone who does it for you (maybe from the local hobby-radio (HAM?) club). 2,54mm Pin-Headers and plugs should be available from every electronic-(online)-shop. Look at the BF shematics: http://www.atmel.com/dyn/resources/prod_do...nts/doc4271.pdf
Page 33. eg. J402(JTAG): Pin 4 VCC, Pin 2 GND or J400(PORTB)/J401(PORTD): Pin 10 VCC, Pin 9 GND or ISP-connector (maybe this picture gives a better overview: http://www.siwawi.arubi.uni-kl.de/avr_proj...ect_cabal.html)
Solder or let someone solder a pin-header on the board and connect a stabelized supply or batteries to one of the VCC(+) and GND(-) pins. External voltage between 3,1 and 4,5V as mentioned in the manual.




AVR_Admin- 05-09-2006
BUTTERFLY NON-ECHO WHEN CONNECTED TO TERMINAL:

I just got the butterfly and when i followed the directions in the user manual to enter name with hyperterm i get no response from the b-fly. also, the butterfly seems to be in an endless loop waiting for a signal because i cannot get it out of "waiting for imput on rs232" mode without taking the battery out. what'sgoin'on?


QUOTE
Firstly when you type on your keyboard, it isnt echoed to the hyperterm screen by default. you also must hit enter when you are done. so if you dont think its working, it actually might be working


QUOTE
Yea, the non-echoing default for HT really had me going for a while. To echo typed characters locally go to file -> properties-> settings (tab) -> ASCII Setup... -> Echo typed characters locally (check box). I also had a pretty weak setup with unsound connections, so I soldered some nice header pins to my b-fly and made a nifty cable with a D shell connecter n' everything.

As far as having to disconnect the battery to restart I guess just tapping back on the joystick will get you out of the uart loop (could have swore i tried that) it works everytime now. Oh, and last but not least... be sure to read the message on the b-fly, it was getting late and i think i just saw scrolling text on the LCD and assumed it was not what i wanted (i mean the thing can't work the first time right?).



AVR_Admin- 05-09-2006
BUTTERFLY DIFFERENT MEMORY TYPES:

I'm a little bit confused concerning the different memory types available in the ATmega169 and on the Butterfly. As I understand the ATmega169 has three different mem. types:

1. SRAM - the 'normal' RAM, volatile, used to store things like variables, used for registers and I/O
2. Flash - non-volatile used to store application and boot code(?)
3. internal EEPROM - non-volatile

and on the Butterfly there is

4. external DataFlash - non-volatile, a kind of EEPROM

Could someone please explain the different Types a little further to me and what I can use them for.

For example: can I store my app./boot code in 4. and how would I tell the ATmega169 to run code from that location ?

QUOTE
The program itself has to be stored in Flash.
Variables are stored in SRAM.
EEPROM is used for values to be retained when power is turned off.
External Dataflash could be used for applications such as datalogging, MP3 file storage - anything that needs more memory for storage than available on the AVR chip.



AVR_Admin- 05-09-2006
BUTTERFLY CLOCK RATE:

I'm interested in changing the clock rate that my Butterfly runs at so that I can use it modulate an IR signal at 38kHz. The stock Butterfly is clocked from the 32kHz real time clock. A clock rate of 1MHz would work quite nicely.

Can anyone direct me on how to do this? Are there clock multipliers that are software settable so that I don't have to make any hardware changes or does this require use of a, for instance, 1 Mhz resonator in place of the RTC?

Power consumption is not a really an issue since the end application will be run from some high capacity batteries. I just liked the form factor and extra goodies of the Butterfly so wanted to design around it.


QUOTE
Sorry if I am misundestanding your question but the Butterfly already runs code at 1MHz. It is my undestanding that the 32.768KHz crystal output is fed to Timer/counter2 for use in a real time clock type of application. The system clock uses the internal RC oscillator which I believe actually runs at 8MHz but is divided down internally to 1MHz. Again, as I understand it you can change this in software to run at 8, 4, or 2MHz as well.
Clearly there's a lot I don't understand. A friend and I have been debating this on email.


The schematic clearly shows XTAL1 and XTAL2 connected to the RTC, which has a frequency of 32.768 kHz. Those pins can also be used as counter/timers, so maybe that is how they are being used this application? This seems a foolish use for a C/T unless it's providing interrupts or some such, but that doesn't seem a good way to tie up those pins.

Additionally, current consumption is lowest when the clock is low, so given the battery power one would think that Atmel would set the clock as low as possible.

I would investigate further, but the AtMega169V datasheet that I D/L'd from Atmel is corrupt and I can't read it.

My question seems to be answered by this in main.c

CODE
void Initialization(void)
{
char tst; // dummy

OSCCAL_calibration(); // calibrate the OSCCAL byte

CLKPR = (1<<CLKPCE); // set Clock Prescaler Change Enable

// set prescaler = 8, Inter RC 8Mhz / 8 = 1Mhz
CLKPR = (1<<CLKPS1) | (1<<CLKPS0);

AVR_Admin- 05-09-2006
SOURCE FOR BUTTERFLY LCD SCREENS:

Does anyone know who manufactures the Butterfly LCD?

QUOTE
From "AVR Butterfly Evaluation Kit User Guide" Atmel document 4271A–AVR–07/03 we find that it is the same display as on the STK502.


CODE
Note: The LCD-display on the STK502 can be ordered separately from ACTE Norway
(www.acte.no).
Phone: +47 63 89 89 00
Fax: +47 63 87 90 00
E-mail: info@acte.no
Price: NOK 99,-
Ordering number: H4042-DL DE5156/L.


I appreciate the hint on where to buy it (I'm in NA) but was hoping someone knew who the manufacturer was. I guess I can track them down through the 'info' address. Thanks for your help.

QUOTE
Since no manufacturer is listed in the Bill of Materials, it could very well be a custom/semi-custom display built just for these applications. Once your quantities reach into the thousands semi-custom LCDs are not cost prohibitive.


I appreciate that it could be; however, usually for large volumes you go directly to the manufacturer and bypass distribution suppliers - unless Atmel themselves are selling the LCD to the supplier they noted in the STK502 document?

QUOTE
Figure 4.1 of the STK502 User Guide shows the manufacturer as Hitech Displays, the part number is H4042-DL DE5127/L. Their website is www.hitech-lcd.com.

I contacted them a while ago. They quoted me US$3.00 each for order of 100 (FOB Singapore). Their contact email is hdisplay@singnet.com.sg



AVR_Admin- 05-09-2006
BUTTERFLY CHANGED FUSES:

I have accidently changed one of the clk related fuse bits on the mega 169 in my butterfly. Now i can't change anything back and can't communicate with the mega169 at all. Please, is there any advice on how to fix this?
I am using the stk500 to program it.

QUOTE
If you are lucky and the external crystal option is selected you might try clicking on the STK500 icon in Studio and changing the Oscillator selection to 32.7KHz (click on the Board tab). I have no idea if this will work, just thought I would suggest it.

If you are unlucky the external oscillator option is selected. Now you will need to inject a clock signal into the m169 (I forget whether its XTAL1 or XTAL2, the datasheet will tell you). I am not sure if you will have to unsolder the 32.768KHz crystal or not. I have read here that you will need to inject something like a 500KHz clock I think. Perhaps someone could provide a link to a thread where this procedure is discussed in more detail.






Thanks for your reply. I've tried the 32.7khz trick, but didnt' help.
By your other suggestion, do you mean I should have a crack at the High Voltage Parallel Programming technique? It seems that method disables the external crystal so I think that's what you meant - it looks a good idea but tricky.

QUOTE
I was not referring to High Voltage programming but that possibly is another solution (never tried it myself and not familiar with that section of the Butterfly manual, that is why I say possibly).

I was referring to using an external function generator or some other type of oscillator and inputting that signal into the XTAL1 pin of the m169. This may be necessary if the fuses accidently get set for the external oscillator option. Note this is different than the fuses being set for the external crystal option. An external oscillator is like one of those metal cans with 4 legs that can fit into a DIP socket. An external crystal can also come in a metal can but only has 2 legs and requires 2 capacitors.




AVR_Admin- 05-09-2006
BUTTERFLY EXTERNAL POWER SUPPLY:

I have 3 AA batteries which gives about 4.1 volts so it is within the specs. Should I remove the button cell battery when using external power? I am a computer nerd not an electronics nerd so I'm wondering if the amps matter. The specs just tell you about volts, but wouldn't there also be some kind of range for the amps? It would seem that 10000A would kill it.

Also, what is a good way to connect everything to the butterfly? I have a two row header, but the electronics store didn't cary any two wire connectors. Any way to hook it up to a breadboard?


QUOTE
I'm *guessing* you should remove the coin cell. Unless it is diode protected (I doubt it is), putting other batteries on there that have a higer voltage will try to charge the coin cell - bad form.

10,000A will kill a lot fo things 

There is a thing called Ohm's law that comes into play. If you can treat the butterfly as just a resistor (not too bad an approximation) then the current it draws will be determined by the voltage you apply to it - not how much your power supply (batteries, Hoover Dam, etc) can deliver.

I think that's what you meant - would using a higher voltage power supply draw higher current? Generally that is true.

If you have the header stock, a quick way of hooking up if you don't have the actual connector is to use wire-wrap wire. Header posts take to wire wrap wire like the were made for it - and they basically were. It isn't permanent but gives a really good connection that you can just pull off when you are done. You can get a cheap but very servicable wire wrap tool at Radio Shack or similar.



CODE
The Butterfly coin cell is diode-protected. There is no need to remove it.

If you need your own copy of the schematic.


QUOTE
If you have any junk cables from a computer motherboard, like disk drive cables or serial port cables, the spacing should be the same (0.1"" square), and the ribbon cable is already connected to one end. 

AVR_Admin- 05-09-2006
BUTTERFLY DATAFLASH:

For three days I try to store data in the data flash on the AV R Butterfly. I cannot make it. It does not work with my code.

So, please, if somebody has ever tried to store data in the dataflash and read it back of the AVR Butterfly please give me a hint or better give me a working source code.

I am using the functions from GCC, module dataflash.c

QUOTE
Take a look into the file test.c in the butterfly-application source. This will give you an idea of how it works. The datasheet for the flash-chip, an application note "using Dataflash" and an application note describing the interfacing between an AVR and a Dataflashs to store "audio-data" (using software-spi IRC) is available at atmel.com



AVR_Admin- 05-09-2006
BUTTERFLY & DATAFLASH AT FIVE VOLTS:

Does anyone know if this DataFlash (this is the one on the Butterfly) can take a Vcc of 5 volts? The datasheet[1] says, "supply voltage 2.5 to 3.6 volts", but under "Absolute Maximum Ratings" it says, "All Input Voltages (including NC Pins) with Respect to Ground: -0.6V to +6.25V". There is no Vcc voltage specified in the absolute maximum ratings, so am I right to assume that the aforementioned statement applies to the Vcc pin as well?

QUOTE
Maximum input voltage is just the maximum voltage you can apply without the chip totally melting down. It may or may not function at those ratings - as I think the 'absolute maximum ratings' say something along those lines.



There is no Vcc voltage specified in the absolute maximum ratings, so am I right to assume that the aforementioned statement applies to the Vcc pin as well?


QUOTE
Vcc is not considered an input. It is rated at the value you metioned, 2.5V - 3.6V. Inputs pins have a higher range because Atmel made them easier to interface with micros. Now, a 5V micro can connect directly to a Dataflash, you still need to give the Dataflash 3.3V for Vcc, but the signal lines go directly from micro to Dataflash. If you look at MultiMediaCards (MMC), they only allow 3.3V on input pins, so it is necessary to convert the voltages of the output pin of the microcontrollers from 5V to 3.3V, assuming you are running a 5V processor. If you are running a 3.3V processor, no big deal.

In all, I would not suggest powering your Dataflash at 5V, but it is ok to interface it with a 5V micro.



QUOTE
I would recommend a 100 ohm or maybe alittle smaller resistor in series on each of the lines between the micro to the dataflash.

micro vcc = 5v, dataflash vcc =3.3v

the micro will sense a 3.3v level as a 1 no problem. 100 ohm should be good.


QUOTE
Dataflash i/o can endure 5v but vcc must be 2.5-3.6v
To generate 3.3v I suggest use special voltage regulator chip. Divided from 5v by resistor or three diodes is not a good idea even though that is suggested by ATMEL applycation note.Because the consume current differs greatly betwen working(especialy writting) and idle.


I failed to mention that the reason I asked this question was because I want to run the Butterfly off 5 volts, so I can't really make any big changes to the circuit.

A possible solution that occurred to me would be to lift the DataFlash's Vcc pin off the PCB and connect it directly to the battery's positive terminal with a short length of wire. This way you could interface 5V logic to the Butterfly and still have the DataFlash operate within its specs.

Still, I wonder why Atmel didn't specify a maximum Vcc voltage in the datasheet ...

Edit: I've just noticed that in the technical specs for the Butterfly[1], it says that the supply voltage range when using external power is 3.1V-4.5V ...

[1]http://www.atmel.com/dyn/resources/prod_documents/doc4271.pdf, page 29



AVR_Admin- 05-09-2006
BUTTERFLY RS232 CONNECTIONS:

I was wondering if anybody else had same/similar issues or can recommend something to solve my problem. I am trying to get an AVR butterfly board to communicate over RS232 and/or ISP. I've read everything I can find on the hardware and it doesn't seem to be anything special, but I cannot get it to talk any way. It happily feeds off STK500 power and runs its little demo program, but AVR Studio will not enter programming mode regardless of what clock settings I use. Also, trying to communicate with it over serial connection (to enter name in the demo application) does not give any results. The board seems to be waiting for connection, terminal is sending stuff over, but nothing is happening. I've checked and double-checked all cables and wiring and even tried the second board thinking that this one is defective, but still no luck.

I would greatly appreciate any useful advice/suggestion

QUOTE
I just got the butterfly to dork around with a little while ago and came across some initial problems with sending a name to it with the uart. So I know it can be frustrating if it doesn't work right away. Have you soldered in the header pins yet? This is essential if you want to get a good conection, if you are a soldering freak (like myself) this tedious task will be quite enjoyable.


QUOTE
Anyways, spend some time and make a nice cable with a D-shell and a header connector and be sure to triple check the wiring (it is really not clear which wires cross in the ap-note). Double check your hyperterminal settings...yadda, yadda ...and be patient.


I actually have the headers soldered, but will check on the connection again (there must be something systematically wrong with my setup for two boards not to work). What also buffles me is the fact that I cannot connect to it over SPI as well. I guess I just have to take one step at a time to see where I've screwed up.

QUOTE
I've connected Butterfly to PonyProg2000 without problems via ISP and LPT programmer for it. Only one problem I found, that my programming cable is too long (about1,5 meeters). With other Megas I has some problem, but coupling capacitors helps well.

I powered Butterfly from programmer with 5 volts.

QUOTE
To test the rs232 look for about -10V on both the Tx and Rx lines, If one is negative but the other is not then suspect crossed over.


OK, I've got it working with both RS232 and SPI.

1. For serial communication problem was in terminal configuration (it MUST be exactly as described in http://www.avrfreaks.net/filednload.php ... mmies.pdf, including NO flow contol and AUTO detect emulation (I used windows hyperterminal)

2. For SPI to work Auto Power Save Mode MUST be Off. Otherwise it didn't work for me.

As soon as had these things set as described -- it all worked. Hope it helps someone else facing same chalenges.

QUOTE

Quite often the fact that the Butterfly does NOT echo back characters to a Terminal Program fools many into thinking that it is not working.





AVR_Admin- 05-09-2006
BUTTERFLY LCD SCREEN:

I am currently working on a project to creat a ultrasonic range finder measuring device. I have been writing a program that uses a AVR ATmeg 169 microcontroler to impliment a SRF08 Range finder. I am have been able to compile some code for this project, but I am undable to get my LCD to display on the micro controller to tell me if it is working properly.

Any helpl would be deeply appreciated.

QUOTE
Have you initialised the LCD controller? Do you get anything displayed on the LCD at all? Which language are you programming in? The butterfly source code is available, you could use that as an example.

There are three functions to be accomplished:
1) initialise LCD controller
2) mapping ASCII text to segment buffer
3) interrupt handler to update LCD from buffer



AVR_Admin- 05-09-2006
BUTTERFLY RS232 MODEM SIGNALS:

I've only just realised the ATmega169 doesn't have inputs to take in the other modem serial signals such as Ring Indicator, Data Terminal Ready etc. Is there something I can add on to the butterfly (another IC) that will allow it to receive and process these signals. When I read the specs, being able to connect through serial with an inbuilt rs232 level converter, I thought meant u can connect to it using a modem or anything, but after more careful reading, it only meant I could connect it up to a PC and be able to program the Butterfly over serial


--------------------------------------------------------------------------------
QUOTE
you will need asnother level converter for teh additional signals. Then you can use any free I/O's of the m169. (Though you may want to try and use some of the INT lines for the more important signals)



AVR_Admin- 05-09-2006
OVERWRITING BUTTERFLY BOOTCODE:

I just bought myself a new AVR butterfly. I am pretty new to this one and have a simple question about it. Every samplecode I found on the net starts with

.orig 0x000
jmp RESET

RESET: ldi....

Doesn't that code overwrite the exsisting bootloader-code of the butterfly? I mean, will I still be able use avprog over the UART to upload new programs?

QUOTE
There is no danger of overwriting - the boot loader section is the last 2K of flash memory and is protected by lock bits. I have flashed my butterfly > 50 times with no problems.



Its always good to know that you can't mess up anything
Thanks for answering.


AVR_Admin- 05-09-2006
BUTTERFLY ADC BLOCK DIAGRAM ERROR:

I was looking at the ATMega169 datasheet for my Butterfly. I want to use it to do a single-ended conversion and 2 differential conversions.

According to the ADC block diagram on page 195, pins 0-2 of port F are connected to a negative input MUX. BUT, on page 208 table 90, it seems like only pin 1 and 2 can be used as the negative input with positive inputs from the other ADC pins. Have Atmel made an error and not fully documented this table to include pin 0, or am I missing something important here?

Also, can someone please explain how ADC1 and ADC2 can be both a positive and negative input at the same time? This is from table 90.


QUOTE
If I had to guess, I think that the error is in the block diagram, not in the table. Compare the block diagram and table to those of the Mega64 or other AVRs with programmable ADC gain. The '169 does not have that feature, and those are the slots in the table.

Quote:

Also, can someone please explain how ADC1 and ADC2 can be both a positive and negative input at the same time? This is from table 90.


QUOTE
When I first saw that in an AVR datasheet, I also noted that with puzzlement. Then I realized that making a conversion of the channel against itself would give the offset error for part of the circuitry, which could then be applied to a "normal" conversion.

Note also that the differential channels seem to have a lower (8 bit) typical accuracy, according to the datasheet.


QUOTE
Although it may seem strange, any of the inputs ADC0-ADC2 can be either the positive or negative input to the diff amp. The first differential mux selection (10000) uses ADC1 the (-) input and ADC0 as the (+). Its not that ADC0 was omitted. It's just never used as the negative input (although according to the block diagram it could have been).

On your point about ADC1 and ADC2 being used as both the positive and negative inputs simultaneously - I don't know. It doesn't seem logical. However, if I were to take a wild guess, I would say that this is a single ended conversion selection with gain.

Hopefully someone else has had experience with this setting.


Thanx for replying.

I looked at the other datasheets and yes I see what u're saying about Gain features of the other AVRs that the 169 doesn't have. But can I still use ADC0 as a negative diff input with 1x gain? I'm sort of leaning to the side of 'no' because there's no register values to allow this in the ADMUX register.

I would like to be able to test this and see if it works, but the Butterfly isn't set up to do that yet...I'm working on my hardware schematic and PCB design now and wanted to know what pins to bring out to the PCB so I can use the differential ADC, which brought me to this problem and hence my post here.

I hope there's someone else out there that may have more experience in this. Your help would be greatly appreciated.

CODE
I emailed Atmel about the problem and they said the the block diagram in the 169 datasheet is incorrect. The table is correct ADC0 can NOT be used as a negative input. Mega169 does not include any Gain as well.



AVR_Admin- 05-09-2006
PROGRAMMING BUTTERFLY EEPROM:

I recently got the avr butterfly kit and also built a ATMEL JTAG Ice clone. Now the clone can program the flash, fuse, lock bits properly but it cannot program the eeprom. It says file content differs or somthing like that. I am trying to program a .eep file into the eeprom. The c- compiler is ICCAVR 6.31A.

So I reprogrammed the original code back and used avr prog in studio 4.09 to download my program, again the flash gets programmed but the avrprog software seems to get stuck eternally trying to program the eeprom. Any body experience this before?

QUOTE
Are all the butterflys out there programming eeprom ok? Let me know of your experiences. My butterfly board has an E.S. chip on it. I guess its an engineering sample. Is this a problem with the E.S. m169 chip?


QUOTE
I had similar errors with serial programming (with the internal bootloader) and the normal flash. But the applications work well.
Then i switch to an ISP Dongle and Ponyprog and now i have no more errors.


QUOTE
Has anybody succeeded in using stk500 to program eeprom data into the butterfly. The jtag does not succeed in programming the internal eeprom.





Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.