Skip to content

Releases: SpenceKonde/megaTinyCore

2.5.0 - A gargantuan update! Lots of new stuff!

18 Dec 11:56
Compare
Choose a tag to compare

Totally Rewritten Wire library

Among other things, it supports DualMode (and master/slave without dual mode), which has been an oft-requested issue.

  • Completely new Wire.h library with exciting features - Thanks to @MX682X!
    • See the Wire library readme for more details.
    • Master + Slave on the same TWI - either using the same pins or in dual mode
    • Support for TWI1 assuming your device has it.
    • Enhanced slave functionality:
      • When set to match multiple addresses, method provided to find which address was used most recently.
      • After the master has read data from the slave, method provided to find out how many bytes were actually read.
      • Slave now has a way to test whether there is currently an ongoing transaction.
        All that, and it uses less flash too!

Serial is better now too!

That's not the only thing that's seen major rewrites: So has Serial - also thanks to @MX682X! These changes aren't as comprehensive, and I did more work here than on Wire.h (where I did virtually nothing other than the documentation). Check out the Serial Reference for more details, but in short

  • Added support for loopback, rs485, open drain mode!!
  • Added support for using event input instead of the RX pin (Untested)
  • Even added support for MSPI and synch (clocked) mode
  • Reimplemented ISRs in assembly, saving up to 1k of flash, and improving execution time such that you could receive bursts of characters at the maximum baud rate and not miss characters.
  • Adjusted serial buffer size 512b and 1k parts by adding an intermediate 32b serial buffer size.
  • Hoped for size improvements didn't materialize, but the assembly was enough to keep it from getting too bloated, at least.

