watterott / ATmega328PB-Testing

Atmel/Microchip ATmega328PB support for Arduino IDE
https://learn.watterott.com
76 stars 61 forks source link

Optiboot PB loader on Nano Clone no worky #45

Closed zdravke closed 5 years ago

zdravke commented 5 years ago

I've burnt optiboot_m328PB.hex with avrdude on Nano clone with Atmega328PB with another Nano as ISP and there were no errors. However, nothing works. Tried optiboot_m328pb_blink.hex which also burns fine, but led does not blink. Burning back m328P bootloader works fine.

Arduino IDE also cannot upload anything on PB variant even though Wattuino boards package was installed. Any ideas what I'm doing wrong?

zdravke commented 5 years ago

C:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude -P com12 -b 19200 -c avrisp -p m328pb -e -v -C avrdude.conf -U flash:w:optiboot_m328pb.hex

avrdude: Version 6.3-20171130 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "avrdude.conf"

     Using Port                    : com12
     Using Programmer              : avrisp
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega328PB
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PC2
     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        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel AVR ISP
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9516 (probably m328pb) avrdude: safemode: lfuse reads as FF avrdude: safemode: hfuse reads as DA avrdude: safemode: efuse reads as 5 avrdude: erasing chip avrdude: reading input file "optiboot_m328pb.hex" avrdude: input file optiboot_m328pb.hex auto detected as raw binary avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% 36.12s

avrdude: 32768 bytes of flash written avrdude: verifying flash memory against optiboot_m328pb.hex: avrdude: load data flash data from input file optiboot_m328pb.hex: avrdude: input file optiboot_m328pb.hex auto detected as raw binary avrdude: input file optiboot_m328pb.hex contains 32768 bytes avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 19.88s

avrdude: verifying ... avrdude: 32768 bytes of flash verified

avrdude: safemode: lfuse reads as FF avrdude: safemode: hfuse reads as DA avrdude: safemode: efuse reads as 5 avrdude: safemode: Fuses OK (E:05, H:DA, L:FF)

avrdude done. Thank you.

awatterott commented 5 years ago

You also have to write the fuse bits.

Extended: 0xFD
High:     0xD6
Low:      0xFF
Lockbits: 0xCF (LPM and SPM prohibited in Boot Section)

avrdude -c avrisp -p atmega328p -e -U flash:w:optiboot_m328p.hex:i -U lfuse:w:0xFF:m -U hfuse:w:0xD6:m -U efuse:w:0xFD:m -U lock:w:0xCF:m
zdravke commented 5 years ago

Thanks, it works now:) Do you know how to send 16bit PWM to other pins, except for pin 9 and 10?

awatterott commented 5 years ago

Have a look in the datasheet for OCxx pins. These are output compare pins from the timers and can generate PWM signals.