top of page
Search
camtulasboona

Usb to serial using atmega8: Tips and tricks for improving the speed and reliability of the communic



Watch out: t2313 and 2313, m8 and m88, c128 and m128, etc look very similar but they are in fact quite different chips! For that reason I suggest you type out the name of the chip, that is, instead of t2313 use attiny2313 or m8 use atmega8. Avrdude is smart enough to know what you mean if you type out the full name.


Double check what chip you are using by looking at the top of the chip, these say ATTINY2313 and ATMEGA8 (respectively) the -20PI and -16PC are just the speed ratings and package descriptions so ignore them for now.




Usb to serial using atmega8




This switch tells avrdude where to look for your programmer. If you are using a USB connected device, you can just use -P usb or, leave it out. The programmer automatically knows when the programmer is a USB device.


If you are using a parallel port or serial port programmer, you should use this option to indicate what port the programmer is connected to. 99% of the time its lpt1 (parallel) or com1 (serial) but you can always check it by looking under the Device Manager. Open the System Properties control panel


Get your AVR target board ready to go, we'll be using an attiny2313 in this example but of course you should substitute the chip you're using (in which case the code will probably not do anything). Make sure the device is powered, either by batteries or a wall plug or by the programmer if the programmer can do it.


Figure out what programmer you are using and which port its connected to (in this example I'll be using a usbtinyisp but anything is fine.) Since the usbtinyisp is a USB programmer I can leave off the -P switch.


This means that the programmer couldn't talk to the chip. If you are using a "simple" programmer such as a serial or parallel port bitbang programmer, it could mean the programmer is at fault. Otherwise, it usually means the programmer is OK but it couldnt find the chip.


You'll see that it stops at step 2, once the signature is different than the expected one it stops. This is because code that is compiled for an attiny2313 wont run on an atmega8 (this is true of most microcontrollers, the .hex files are not cross compatible)


Almost 4 years later, I started using AVR microcontrollers again. However, today it is difficult to find a computer that has a parallel port, and thus I needed to revisit this topic of AVR programmers. And I end up building (and buying) the USBasp (Wayback Machine) programmer.


The serial port was a bit more complicated because it implemented the RS-232 protocol, and thus it required a non-trivial hardware. On the other hand, once you had RS-232 implemented, using the serial port became quite simple. In a nutshell, you write bytes at one end, they are transmitted using the RS-232 protocol, and they arrive at the other end.


Page 10 from AVR910 - In-System Programming document shows A Simple Low-cost In-System Programmer. It uses an AT90S1200 microcontroller to do the hardware+software conversion between the RS-232 and UART protocols (coming from the serial port) to the ISP protocol used by AVR microcontrollers.


MAIN CONFUSION:1) I cannot help myself differentiating or relating SPI, RS232 and UART.I know these are used for serial communication between devices but how?(which is used when and why and how)(appropriate hardware for transmitting device and receiving device)


