Fattoresaimon / I2CEncoderMini

GNU General Public License v3.0
32 stars 7 forks source link

INT pin not working #5

Open nburobotics opened 3 years ago

nburobotics commented 3 years ago

I assembled 4 pieces of I2CEncoderMini_V1.1 and uploaded the HEX file directly. I've got everything working except the INT pin. I'm using the Basic_with_Callbacks sketch. I'm trying to read the configuration and it is: interrupt config is 255 ID code is 57 version is 17 It seems to me that the INT pin never goes LOW regardless of "i2cEncoderMiniLib::IPUP_ENABLE" or IPUP_DISABLE. Is there something else around the proper use of the INT?

Fattoresaimon commented 3 years ago

Hello, The int pin is also the UPDI pin used for programming. You have also to flash the fuse bit in order to change the UPDI pin to GPIO. In atmel studio there is a checkbox where you can select that field. If you used some DYI programmer probably it will not work, but i'm not sure. I suggest you to use the pickit4 and use directly Atmel studio by loading the elf file.

nburobotics commented 3 years ago

Hello, Thank you Fattoresaimon for your prompt response. I liked very much your encoder solution. I'm working in Linux and I don't have pickit4... I want to share the following solution which works, It uses avrdude (the same used by Arduino to upload):

for test pruposes (UPDI enabled)

avrdude -C avrdude.conf -v -p attiny402 -c jtag2updi -P /dev/ttyUSB0 -Ufuse2:w:0x02:m -Ufuse6:w:0x04:m -Ufuse8:w:0x00:m -Uflash:w:I2CEncoderMini.hex for "production" purposes (GPIO enabled, UPDI locked) avrdude -C avrdude.conf -v -p attiny402 -c jtag2updi -P /dev/ttyUSB0 -Ufuse2:w:0x02:m -Ufuse5:w:0xc1:m -Ufuse6:w:0x04:m -Ufuse8:w:0x00:m -Ulock:w:0x00:m -Uflash:w:I2CEncoderMini.hex
Fattoresaimon commented 3 years ago

Hello, So at the end was the fuse bit right? Pay attention that in case of UPDI disabled you need to give the 12V pulse to revert back to UPDI. Thank you for sharing your solution! i think it will be useful for some other user. Thank you, Simone

speedcrafter442 commented 3 years ago

Hello, I tried the suggestion from nburobotics but I can't find the EncoderMini via i2c after the flash.

Result from flash: C:\avrdude>avrdude -v -p attiny402 -c jtag2updi -P com1 -Ufuse2:w:0x02:m -Ufuse6:w:0x04:m -Ufuse8:w:0x00:m -Uflash:w:I2CEncoderMini.hex

avrdude: Version 6.3, compiled on Feb 17 2016 at 09:25:53 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\avrdude\avrdude.conf"

     Using Port                    : com1
     Using Programmer              : jtag2updi

JTAG ICE mkII sign-on message: Communications protocol version: 1 M_MCU: boot-loader FW version: 1 firmware version: 6.00 hardware version: 1 S_MCU: boot-loader FW version: 1 firmware version: 6.00 hardware version: 1 Serial number: 00:00:00:00:00:00 Device ID: JTAGICE mkII AVR Part : ATtiny402 Chip Erase delay : 0 us PAGEL : P00 BS2 : P00 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 0 StabDelay : 0 CmdexeDelay : 0 SyncLoops : 0 ByteDelay : 0 PollIndex : 0 PollValue : 0x00 Memory Detail :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
       prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
       fuses          0     0     0    0 no          9    0      0     0     0 0x00 0x00
       fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
       data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
       usersig        0     0     0    0 no         32   32      0     0     0 0x00 0x00
       flash          0     0     0    0 no       4096   64      0     0     0 0x00 0x00
       eeprom         0     0     0    0 no        128   32      0     0     0 0x00 0x00

     Programmer Type : JTAGMKII_PDI
     Description     : JTAGv2 to UPDI bridge
     M_MCU hardware version: 1
     M_MCU firmware version: 6.00
     S_MCU hardware version: 1
     S_MCU firmware version: 6.00
     Serial number:          00:00:00:00:00:00
     Vtarget         : 5.0 V

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.16s

avrdude: Device signature = 0x1e9227 (probably t402) avrdude: NOTE: Programmer supports page erase for Xmega devices. Each page will be erased before programming it, but no chip erase is performed. To disable page erases, specify the -D option; for a chip-erase, use the -e option. avrdude: reading input file "0x02" avrdude: writing fuse2 (1 bytes):

Writing | ################################################## | 100% 0.01s

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

Reading | ################################################## | 100% 0.01s

avrdude: verifying ... avrdude: 1 bytes of fuse2 verified avrdude: reading input file "0x04" avrdude: writing fuse6 (1 bytes):

Writing | ################################################## | 100% 0.01s

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

Reading | ################################################## | 100% 0.01s

avrdude: verifying ... avrdude: 1 bytes of fuse6 verified avrdude: reading input file "0x00" avrdude: writing fuse8 (1 bytes):

Writing | ################################################## | 100% 0.01s

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

Reading | ################################################## | 100% 0.01s

avrdude: verifying ... avrdude: 1 bytes of fuse8 verified avrdude: reading input file "I2CEncoderMini.hex" avrdude: input file I2CEncoderMini.hex auto detected as raw binary avrdude: writing flash (4096 bytes):

Writing | ################################################## | 100% 2.05s

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

Reading | ################################################## | 100% 1.35s

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

avrdude done. Thank you.