diff --git a/megaavr/extras/Ref_Clocks.md b/megaavr/extras/Ref_Clocks.md index 0cb16721..11dec477 100644 --- a/megaavr/extras/Ref_Clocks.md +++ b/megaavr/extras/Ref_Clocks.md @@ -18,7 +18,7 @@ Additionally, there is a tuning register, CLKCTRL.OSCHFTUNE. Unfortunately, it i If an external 32.768 MHz crystal has been connected, you can, for improved temperature stability, autotune the internal oscillator from this. I had to direct a torch at the chip (from a distance) to heat it up enough to see the speed autotune.... Not the feature I'm most impressed with. A+ on concept, C on execution. -Tuning to achieve non-standard speeds is not supported on the AVR Dx-series parts under DxCore. +Tuning to achieve non-standard speeds is not supported on the AVR Dx-series parts under DxCore. ### On tinyAVR The OSCCFG fuse selects whether the speed is derived from a 20 MHz or 16 MHz oscillator. At power-on, these are always set to a prescaler of /6 hence 2.66 or 3.33 MHz. The core, prior to calling setup, will reconfigure the prescaler to match the requested speed. The OSCCFG fuse is always set when a sketch is uploaded via a UPDI programmer. @@ -33,9 +33,9 @@ Not the feature I'm most impressed with. A+ on concept, C on execution. Tuning to achieve non-standard speeds is not supported on the AVR Ex-series parts under DxCore. ## Supported Clock Speeds -Like classic AVRs, tinyAVRs have a "speed grades" depending on the voltage and operating conditions that they are rated for operation within. The spec is 5 MHz @ 1.8V , 10 MHz @ 2.7V (3.3V nominal) and 20 @ 4.5V (5.0V nominal) (2.7 or 4.5 for 8MHz and 16 MHz at >105C . See the Speed Grade reference for more information on this. Note that the speed grades are extremely conservative for room temperature operation, and unreal overclocking is easily achievable at room temperaturee, particularly with high temp. rated parts. +Like classic AVRs, tinyAVRs have a "speed grades" depending on the voltage and operating conditions that they are rated for operation within. The spec is 5 MHz @ 1.8V , 10 MHz @ 2.7V (3.3V nominal) and 20 @ 4.5V (5.0V nominal) (2.7 or 4.5 for 8MHz and 16 MHz at >105C . See the Speed Grade reference for more information on this. Note that the speed grades are extremely conservative for room temperature operation, and unreal overclocking is easily achievable at room temperaturee, particularly with high temp. rated parts. -The AVR Dx-series come in I (105C) and E (125C) spec parts. Since the DA-series was released, Microchip has STOPPED MARKING THE SPEED GRADE ON THE CHIPS. Be sure that if you have both speed grades, you mark the chips somehow (0 and 1-series parts do still have the temperature rating marked (N = 105, F = 125). +The AVR Dx-series come in I (105C) and E (125C) spec parts. Since the DA-series was released, Microchip has STOPPED MARKING THE SPEED GRADE ON THE CHIPS. Be sure that if you have both speed grades, you mark the chips somehow (0 and 1-series parts do still have the temperature rating marked (N = 105, F = 125). Some of the listed speeds, while supported by the hardware are not supported by the core - typically weird, slow clocks, particularly from a crystal diff --git a/megaavr/extras/Ref_Defines.md b/megaavr/extras/Ref_Defines.md index 16d8357d..155a878a 100644 --- a/megaavr/extras/Ref_Defines.md +++ b/megaavr/extras/Ref_Defines.md @@ -272,7 +272,7 @@ There are a number of macros for determining what (if any) features the core sup * `CORE_HAS_TIMER_TAKEOVER = 1` - if defined as 1 or more, `takeOverTCxn()` functions are available to let user code take full control of TCA0, TCA1 and/or TCD0. If a part, for which support has been provided by one of my cores, in a release, without a takeOverTCxn() function for a timer it has, and later gets a takeOverTCxn function for that timer, there would need to be a CORE_HAS_TIMER_TAKEOVER = 2 for versions of the core that have that new function. I hope, however, to give all new timers a takeOver function if one is appropriate with the first release of support for parts having those timers. * `CORE_HAS_TIMER_RESUME = 0`- if defined as 1, the corresponding `resumeTCAn()` functions, which reinitialize them and return them to their normal core-integrated functions, are available. Different values in the future might be used to indicate that resume timers other than TCAn, or which might have an option to resume TCD0. Not available on megaTinyCore. * `ADC_NATIVE_RESOLUTION = 10 or 12`- This is the maximum resolution, in bits, of the ADC without using oversampling. 2-series get 12-bits, other tinies get 10, and all Dx/Ex get 12, though the Ex has a much nicer ADC. -* `ADC_NATIVE_RESOLUTION_LOW = 8 or 10` - All the ADCs, in addition to converting at ADC_NATIVE_RESOLUTION, have a lower resolution, slightly faster option. On the tinyAVRs this is 8-bit for all parts, while for Dx, it's 10 bits. +* `ADC_NATIVE_RESOLUTION_LOW = 8 or 10` - All the ADCs, in addition to converting at ADC_NATIVE_RESOLUTION, have a lower resolution, slightly faster option. On the tinyAVRs this is 8-bit for all parts, while for Dx, it's 10 bits. * `ADC_DIFFERENTIAL = 0, 1, or 2` - This is defined as 1 if the part has a basic differential ADC (no gain, and Vanalog_in constrained to between Gnd and VRef, as on the Dx-series), and 2 if it has a full-featured one. It does not indicate whether said differential capability is exposed by the core. This is 0 for 0/1-series and 2 for 2-series. Classic AVRs on ATTinyCore 2.0.0+ will define this as -1 if they have a differential ADC, as their ADC takes differential channels in a totally different way, and will not define it at all if they do not. See also `CORE_HAS_ANALOG_DIFF` * `SUPPORT_LONG_TONES = 0 or 1` - On some modern AVR cores, an intermediate value in the tone duration calculation can overflow (which is timed by counting times the pin is flipped) leading to a maximum duration of 4.294 million millisecond. This is worst at high frequencies, and can manifest at durations as short as 65 seconds worst case. Working around this, however, costs some flash, so megaTinyCore only supports long tones on parts with more than 8k of flash. If `SUPPORT_LONG_TONES` is defined as 1, as long as (duration * frequency)/500 < 4.294 billion, the duration will not be truncated. If it is defined as 0, the bug was known to the core maintainer and they chose not to fully correct it (eg, to save flash) but took the obvious step to reduce the impact, it will be truncated if (duration * frequency) exceeds 4.294 billion. If `SUPPORT_LONG_TONES` is not defined at all, the bug may be present in its original form, in which case the duration will be truncated if (duration * frequency) exceeds 2.14 billion. * `CORE_HAS_ANALOG_ENH = 1` - If defined as 1, `analogReadEnh()` (enhanced analogRead) is available. Otherwise, it is not; it is 1 for all parts on recent versions of megaTinyCore. diff --git a/megaavr/extras/Ref_Reset.md b/megaavr/extras/Ref_Reset.md index 5ac80e43..a18bc005 100644 --- a/megaavr/extras/Ref_Reset.md +++ b/megaavr/extras/Ref_Reset.md @@ -39,7 +39,7 @@ The two high bits of GPIOR0 may be written by the init_clock() function (which r // } ``` -3. When the bootloader entry conditions are not met, the reset flags are read. If they are 0, indicating no reset has occurred, we immediately fire a software reset. If the entry conditions are not met, but the reset flags are non-zero, or if the entry conditions are met and the bootloader runs (and either times out or receives a new application), before jumping to the app the flags are cleared, and stashed someplace where a user of average skill can retrieve them (ie, NOT r2). A do-nothing register like GPIOR0 is well suited to this, and this is what we use the lower 6 bits of that register for (the remaining two are used to report issues with the tuned clock settings) +3. When the bootloader entry conditions are not met, the reset flags are read. If they are 0, indicating no reset has occurred, we immediately fire a software reset. If the entry conditions are not met, but the reset flags are non-zero, or if the entry conditions are met and the bootloader runs (and either times out or receives a new application), before jumping to the app the flags are cleared, and stashed someplace where a user of average skill can retrieve them (ie, NOT r2). A do-nothing register like GPIOR0 is well suited to this, and this is what we use the lower 6 bits of that register for (the remaining two are used to report issues with the tuned clock settings). ## Reset Sources @@ -145,7 +145,7 @@ void resetViaSWR() { } ``` -The two recommended methods, resetViaWDT() and resetViaSWR() are provided by DxCore.h or megaTinycore.h as appropriate. +The two recommended methods, resetViaWDT() and resetViaSWR() are provided by DxCore.h or megaTinycore.h as appropriate. ## Using watchdog to reset when hung If you only worked with the watchdog timer as an Arduino user - you might not even know why it's called that, or what the original concept was, and just know it as that trick to do a software reset on classic AVRs, and as a way to generate periodic interrupts (which it can't do on a modern AVR - though the much more powerful and full features RTC can be used instead). The "purpose" of a watchdog timer is to detect when the part has become hung - either because it's wound up in an infinite loop due to a bug, or because it wound up in a bad state due to a glitch on the power supply or other adverse hardware event, has been left without a clock by an external clock source failing, went to sleep waiting for some event which doesn't end up happening (or without correctly enabling whatever is supposed to wake it up) - and issue a reset. It is often anthropomorphized as a dog, who needs to be "fed" or "pet" periodically, or else he will "bite" (commonly seen in comments - the latter generally only when we are expecting it, as in `while (1); //wait for the watchdog to bite`). diff --git a/megaavr/libraries/Comparator/README.md b/megaavr/libraries/Comparator/README.md index abdb5d0e..45c55d7f 100644 --- a/megaavr/libraries/Comparator/README.md +++ b/megaavr/libraries/Comparator/README.md @@ -92,7 +92,7 @@ Comparator.input_n = comparator::in_n::vref; // Connect voltage reference to th ### reference -On the 0-series and 1-series, this sets the voltage reference that will be used if VREF is selected as the negative input. On non-0-series, this also sets the voltage that DACREF is derived from. +On the 0-series and 1-series, this sets the voltage reference that will be used if VREF is selected as the negative input. On non-0-series, this also sets the voltage that DACREF is derived from. On 1-series parts with multiple comparators, these reference voltages can be set independently for each comparator. On the Dx and Ex parts, parts with multiple comparators have to share just one reference voltage.. On the tinyAVR 1-series, AC0 and the DAC that can be output on PA6 share the same reference. The 0/1-series uses a rather strange set of voltages, while the 2-series uses the same voltages that most modern AVRs do. diff --git a/megaavr/libraries/Event/examples/Read_event_settings/Read_event_settings.ino b/megaavr/libraries/Event/examples/Read_event_settings/Read_event_settings.ino index 3efdde33..c8499727 100644 --- a/megaavr/libraries/Event/examples/Read_event_settings/Read_event_settings.ino +++ b/megaavr/libraries/Event/examples/Read_event_settings/Read_event_settings.ino @@ -41,7 +41,7 @@ void setup() { // Start event channels Event0.start(); #if !defined(MEGATINYCORE) || _AVR_PINCOUNT > 8 - // again for the second channel, if we have + // again for the second channel, if we have Event2.set_generator(gen1::pin_pa4); // Set pin PA4 as event generator Event2.set_user(user::evoutb_pin_pb2); // Set EVOUTB as event user Event2.start(); diff --git a/megaavr/libraries/Logic/README.md b/megaavr/libraries/Logic/README.md index 35023224..8014ddc9 100644 --- a/megaavr/libraries/Logic/README.md +++ b/megaavr/libraries/Logic/README.md @@ -247,7 +247,7 @@ Notes specific to ATtiny 0/1-series: * DA/DB have 3 AC's, EA 2, and the DD, DU and EB have one. The two final limits add further chaos to the distributions of numeric values for users and generators - the two seem to have had separate algorithms for determining when to leave holes for absent peripherals, and when to fill them in. They *really* seem to like filling in the holes in the generator lists, leaving me wondering what it is abouut the length of the list with such a high cost... -* **Errata warning** Many parts in circulation are impacted by an errata (though not all - some never had it, while the 32k parts have gotten a die rev that fixes it. On effected parts, the link input does not work unless pin output of the other logic block is enabled. Check the applicable errata and datasheet clarification document from Microchip to see if your part is impacted. Other parts have a +* **Errata warning** Many parts in circulation are impacted by an errata (though not all - some never had it, while the 32k parts have gotten a die rev that fixes it. On effected parts, the link input does not work unless pin output of the other logic block is enabled. Check the applicable errata and datasheet clarification document from Microchip to see if your part is impacted. Other parts have a * **Compatibility warning** The tinyAVR 0/1's were the first AVRs with CCL. They made some decisions that they realized weren't such a good idea after all and changed for parts released more recently. Most importantly, for TCBs and ACs, as well as USARTs, the peripheral number used is the input number. SPI on these parts makes MISO available supposedly. Later parts do not. Later parts also only make USART TXD available - though you can get XCK from the event system. * USART option will use XCK on input 0, TXD on input 1, and is not valid for input 2. * MISO is (supposedly) available as an input when SPI is used as the input. @@ -595,50 +595,6 @@ The two bits per LUT allow the interrupt to be triggered on ``` -## Latch-without-sequencer -The available sequencer options, unfortunately, are capable of only slightly more than what can be done with just the even block alone, using feedback. An example of this (2 on DxCore) shows a different input ordering. The comments in the LatchNoSeq example provide a bit more information. You can do many tasks that would at first blush look like a job for the latches by simply setting one input as feedback, and the other two to your latch inputs. - -##### RS-latch w/out sequencer -Input0 is Set -Input1 is Reset -Input2 is Feedback - -| 2 | 1 | 0 | Out | -|---|---|---|-----| -| 0 | 0 | 0 | 0 | -| 0 | 0 | 1 | 1 | -| 0 | 1 | 0 | 0 | -| 0 | 1 | 1 | 0 | -| 1 | 0 | 0 | 1 | -| 1 | 0 | 1 | 1 | -| 1 | 1 | 0 | 0 | -| 1 | 1 | 1 | 1 | - -Truth = 0b10110010 = 0xB2; - -Note that here you have the power to decide what happens in the event that the illegal state where R and S are both high occurs. Here I have it maintain the current state. -It's also fine to have it go high or low on the "S & R = 1" state, with truthtables of 0b10111010 = 0xBA, or 0b00110010 = 0x32 respectively. But make it toggle, ie, truth table of 0b00111010 = 0x3A and it will instead oscillate extremely rapidly (though it could be slowed down with the synchronizer or filter, that still isn't particularly useful ) - -##### D-type latch w/out sequencer -Input0 is D -Input1 is G -Input2 is Feedback - -| 2 | 1 | 0 | Out | -|---|---|---|-----| -| 0 | 0 | 0 | 0 | -| 0 | 0 | 1 | 0 | -| 0 | 1 | 0 | 0 | -| 0 | 1 | 1 | 1 | -| 1 | 0 | 0 | 1 | -| 1 | 0 | 1 | 1 | -| 1 | 1 | 0 | 0 | -| 1 | 1 | 1 | 1 | - -Hence truth tables are 0xB2 and 0xB8, and both of these leave the odd LUT available. Of course, if you need a logic block to come up with the inputs to set and reset, this is less useful. - - - ## Reconfiguring There are TWO levels of "enable protection" on the CCL hardware except on the newest parts . According to the Silicon Errata, only one of these is intended. As always, it's anyone's guess when or if this issue will be corrected in a future silicon rev. That it is likely to be fixed on any part that gets a die rev is not in doubt; when (and indeed whether) they will rev the die to fix all the nasty bugs that they've now corrected in their peripheral designs. (It would appear that Microchip only became aware of the issue after the Dx-series parts were released; it's the kind of thing where you could believe that it was intended if annoying behavior, which is probably why it wasn't noticed sooner (It came at the same time as the "TCA does what the datasheet says on RESTART command" (paraphrased, ofc), another bug like that; both may indeed have been intended at the time, and only later classified as bugs, perhaps by a newly installed product manager or QA czar who thought the original intent was folly (I do suspect that there was a changing of the guard around that time. That and/or an influx of testing manpower and resources. How else do you introduce a new ADC while reducing the number of errata from the previous generation from around 20, several serious, to like 5, of which this is the only one without a workaround); I happen to agree on this count and think it's a big deal (the other feature that got this treatment I agree with as well, but why did they ever let the timers have a port direction override? . Since there is no indication that there are die revs coming out any time soon, users are advised to proceed with use of workarounds, rather than delay work in the hopes of corrected silicon. diff --git a/megaavr/libraries/Logic/Tricks_and_Tips.md b/megaavr/libraries/Logic/Tricks_and_Tips.md index 2f03bf41..599a66ae 100644 --- a/megaavr/libraries/Logic/Tricks_and_Tips.md +++ b/megaavr/libraries/Logic/Tricks_and_Tips.md @@ -122,8 +122,6 @@ Clock: N/A Sync/Filter: Off -### - ## Sequential logic with just one LUT You can simulate some sequential logic units with just one LUT! @@ -196,6 +194,7 @@ LUT: Ergo: TRUTH = 0xE4 ### Gated Buffer +Let a signal through or output a constant signal depending on the second signal. INSEL: * X: D - When G is high, D is output * Y: G - When G is low, the output is low. @@ -213,7 +212,7 @@ Clock: N/A Sync/Filter: Off ### Double-gated Buffer -There are many variants on this where different combinations of logic are used. The point is to get an "If A and B, output C, else output (whatever level it is" +There are many variants on this where different combinations of logic are used. The point is to get an "If A and B, output C, else output (whatever level you want it to default to)" INSEL: * X: D - When G is high, D is output