Other new features:

  • Expanded Event library. Greatly Improved functionality for portable code/libraries
    • Add a set of compatibility defines to make life easier for people porting non-Event-library event-using code to 0/1-series.
  • Actually prevent disabling warnings - -Wall for all! You should not be compiling code with warnings disabled, the vast majority of the time, they're pointing to problems, and in the cases that aren't bugs, they're still a weak point that future bugs could come from (and that people will comment on when you post the code on forums to ask for help). I thought I'd done this a long time ago. Also pull in some warning-related flags from DxCore, including making implicit function declarations error, since the implied declarations when this happens are basically never result in working code, but it occasionally compiles and malfunctions.
  • Major progress on doc enhancements.
  • Using millis or micros (or rather attempting to) when they are unavailable due to millis being disabled, or in the case of micros, RTC used as millis time source, give better errors. You can test for #if defined(millis) and #if defined(micros) to check if those are available.
  • Clarified licence (for one thing, renamed to a .md so people can read it more easily, and know that it's readable if they're on windows) for tinyNeoPixel.
  • Harmonize Comparator.h with DxCore.
    Add avrdude.conf for the 32k 2-series parts which are now becoming available.
  • Port micros and delay-microseconds improvements from DxCore. (delayMicroseconds is more accurate now for the compiletime-unknown delays, and the micros math is faster because it was reimplemented in hand tuned assembly for the most important speeds).
  • SerialUPDI reference now links to it's actual location.
  • Port new attach interrupt from DxCore.
  • Port new printf option from DxCore.
  • Update callbacks to match DxCore 1.4.0, most notably the init_reset_flags(). It will automatically clear reset flags if not overridden, stashing them in GPIOR0 (chosen because has lower overhead than a variable)
  • Platform.txt organization and commenting. Fix issues where defines were missing from lib-discovery phase.
  • Reduce flash footprint of pinMode.
  • Improve methods used to block attempts to use "upload using programmer" when an optiboot board is selected. That confiuration is guaranteed not to work, and we should not do things that we know 100% will not work. We would need a merged output file for this, but the IDE doesn;t make those for us here. (only over on attinycore, where they're not usable and we must go out of our way to delete the damned things)
  • Timers.h shared with DxCore.

Bugfixes

  • Recent change to C++17 required additions to new.cpp and new.h, including sized deallocation (delete) and alignment-aware new and delete operators. The sized deallocation operator is called when existing code that worked before is compiled to the C++ 17 standard; since free() doesn't care about the size, implementation was straightforward. Discussion is ongoing about the aligned new and delete operators, which are also new in this version of the standards. It is likely that we will not support them, since other Arduino cores aren't even building to C++ 17 standard, so if your code needs aligned new/delete, it also won't work anywhere else in Arduino-land. While we are not shy about adding features, we do so only to support hardware features. If conditions change we will revisit this matter.
  • Fix timekeeping on clock speeds only supported with external clocks or tuning when a TCA or TCB is used for millis (it's still busted with the TCD)
  • Correct SYSCFG0 fuse settings when burning bootloader for 2-series parts - they default the reserved bits to 1 not 0, and worse still, setting them to 0 enables a mode we probably don't want.
  • Stop clearing fuse 4 by writing the default values for TCD0 on a 1-series. Now, with great difficulty, we only set that on parts that actually have the type D timer in order to keep our promise of burn bootloader restoring the chip to a fully known state. (well, except for the user row, and EEPROM if you've got it set to retain).
  • Fix theoretical EEPROM.h bug inherited from avr-libc, and keep millis() from losing time when writing more than one byte at a time; update and harmonize with DxCore.
  • Fix 402 with bad signature support.
  • Fix names of .lst and .map
  • Fix bug with disabled millis on tinyNeoPixel libraries not working. Again.

Like I said, this is HUGE.....

2.4.2 - Another bugfix

04 Sep 09:52
Compare
Choose a tag to compare
  • Correct bug with openDrainFast(pin,CHANGE); This was a really nasty one, albeit for a rare corner case. Using CHANGE on a pin that was not on PORTA would alter other settings for other pins seemingly at random instead due to a missing '0x' in a memory offset.
  • Add a whole bunch of missing devices to SerialUPDI.
  • Fix a few examples so they dont throw warnings or demonstrate the wrong way to do things.
  • Instruct linker to use rcall and rjmp when possible (-mrelax). This should always have been the case, and it's absence had significant negative impact that had until now gone unnoticed.
  • Fix burn bootloader with SerialUPDI (#506)
  • Spelling and grammar corrections - thanks! (#508)
  • Fix issue with lowByte() macro and add test sketch to exercise all macros. (#515)
  • Fix issue with some macros caused by switch to C++17 standard. Typeof being an extension, it must be __typeof__ if compiled with standard C++ 17.

2.4.0 - SerialUPDI compatibility fixes, oscillator tuning, and much more!

24 Aug 08:47
Compare
Choose a tag to compare

megaTinyCore 2.4.0 is FINALLY HERE!!!
This brings what is hoped will be a major improvement in compatibility of SerialUPDI (except in turbo mode - turbo mode is slowed significantly by those improvements; turbo mode is not expected to work on all adapters or under all conditions, but rather to offer the absolute highest performance, with the expectation that the user will take care to provide optimum conditions)
We also see some exciting new features:

  • Tuned Internal Oscillator - see the tuning document for more information, this gives a route to overclocking these parts without using an external clock, as well as, on Optiboot configurations, running at 16 MHz when the bootloader was burned at 20 MHz and vise versa. Running the tuning sketch first is strongly recommended. The 2-series parts, at 5v and room temperature will often run at 32 MHz from the internal oscillator (after cranking the calibration way the hell up)! Under similar conditions, 0/1-series parts can sometimes run stabily at 30 MHz from internal, and 24 or 25 MHz should be no problem at all. Obviously, the operating temperature range will be more limited when overclocked in this way (and the internal oscillator can never push the parts quite as far as an external clock can). Be sure to read the tuning documentation if you're interested in using this functionality.
  • New advanced digital I/O functions: openDrain(), openDrainFast() and pinConfigure (first introduced on DxCore) are now available. The first two just provide a wrapper around writing to the direction bit instead of the output bit, allowing it to be used as an "open drain" output, which is very useful for interacting with devices running at a lower voltage, while pinConfigure() provides a single function to set (or leave unchanged) every parameter of the specified pin.
  • Early version of Event.h - however, my initial work with it showed that there are still serious features needed to make this particularly useful. We're getting there though.
  • C++ 17 support and support for libraries that insist on providing only precompiled source code.

There's also a HUGE number of minor and major bugfixes in here this release. Truly too many to list - the changelog is not complete, and even that runs to over 30 bullet-points.

We also now have better CI testing to catch any future problems which result in failures to compile, and look forward to improving this testing further.

2.3.2 - Improved serial-updi, and a bunch of bugfixes, 2-series optiboot

11 May 15:23
Compare
Choose a tag to compare

This is a big release for serial adapters and people who own them - because we've improved the performance of serial-adapter-as-updi by a factor of 8-20 or more! You can now write a full 32k chip in under 5 seconds using just a serial adapter and a resistor (or preferably a schottky diode like a 1N4148). jtag2updi is now a legacy programming tool, we do not recommend using it unless the serial adapter method is for some reason unsuitable (in which case one wonders why jtag2updi would be more suitable, but that's another issue...)
We also introduce the 2-series versions of Optiboot, in case anyone wants to use your serial adapter like that, instead of as a UPDI programmer.....
Keywords.txt now includes all the register names from the datasheet (thanks @MCUdude )
Optiboot users also get the Flash library to write to flash from application (@MCUdude again - this is the version of Flash.h from MegaCoreX and like the version on classic AVRs, totally different from the Flash.h in DxCore (it's unfortunate that we named them the same thing).You now get a memory map too when you do Export compiled binary. Hopefully in future version I'll be able to automatically format it better than it is now - the first column is too small, so the columns don't line up; but because the numbers are hex, importing it into excel is annoying (excel is surprisingly bad at hexadecimal numbers)

Other than that, this is largely a bugfix release:

  • Wire clock generation now does something like what it claims. (#400)
  • Issue with PWM on PIN_PC0 and PIN_PC1 not working correctly when they are written in rapid succession. (#414)
  • analogReadEnh() and analogReadDiff() on the 2-series would incorrectly configure CTRLB, leaving it set to 0 (an accidental copy/paste error from the 1-series) which set the ADC prescaler to the minimum, guaranteeing that the ADC clock was out of spec after the first ADC reading. It worked surprisingly well in that state such that I had missed the issue until I saw it by chance while investigating ways to try to improve the accuracy, which just didn't seem to be very good (well no wonder!)
  • Fix a theoretical bug in optiboot on all parts when an application directly jumps to reset or runs off the end of flash (we now do a software reset if we detect that so adverse peripheral configurations can't hose the bootloader).
  • Lots of other little stuff. Boards.txt looks lovely now!

2.3.0 - tinyAVR 2-series support! New ADC functionality!

12 Apr 17:44
Compare
Choose a tag to compare

Well. this is a big release, and sooner than I planned. Couldn't help but work on this. This adds:

  • Support for 2-series boards in boards.txt for non-optiboot definitions only (I realized there are a couple of complications there, so instead of releasing stuff I know will be seriously broken, bootloaders for 2-series deferred imtol; a 2.3.x/
    The most significant addition is a wrapper around more advanced ADC reads, with analogReadEnh - this enhanced analogRead() takes a pin number, and optionally a number of bits of resolution, and optionally a gain of 0 (PGA off), 1 (unity gain(., 2, 4, 8, or 16x gain supported. This function works on all oparts, but only on the tinyAVR 1-series have
  • Support for differential ADC measurements with analogReadDiff() - works very similar to above
  • Support for normal analogRead() on 2-series.
  • A few accessory functions to turn features on and off relating toe the new ADC.
    The ADC is kind of a big deal.
  • In addition to that, the long overdue comparator library is ported.
  • Bugs in tone and delay were corrected.
  • 2-series default millis timer switched to TCB1.
  • New version of the pymcuprog bridge that should allow reprogramming of locked chips.
  • New avrgcc toolchain to pick up the latest atpacks where the 32k 2-series are first featured.
  • Probablty more that I forgot mentioning in the changelog.
    Be sure to read the section in t our documents about how to use analogReadEnh and analogReadDiff!

2.2.9 - more critical bugfixes

26 Feb 10:29
Compare
Choose a tag to compare

This brings in yet another round of critical bugfixes for the 2.2.x branch (2.3.x will have 2-series support, and parts of that are already sketched in, but due to ATTinyCore demanding some attention, it will be some time before I am able to come back to finish that off.

  1. Correct critical regression involving PWM on PA3, PA4, and PA5 (introduced with 2.2.8).
  2. Correct critical regression involving PWM on PA7 on 8-pin parts (introduced with 2.2.8)..
  3. Correct defect in RTC millis timekeeping which could result in traveling back in time by as much as 32 seconds.
  4. Correct canShow() and associated code in tinyNeoPixel and tinyNeoPixel_Static libraries to recognize when micros() is not available and skip over the code that uses it, rather than generating a compile error; instead, in these cases, we warn the user that they are responsible for ensuring that show() method is not called less than 50us after the previous show() finished.

2.2.8 - Important bugfixes

21 Feb 16:41
185de99
Compare
Choose a tag to compare

I had hoped that 2.2.7 was stable enough to take my eyes off megaTinyCore, but no such luck. A few critical bugfixes had to get released ASAP.

  • Burn bootloader for Optiboot boards when using the pyupdi style programer (ie, serial adapter with resistor) would report success but not actually write the bootloader to flash. A combination of a defect in the core and a bug in the tooling. We are waiting for a fix on the tooling bugs but in the meantime it was found to be possible to prevent to bug from manifesting by correcting the recipe used to build the command.
  • 2.2.7 introduced a regression in constrain() that caused this macro to not compile. This issue has been corrected.
  • The TCD "no glitch" feature added a few versions ago introduced a regression in the handling of the INVEN (INVert ENable) bit, whereby digitalWrite on a pin used by TCD0 for PWM would unset that bit, in order to properly turn off PWM output which might be outputting 100% HIGH while still connected to the timer, which we do in order to avoid having to briefly stop the timer so we can access the TCD0.FAULTCTRL register; we want to unset it if its set when we turn off PWM.... but not if the user has set it for some other reason! This bug is corrected now - it will only touch INVEN if it is disconnecting pin from timer at same time.
  • Found a nasty bug in the routines for TCA0 PWM - has been there for ages, but first glance over how the compiler implemented it, it could have a dramatic effect on the performance of analog and digital writes to pins - problem came down to a "variable shift" - if you ask for 1<<7 that will get optimized to a constant with that value at compiletime. But if you do 1<<x and x is not known at compiletime... that is a LOOP! At least 4 cycles per iteration assuming it's a byte; more for larger datatypes. I definitely hadn't realized that when I wrote the code in question. By looking up the bitmask instead of bit position, substantial performance improvement was realized, as well as flash savings.

In an effort to control hosting costs which I think are being driven by the github actions CI testing, I've tried attaching the avr-gcc toolchain version used by megaTinyCore and DxCore to this. Let's see if they let me get away with this....

2.2.7 - takeOverTCA0, openDrain() I/O

10 Feb 15:03
Compare
Choose a tag to compare

This is planned as the final 2.2.x release with 2-series support starting in 2.3.0, and I want a release with all the non-2-series changes out, so we only have the 2-series as a headline thing waiting on 2.3.0 - but I wanted to get testing versions of 2.3.0 in peoples' hands quickly. Plus, it turned out that an update to avrdude.conf made the difference between working and not working with a bunch of new programmers, so we want that in the hands of everyone ASAP too,

So let's release this, and soon a 2.3.0-dev will be in master with 2-series parts sketched in, but no guarantees that anything works. Anyway, this adds the timer takeover functions (tell the core you're taking full control of the timer and to pretend it doesn't exist), and openDrain() (digitalWrite-esque wrapper around using a pin as an open drain output). And a few minor changes/fixes

2.2.7 changes:

  • Clean up Servo formatting and comments and synchronize with DxCore version of library.
  • We were waiting for ENRDY to be set before changing enable-protected registers of TCD0. That doesn't appear to be needed. We just can't re-enable it until ENRDY is set. It makes the glitch when turning PWM off or on... maybe 6 CLK_PER shorter? I think under default settings, the loop goes from one iteration to none....
  • Do not initialize the the compare values of TCA0. 1. They are guaranteed by hardware to start up at 0, and we don't CARE what they start up as, because before the core turns any of them on, it sets them to a value. 24 bytes saved! (STS x 6)
  • Add takeOverTCA0(), takeOverTCD0(). Calling these will set a flag that tells analogWrite() and digitalWrite() not to try to configure these timers, and instead to act like the pin has no PWM functionality. User assumes responsibility for the management of Waveform Output.
  • Update avrdude.conf to fix support for Snap, PICKit and Curiosity programmer options.
  • Fix macro definitions of sq() and constrain() which were still vulnerable to stupid stuff caused by macro leading to arguments being evaluated multiple times.
  • Add openDrain(), openDrainFast() - LOW, FLOAT, and CHANGE are supported. LOW set pin to output, FLOAT (#defined as 1 now) sets it input, and CHANGE toggles it. It does turn off PWM, and it does set the PORTx.OUT for that pin to 0 so carelessness can't lead you to switching a pin left set to HIGH's output on (on the reasoning that you may be switching a line connected to something that could be damaged if you drove it high). It does not, however, touch the PINnCTRL register (so pullup is left on if you'd already set it that way). However openDrainFast() - the fast-I/O version of that function - does NOT touch the PWM or PORTx.OUT register.
  • IDE should now highlight a few more keywords associated with megaTinyCore.
  • Minor formatting improvements in ChangeLog.md.
  • Update avr-gcc toolchain to azduino3.

(note - this is the second try at this release, hence the underscore in version number - I didn't check the CI results until after I'd released, and it turned out to be broken on 0-series. I pulled that after a half hour, without it ever having been available on board manager, but github won't let me reuse version numbers - you can never truly delete them)

2.2.6 - Wire.h fix on several levels

24 Jan 10:17
Compare
Choose a tag to compare

In 2.2.4, I tried to pull in a change for a problem with I2C baud rate calculation. But I actually made things much worse because I only pulled in half of it. This gets the other half. It also adds hardening against the widespread and long-standing TWI errata, by having it ensure that it's pins are set appropriately when Wire.begin() is called. a method to enable pullups with Wire.usePullups(). It also adds a bit more documentation for the wire library Also, the SPI library no longer requires the SS pin to be specified, since there is literally nothing special about it the way the SPI library sets it up SPI.h is master only (SPI.h got major work done on DxCore - I didn't bother bringing the Dx-specific stuff back here, but I did remove SS pin requirement.

2.2.5 - Another try at pyupdi for board manager...

18 Jan 04:22
a63e9c9
Compare
Choose a tag to compare

Apparently I had also forgotten to add python3 to the tools that the build script adds for toolsDependencies - so my previous fix just left us with a different error!