Menu

ATtiny202 Blink not working on all PortA

Help
Jberg
2026-09-13
3 days ago
1 2 > >> (Page 1 of 2)
  • Jberg

    Jberg - 2026-09-13

    Hello everyone,

    Here's a case of Blink test on a ATtiny202 that is working fine with Arduino on all separate PortA,0,1,2,3,4
    (except the PortA map is different dosen't match Microchips datasheet document :
    2019 Microchip Technology Inc. Complete Datasheet DS40002159A-page 15 show on the screen cap below)

    with GCBasic dosen't work at all on all individual PortA pin (with a successfully compiled message)

    Here's the listing of Arduino when compiling follow by GCBasic compiling

    '---------------------------------------------------------------------
    ' Microchips ATtiny202/402 Datasheet  2019 Microchip Technology Inc. Complete Datasheet DS40002159A-page 15
    '---------------------------------------------------------------------
    
    
    '---------------------------------------------------------------------
    ' Arduino ATtiny202 Blink Test  Upload Using Programmer
    '---------------------------------------------------------------------
    
    Sketch uses 456 bytes (22%) of program storage space. Maximum is 2048 bytes.
    Global variables use 10 bytes (7%) of dynamic memory, leaving 118 bytes for local variables. Maximum is 128 bytes.
    "C:\Users\jackc\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1/python3" -u "C:\Users\jackc\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.11/tools/prog.py"  -t uart -u COM6 -b 57600 -d attiny202 --fuses 0:0b00000000 2:0x02 6:0x04 7:0x00 8:0x00 "-fC:\Users\jackc\AppData\Local\arduino\sketches\2B4FE903EBF800AD7AF4DD65A9BB73D0/sketch_sep12a.ino.hex" -a write -v
    SerialUPDI
    UPDI programming for Arduino using a serial adapter
    Based on pymcuprog, with significant modifications
    By Quentin Bolsee and Spence Konde
    Version 1.3.1 - Aug 2025
    Using serial port COM6 at 57600 baud.
    Target: attiny202
    Set fuses: ['0:0b00000000', '2:0x02', '6:0x04', '7:0x00', '8:0x00']
    Action: write
    File: C:\Users\jackc\AppData\Local\arduino\sketches\2B4FE903EBF800AD7AF4DD65A9BB73D0/sketch_sep12a.ino.hex
    pymcuprog.programmer - INFO - Setting up programming session for 'attiny202'
    pymcuprog.deviceinfo.deviceinfo - INFO - Looking for device attiny202
    pymcuprog.serialupdi.physical - INFO - Opening port 'COM6' at '57600' baud
    pymcuprog.serialupdi.link - INFO - STCS 08 to 0x03
    pymcuprog.serialupdi.link - INFO - STCS 06 to 0x02
    pymcuprog.serialupdi.link - INFO - LDCS from 0x00
    pymcuprog.serialupdi.link - INFO - UPDI init OK
    pymcuprog.serialupdi.link - INFO - STCS 06 to 0x02
    pymcuprog.serialupdi.link - INFO - Setting UPDI clock to 4 MHz
    pymcuprog.serialupdi.link - INFO - STCS 03 to 0x09
    pymcuprog.serialupdi.physical - INFO - Switching to '57600' baud
    pymcuprog.serialupdi.application - INFO - SIB: 'tinyAVR P:0D:0-3M2 (01.59B14.0)'
    pymcuprog.serialupdi.application - INFO - Device family ID: 'tinyAVR'
    pymcuprog.serialupdi.application - INFO - NVM interface: 'P:0'
    pymcuprog.serialupdi.application - INFO - Debug interface: 'D:0'
    pymcuprog.serialupdi.application - INFO - PDI oscillator: '3M2'
    pymcuprog.serialupdi.application - INFO - Extra info: '(01.59B14.0)'
    pymcuprog.serialupdi.application - INFO - Using 16-bit UPDI
    pymcuprog.serialupdi.link - INFO - LDCS from 0x00
    pymcuprog.serialupdi.application - INFO - PDI revision = 0x02
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.application - INFO - Entering NVM programming mode
    pymcuprog.serialupdi.link - INFO - LDCS from 0x07
    pymcuprog.serialupdi.application - INFO - Apply reset
    pymcuprog.serialupdi.link - INFO - STCS 59 to 0x08
    pymcuprog.serialupdi.application - INFO - Release reset
    pymcuprog.serialupdi.link - INFO - STCS 00 to 0x08
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.nvm - INFO - No specific initializer for this provider
    Pinging device...
    pymcuprog.programmer - INFO - Reading device ID...
    pymcuprog.serialupdi.application - INFO - SIB: 'tinyAVR P:0D:0-3M2 (01.59B14.0)'
    pymcuprog.serialupdi.application - INFO - Device family ID: 'tinyAVR'
    pymcuprog.serialupdi.application - INFO - NVM interface: 'P:0'
    pymcuprog.serialupdi.application - INFO - Debug interface: 'D:0'
    pymcuprog.serialupdi.application - INFO - PDI oscillator: '3M2'
    pymcuprog.serialupdi.application - INFO - Extra info: '(01.59B14.0)'
    pymcuprog.serialupdi.application - INFO - Using 16-bit UPDI
    pymcuprog.serialupdi.link - INFO - LDCS from 0x00
    pymcuprog.serialupdi.application - INFO - PDI revision = 0x02
    pymcuprog.serialupdi.link - INFO - LDCS from 0x0B
    pymcuprog.serialupdi.application - INFO - Device ID from pyupdi = '1E9123' rev 'B'
    pymcuprog.nvm - INFO - Device ID: '1E9123'
    pymcuprog.nvm - INFO - Device revision: 'B'
    pymcuprog.nvm - INFO - Device serial number: 'b'51523131382045e22d74''
    Ping response: 1E9123
    Setting fuse 0x0=0x0
    Writing literal values...
    pymcuprog.programmer - INFO - Write...
    pymcuprog.programmer - INFO - Writing 1 bytes of data to fuses...
    pymcuprog.programmer - INFO - Write complete.
    Verifying literal values...
    pymcuprog.programmer - INFO - Reading 1 bytes from fuses...
    pymcuprog.programmer - INFO - Verifying...
    Action took 0.04s
    Setting fuse 0x2=0x2
    Writing literal values...
    pymcuprog.programmer - INFO - Write...
    pymcuprog.programmer - INFO - Writing 1 bytes of data to fuses...
    pymcuprog.programmer - INFO - Write complete.
    Verifying literal values...
    pymcuprog.programmer - INFO - Reading 1 bytes from fuses...
    pymcuprog.programmer - INFO - Verifying...
    Action took 0.04s
    Setting fuse 0x6=0x4
    Writing literal values...
    pymcuprog.programmer - INFO - Write...
    pymcuprog.programmer - INFO - Writing 1 bytes of data to fuses...
    pymcuprog.programmer - INFO - Write complete.
    Verifying literal values...
    pymcuprog.programmer - INFO - Reading 1 bytes from fuses...
    pymcuprog.programmer - INFO - Verifying...
    Action took 0.04s
    Setting fuse 0x7=0x0
    Writing literal values...
    pymcuprog.programmer - INFO - Write...
    pymcuprog.programmer - INFO - Writing 1 bytes of data to fuses...
    pymcuprog.programmer - INFO - Write complete.
    Verifying literal values...
    pymcuprog.programmer - INFO - Reading 1 bytes from fuses...
    pymcuprog.programmer - INFO - Verifying...
    Action took 0.04s
    Setting fuse 0x8=0x0
    Writing literal values...
    pymcuprog.programmer - INFO - Write...
    pymcuprog.programmer - INFO - Writing 1 bytes of data to fuses...
    pymcuprog.programmer - INFO - Write complete.
    Verifying literal values...
    pymcuprog.programmer - INFO - Reading 1 bytes from fuses...
    pymcuprog.programmer - INFO - Verifying...
    Action took 0.05s
    Finished writing fuses.
    Chip/Bulk erase,
    Memory type eeprom is conditionally erased (depending upon EESAVE fuse setting)
    Memory type flash is always erased
    Memory type lockbits is always erased
    ...
    pymcuprog.programmer - INFO - Erase...
    pymcuprog.serialupdi.nvm - INFO - Chip erase using NVM CTRL
    Erased.
    Action took 0.02s
    Writing from hex file...
    Writing flash...
    pymcuprog.programmer - INFO - Write...
    pymcuprog.programmer - INFO - Writing 456 bytes of data to flash...
    [                                                  ]
    [======                                            ] 1/8
    [============                                      ] 2/8
    [==================                                ] 3/8
    [=========================                         ] 4/8
    [===============================                   ] 5/8
    [=====================================             ] 6/8
    [===========================================       ] 7/8
    [==================================================] 8/8
    pymcuprog.programmer - INFO - Write complete.
    Action took 0.23s
    Verifying...
    pymcuprog.programmer - INFO - Reading 456 bytes from flash...
    pymcuprog.programmer - INFO - Verifying...
    Verify successful. Data in flash matches data in specified hex-file
    Action took 0.09s
    pymcuprog.serialupdi.application - INFO - Leaving NVM programming mode
    pymcuprog.serialupdi.application - INFO - Apply reset
    pymcuprog.serialupdi.link - INFO - STCS 59 to 0x08
    pymcuprog.serialupdi.application - INFO - Release reset
    pymcuprog.serialupdi.link - INFO - STCS 00 to 0x08
    pymcuprog.serialupdi.link - INFO - STCS 0C to 0x03
    pymcuprog.serialupdi.physical - INFO - Closing port 'COM6'
    
    
    
    
    '---------------------------------------------------------------------
    ' GCBASIC 
    '
    ' ATtiny202 Blink
    '---------------------------------------------------------------------
    #chip tiny202, 20
    
    
    ' Set pin direction to output
    Dir PORTA.0 Out
    
    ' Main program loop
    Do Forever
    
        PORTA.0 = 1
        Wait 500 ms
    
        PORTA.0 = 0
        Wait 500 ms
    Loop
    
    
    '---------------------------------------------------------------------
    ' GCBasic  TERMINAL
    '---------------------------------------------------------------------
    
    GCBASIC (2026.09.08 (Windows 64 bit) : Build 1634)
    
    Compiling: ATtiny202 Blink Test.gcb
    Program compiled successfully (Compile time: 3.690 seconds)
    
    Summary:
         Compiled:
              Program lines: 8
              Subroutines:  User: 0 ; System: 2 of 501 ; Total: 2
         Chip resource usage:
              Program Memory: 90/1024 words (8.79%)
              RAM: 0/128 bytes (0%)
              OSC: 20Mhz (Internal oscillator)
    
    Assembling program using GCASM
    Program assembled successfully (Assembly time: 0.071 seconds)
              Code Segment: 95/1024 words (9.28%)
    
    Downloading program ...AVRDUDE UPDI Friend
    Reading 180 bytes for flash from input file ATtiny202 Blink Test.hex
    Writing 180 bytes to flash
    Writing | ################################################## | 100% 0.16 s 
    Reading | ################################################## | 100% 0.04 s 
    180 bytes of flash verified
    
    Avrdude done.  Thank you.
    Programming successful
    Done
    
    
    
    
    --------------------------------------------------------------------
    
    Programmer Editor Setup
    
    Name:
    AVRDUDE UPDI Friend
    
    File:
    C:\GCstudio\AVRDUDE\avrdude.exe
    
    Command Line Parameters
    avrdude.exe -c serialupdi -p t202 -P COM6 -U flash:w:"%filename%":a
    
    Working Directory
    C:\GCstudio\AVRDUDE
    

    Thanks for any comments this is not urgent (I will survive)

     
  • Jberg

    Jberg - 2026-09-13

    on Arduino when 'digitalWrite(2, HIGH);' it mean PortA.2 on Pin 4

    here the list

    PORT PIN#
    PA0 = 2
    PA1 = 3
    PA2 = 4
    PA3 = 5
    PA4 = 7
    PA5 = 6 UPDI

     
  • Anobium

    Anobium - 2026-09-13

    Found an issue in the memory clear down routine,

    Now changed AVR memory clear down: use native SRAM_START symbol instead of CHIP_INTERNAL_SRAM_START.

    Please replace the attached into your GCStudio\GCBASIC\include\lowlevel folder replacing the existing file.

     
  • Jberg

    Jberg - 2026-09-13

    Many thanks , I did replace system.h still no blink on any pins
    added the build files.

     
  • Anobium

    Anobium - 2026-09-13

    Let us check it is the RAM clear down. I have remove the RAM clear down from the attached. Please test.

     
  • Jberg

    Jberg - 2026-09-13

    The code modification you made work correctly with all PortA.# assign to the right PortA location
    according to Microchips datasheet. (not as the Arduino )

    ounce or twice an error message come up, then I had to
    switch Off/On the usb port of the Adafruit HV UPDI then re-select 'Make Hex and Flash'

    Did several test on all individual pin# of PortA, and the blinking process work just fine.
    My next step it's to use the CCL table and see if it's working ok.

    Many thanks Evan for your great help and support.

     
  • Anobium

    Anobium - 2026-09-13

    Great. We know the root cause - now to fix.

    I need the ASM from the Ardunio blink test. If not avaialbe the HEX. I will figure this out.

    Need to sort this for other using the same chipfamily.


    Will discuss the pictures after we have this sorted.

     
  • Anobium

    Anobium - 2026-09-13

    I need more info from you.

    Using the system.h from https://sourceforge.net/p/gcbasic/discussion/579126/thread/fbfc03c6e0/459d/attachment/system.h Please change the compiler option to use AVRASM - this will help me understand if this is a GCASM issue.

    You may have guessed. I do not have this chip.

     
  • Jberg

    Jberg - 2026-09-13

    here's ZIP of Blink_copy_A.ino.cpp with all the generated files

    With the compiler set at AVRASM I tested all PortA.1,2,3,6,7 with Blink and it's work fiine, no need to toggle the USB port switch. (used system.h from link)

     

    Last edit: Jberg 2026-09-13
    • Anobium

      Anobium - 2026-09-13

      Thank you for the archive.

      Did you revert to the previous system.h ? i dont think so.

       
  • Jberg

    Jberg - 2026-09-13

    kept the one from link

     
    • Anobium

      Anobium - 2026-09-13

      And, that system.h worked when compiled with AVRASM? oh

       
  • Anobium

    Anobium - 2026-09-13

    Would you be able to send me a Tiny202? I want to proper understand what is going on.

    Thank you.

     
  • Jberg

    Jberg - 2026-09-13

    sorry for the delay, yes it worked when compiled with AVRASM

     
  • Jberg

    Jberg - 2026-09-13

    did the blink test on all porta.1.2.3.6.7 with system.h from the link, and AVRASM and it's work fine
    no need to switch the adafruit HV programmer off/on or to reboot GCBasic

    re-did the same as above, except with GCASM and it's not working (with Programming successful)

     
  • Jberg

    Jberg - 2026-09-13

    anytime I'll send you some attiny202 to study, on monday I'll prepare it ready to ship.

     

    Last edit: Jberg 2026-09-13
    • Anobium

      Anobium - 2026-09-13

      Thank you.

      You know this one is not easy. Why? It is not fixed. :-)

      Looking forward to getting little package. :-)

       
  • Jberg

    Jberg - 2026-09-13

    Ah! but you've got the talent to solve it

     
  • Jberg

    Jberg - 2026-09-13

    I'll send you couples of 2 different batch the one I have here (came from Aliexpress) and the one from here, I'll mark each pcb so you can differentiate them on the bench.

     

    Last edit: Jberg 2026-09-14
  • Anobium

    Anobium - 2026-09-13

    Also, send me ASM and HEX produced when using GCASM and the same files when using AVRASM. I can disaamble to see any differences.

     
  • Jberg

    Jberg - 2026-09-13

    no problem I will.

     
  • Jberg

    Jberg - 2026-09-13

    here's GCASM + AVRASM and the system.h used when compiling

     
  • Jberg

    Jberg - 2026-09-13

    for shipping are you able to solder header, (soldering iron) if not I'll send with header on the pcb's

     
    • Anobium

      Anobium - 2026-09-14

      I can do some soldering. :-)

      Mark as a gift!!! As it is.

       
  • Jberg

    Jberg - 5 days ago

    If this can help in any way.
    I did some CCL coding to verify both side Arduino/GCBasic AVRASM compiler
    on Arduino I've got a frequency divider by 2 working fine then with GCBasic it compile the code
    send it to the chip, but not running at all seem to be stock

    Both program consist of the same registers setup only for the CCL .

    Here I send you both builds and misc files detailing the ic pinout that I used for either program
    your package is in transit.

     
    👍
    1
1 2 > >> (Page 1 of 2)

Log in to post a comment.