1) To upload your code into AVR chip, you can use ISP interface. That requires you to connect at least 5 pins: SCK, MISO, MOSI, RESET, GND, and optionally VCC (it used to control or supply voltage, but not mandatory, if your board has it's own power supply). All you need is just to wire 6- or 10-pin ISP connector to that pins of your CPU.To begin programming process you need to obtain some programmer device (USBasp, AVRISPmk2, STK500/600 etc.), Also, you can use Arduino board itself as ISP-programmer for external AVR chip, like this: -an-ATTiny13A-using-Arduino-servo-int/Each of programmer model requires it's compatible software (such as PonyProg), for example STK500 and AVRISP programmes could be used directly from Atmel Studio.Also, you can connect ISP to parallel (LPT) port of the PC, and upload firmware using specialized software, such as uniprof


AVR chips have no it's own support for wireless communication, therefore, to do that you need to use some external wireless chip, for example bluetooth, or WiFi, there are a lot of such modules (for example ESP8266). AVR chip communicate with them using USART, sending and receiving simple commands.


The ATmega16U2 chip on your Arduino board acts as a bridge between the computer's USB port and the main processor's serial port. Previous versions of the Uno and Mega2560 had an Atmega8U2. It runs software called firmware (so named because you couldn't change it once it had been programmed in the chip) that can be updated through a special USB protocol called DFU (Device Firmware Update).


The firmware is also located with the Arduino software in the /hardware/arduino/firmwares/arduino-usbserial folder. On OSX, right-click or command-click on the Arduino application and select "show package contents" to find this folder.


To learn about I2C I have implemented a serial EEPROM programmer using the same AVR based ATMega8 as my old school paralled programmer. I2C, like SPI, is nice because all signalling between the microcontroller and the memory is along only a handful of wires. This also, at I2C speeds at least, makes it slower but adequate for many applications like data logging.


I2C, as a fairly modern tech, is extremely well documented with many good tutorials available on the subject. I got a lot of information from this nice tutorial which roughly describes I2C and how I2C is implemented in the AVR microcontrollers. The serial EEPROM I had to hand, an AT24C256 (PDF), was my target I2C device. This is a 32KByte serial memory in an 8 pin PDIP package. Quite a bit smaller then the parallel version of the same capacity my 6809 uses!


Though the bus is radically different, many things about this serial EEPROM are the same as its parallel sibling, including having a 64byte page size and the rough time taken to write a page (5ms as opposed to 10ms).


Because these EEPROMs are so similar to the parallel version, the programmer code can be similar. The same commands and mechanisms, like upblock, dumphex etc as divised for the parallel programmer can be used with the serial memory. Only the implementation of the functions which read and write bytes and pages to the memory need be different.


Once your ATmega8 has the optiboot bootloader on it, you can upload programs using the Arduino UNO board serial communication pins. The UNO board has a USB-to-serial convertor chip (ATmega8U2) built in.


The AVR is a modified Harvard architecture machine, where program and data are stored in separate physical memory systems that appear in different address spaces, but having the ability to read data items from program memory using special instructions.


Flash, EEPROM, and SRAM are all integrated onto a single chip, removing the need for external memory in most applications. Some devices have a parallel external bus option to allow adding additional data memory or memory-mapped devices. Almost all devices (except the smallest TinyAVR chips) have serial interfaces, which can be used to connect larger serial EEPROMs or flash chips.


In most variants of the AVR architecture, this internal EEPROM memory is not mapped into the MCU's addressable memory space. It can only be accessed the same way an external peripheral device is, using special pointer registers and read/write instructions, which makes EEPROM access much slower than other internal RAM.


AVRDUDE (AVR Downloader/UploaDEr) runs on Linux, FreeBSD, Windows, and Mac OS X, and supports a variety of in-system programming hardware, including Atmel AVRISP mkII, Atmel JTAG ICE, older Atmel serial-port based programmers, and various third-party and "do-it-yourself" programmers.[17]


The Program and Debug Interface (PDI) is an Atmel proprietary interface for external programming and on-chip debugging of XMEGA devices. The PDI supports high-speed programming of all non-volatile memory (NVM) spaces; flash, EEPROM, fuses, lock-bits and the User Signature Row. This is done by accessing the XMEGA NVM controller through the PDI interface, and executing NVM controller commands. The PDI is a 2-pin interface using the Reset pin for clock input (PDI_CLK) and a dedicated data pin (PDI_DATA) for input and output.[18]


High-voltage serial programming (HVSP)[21] is mostly the backup mode on smaller AVRs. An 8-pin AVR package does not leave many unique signal combinations to place the AVR into a programming mode. A 12-volt signal, however, is something the AVR should only see during programming and never during normal operation. The high voltage mode can also be used in some devices where the reset pin has been disabled by fuses.


The JTAGICE mkII debugging tool supports on-chip debugging (OCD) of AVRs with SPI, JTAG, PDI, and debugWIRE interfaces. The debugWire interface enables debugging using only one pin (the Reset pin), allowing debugging of applications running on low pin-count microcontrollers.


The JTAGICE mkII connects using USB, but there is an alternate connection via a serial port, which requires using a separate power supply. In addition to JTAG, the mkII supports ISP programming (using 6-pin or 10-pin adapters). Both the USB and serial links use a variant of the STK500 protocol.


The AVR ONE! is a professional development tool for all Atmel 8-bit and 32-bit AVR devices with On-Chip Debug capability. It supports SPI, JTAG, PDI, and aWire programming modes and debugging using debugWIRE, JTAG, PDI, and aWire interfaces.[41]


The very popular AVR Butterfly demonstration board is a self-contained, battery-powered computer running the Atmel AVR ATmega169V microcontroller. It was built to show off the AVR family, especially a then new built-in LCD interface. The board includes the LCD screen, joystick, speaker, serial port, real time clock (RTC), flash memory chip, and both temperature and voltage sensors. Earlier versions of the AVR Butterfly also contained a CdS photoresistor; it is not present on Butterfly boards produced after June 2006 to allow RoHS compliance.[42] The small board has a shirt pin on its back so it can be worn as a name badge. 2ff7e9595c


3 views0 comments

Recent Posts

See All

Download do Primo

Baixar Primo: o melhor aplicativo de comunicação Você quer manter contato com seus amigos, familiares e colegas em todo o mundo? Você...

Comments


bottom of page