ATMega32 USBasp no programado

1

No uso Arduino solo tratando de programar un ATMega32 simple usando USBASP. Recibiendo este mensaje:

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x0c
avrdude: verification error; content mismatch

avrdude done.  Thank you.

Explicación :

Uso una placa de desarrollo AVR con 8.00:

ParaquelaetiquetadelmodeloAVRseamásclara,tambiénhehechoestafoto( foto )

Para programar el microcontrolador, uso un USBASP. El cristal del programador es 12.0 MHz (aunque podría no ser relevante).

InstaléAvrdudeenubuntuyescribíelsiguienteprograma:

//main.c#defineF_CPU8000000UL#include<avr/io.h>#include<util/delay.h>intmain(void){DDRD=255;PORTD=255;DDRC=255;while(1){PORTC=255;_delay_ms(200);PORTC=0;_delay_ms(200);}return0;}

Luegocompilóycreóunarchivohex:

avr-gcc-w-Os-DF_CPU=8000000UL-mmcu=atmega32-c-omain.omain.cavr-gcc-w-mmcu=atmega32main.o-omainavr-objcopy-Oihex-R.eeprommainmain.hex

Hastaahora,elarchivomain.hexsecreacorrectamente.

Luego,intentandocargarloenelmicrocontrolador:

sudoavrdude-pm32-cusbasp-B8-v-e-u-Uflash:w:main.hex

Ylasalidaesdecepcionante.Merefieroalaúltimaparte:

avrdude:verifying...avrdude:verificationerror,firstmismatchatbyte0x00000x00!=0x0cavrdude:verificationerror;contentmismatchavrdudedone.Thankyou.

Elmensajecompletoes:

avrdude:Version6.0.1,compiledonOct212013at15:55:32Copyright(c)2000-2005BrianDean,http://www.bdmicro.com/Copyright(c)2007-2009JoergWunschSystemwideconfigurationfileis"/etc/avrdude.conf"
         User configuration file is "/home/me/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : usbasp
         Setting bit clk period        : 100.0
         AVR Part                      : ATmega32
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
           flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: set SCK frequency to 8000 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9502
avrdude: erasing chip
avrdude: set SCK frequency to 8000 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (162 bytes):

Writing | ################################################## | 100% 0.15s

avrdude: 162 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 162 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.10s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x0c
avrdude: verification error; content mismatch

avrdude done.  Thank you.

Esta es la forma en que conecté el microcontrolador al descargar el archivo hex :

Cuandoverificolacomunicación,pareceestarbien:

sudoavrdude-pm32-cusbasp-t

Larespuesta:

avrdude:warning:cannotsetsckperiod.pleasecheckforusbaspfirmwareupdate.avrdude:AVRdeviceinitializedandreadytoacceptinstructionsReading|##################################################|100%0.00savrdude:Devicesignature=0x1e9502avrdude>

Entonces,¿quéestámal?¿Quéhacer?

Parecequenohaynadaprogramado.Locomprobéconunadaptadorde5VDC( foto ) y una placa de pruebas con LED y un condensador. Conectar el LED a VCC lo enciende ( foto ) que muestra que el LED está funcionando. La conexión a cualquier pin del puerto D no enciende el LED ( foto ) que se conecta a algunos pines del puerto C a su vez en el LED ( foto ) y algunos no ( photo ). Pero no hay parpadeo. Tenga en cuenta que estoy utilizando un chip virgen ATMega32.

Actualizar

Inspirado en este sitio web (por cierto, no sé alemán!) y algunos otros, finalmente utilicé el siguiente comando:

sudo avrdude -p m32 -c usbasp -v -b 19200 -B5 -e -U flash:w:main.hex -U lfuse:w:0xe4:m -U hfuse:w:0x99:m

Respuesta:

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/me/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping
     Using Port                    : usb
     Using Programmer              : usbasp
     Overriding Baud Rate          : 19200
     Setting bit clk period        : 5.0
     AVR Part                      : ATmega32
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
       flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
       calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

     Programmer Type : usbasp
     Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: set SCK frequency to 187500 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9502
avrdude: safemode: lfuse reads as E4
avrdude: safemode: hfuse reads as 99
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (162 bytes):

Writing | ################################################## | 100% 0.11s

avrdude: 162 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 162 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.07s

avrdude: verifying ...
avrdude: 162 bytes of flash verified
avrdude: reading input file "0xe4"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xe4:
avrdude: load data lfuse data from input file 0xe4:
avrdude: input file 0xe4 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0x99"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x99:
avrdude: load data hfuse data from input file 0x99:
avrdude: input file 0x99 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: lfuse reads as E4
avrdude: safemode: hfuse reads as 99
avrdude: safemode: Fuses OK (H:FF, E:99, L:E4)

avrdude done.  Thank you.

¡Parece que funciona!

Ahora, todos los pines en portD encienden el LED brillante y el pin C0 , C1 , C6 y C7 parpadean mientras que C2 , C3 , C5 dan tenue pero la luz constante al LED y C4 no enciende el LED en absoluto.

Sin embargo, estoy muy feliz de haber escrito algo en el chip, ¿podría alguien explicar lo que ha sucedido?

    
pregunta barej

2 respuestas

-1

Parece que el problema estaba en baudios. "-b 19200" fue la solución.

Un promt estaba en línea: "avrdude: advertencia: no se puede establecer el período de sck. compruebe la actualización del firmware de usbasp".

    
respondido por el Tester
-1

Tuve el mismo problema y cambiar el lfuse a E4 lo solucionó! Creo que 1Mhz puede ser demasiado lento para el programador y la configuración a 8Mhz lo corrige.

    
respondido por el user84151

Lea otras preguntas en las etiquetas