Skip to content

Commit 25cd565

Browse files
committed
Fixes #1243
1 parent d0984f0 commit 25cd565

6 files changed

Lines changed: 1327 additions & 1296 deletions

File tree

ChangeLog.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,32 @@ These items are in addition to what was listed under changes already in release.
2020
* If there are *other substantial changes that need to occur* within the core, I am unaware of the complaints and hence have no plans to address them before the heat death of the universe. If you desire changes on a more rapid timeline, please create an issue so that I am aware of the presence of said problem, deficiency, or imperfection. Those form the action item list for core development activity, so if something is not listed there, **it is unlikely to be implemented/fixed/etc** simply due to my being unaware of any concern.
2121

2222
## Unreleased changes
23-
Changes listed here are checked in to GitHub ("master" branch unless specifically noted; this is only done when a change involves a large amount of work and breaks the core in the interim, or where the change is considered very high risk, and needs testing by others prior to merging the changes with master - everything else goes straight into master). These changes are not yet in any "release" nor can they be installed through board manager, only downloading latest code from github will work. These changes will be included in the listed version, though planned version numbers may change without notice - critical fixes may be inserted before a planned release and the planned release bumped up a version, or versions may go from patch to minor version depending on the scale of changes
23+
Changes listed here are checked in to GitHub ("master" branch unless specifically noted; this is only done when a change involves a large amount of work and breaks the core in the interim, or where the change is considered very high risk, and needs testing by others prior to merging the changes with master - everything else goes straight into master). These changes are not yet in any "release" nor can they be installed through board manager, only downloading latest code from github will work. These changes will be included in the listed version, though planned version numbers may change without notice - critical fixes may be inserted before a planned release and the planned release bumped up a version, or versions may go from patch to minor version depending on the scale of changes.
2424

25-
### Planned 2.6.11
26-
* Pending: New toolchain version.
25+
The 2.6.11 release is pending, following that the next version will by 2.7.0.
26+
27+
## Released Versions
28+
29+
### 2.6.11 (release pending)
30+
* New toolchain version.
2731
* Make wiring.c have the functions referred to in the doc.
32+
* Split the three ugly functions that constituted 60% of wiring.c into a separate file, because finding anything else with those #ifdef-hell-spawned abominations is awful.
33+
* General cleanup of wiring.c and timers.h for maintainability.
2834
* Fix some of the constants for timers so that all timers can still get uniform codes specifying the portmux and (for non-TCA's) which pin within the mux it is, which matters for the other core.
2935
* Documentation improvements.
30-
* Corrected bug sometimes encountered when using serial under atypical cases the causes of which remain mysterious), where it would complain about `__poll_dre_done`.
36+
* Corrected critical bug in the TCD0 millis option (the default on 1-series parts) (#1243)
37+
* Corrected bug sometimes encountered when using serial under atypical cases the causes of which remain mysterious), where it would complain about `__poll_dre_done`. (#1226)
3138
* Correct bug with Comparator (#1236)
3239
* Correct numerous issues with the microchip board defs. Clearly nobody is using them - since 2 of them didn't compile, and none of the optiboot ones would ever be able to successfully be programmed over the bootloader because selfprogramming wasn't enabled (BOOTEND = 0).
33-
* Major Bugfix: Correct issue #1164 thanks to John Vasileff. This would cause Serial.flush to hang in one-wire mode.
40+
* Major Bugfix: Correct issue #1164 thanks to John Vasileff. This would cause Serial.flush() to hang in one-wire mode.
3441
* Major Bugfix: Correct buffered PWM on all parts.
35-
* Major Bugfix: Correct PWM on non-default pins on all parts; digitalPinHasPWM.
36-
* Fix bug with CCL clock source.
37-
* Fix bug with Comparator
42+
* Major Bugfix: Correct PWM on non-default pins on all parts; digitalPinHasPWM() macro.
43+
* Fix bug with CCL clock source selection options.
3844
* Enhance documentation
39-
* Removed example of exactly the sort of boneheaded and strictly-worse in a trivial part of Wire. While it was merely a bad example at the time it was written, it is now known to be a bad, dangerous example, because it featured code that demonstrated Strictly Worse access to registers, by loading a vport register to a pointer register, and using that - not only is it stupid and just a less-featureful PORT when accessed that way, avoiding pointer access to the I/O space (64 addresses, - 28 VPORTs and 4 GPIORs in low I/O and SP, RAMPZ (if applicable), CCP (the register used for `__PROTECTED_WRITE()`}), and of course the SREG. And indeed, none of those are registers that anyone should ever access using a pointer, even if it didn't wasn't safe against an incredibly scary bug - the low I/O is all about the bitwise instructions, which need both the register and bit compile time known. `VPORT_t*` is not a type you should ever declare - if you have had to declare it, *you get no benefit* from faster access to it (like you do if you use the compile-time known VPORT's amd access them without pointing. )
45+
* Correct critical problem with timekeeping on parts with a TCD. (#1243)
46+
* Removed example of exactly the sort of boneheaded and strictly-worse code I rail against in a trivial part of Wire. While it was merely a bad example at the time it was written, it is now known to be a bad, dangerous example, because it featured code that demonstrated Strictly Worse access to registers, by loading a vport register to a pointer register, and using that - not only is it stupid and just a less-featureful PORT when accessed that way, avoiding pointer access to the I/O space (64 addresses, - 28 VPORTs and 4 GPIORs in low I/O and SP, RAMPZ (if applicable), CCP (the register used for `__PROTECTED_WRITE()`}), and of course the SREG) is necessary due to an erratum effecting all AVRxm parts. And indeed, none of those are registers that anyone should ever access using a pointer, even if it didn't wasn't safe against an incredibly scary bug - the low I/O is all about the bitwise instructions, which need both the register and bit compile time known. `VPORT_t*` is not a type you should ever declare - if you have had to declare it, *you get no benefit* from faster access to it (like you do if you use the compile-time known VPORT's amd access them without pointing. )
4047
* Enhance error messages from wrong-part on upload.
4148

42-
## Released Versions
43-
4449
### 2.6.10 - Critical fix
4550
* Critical bugfix: Switch to using Azduino7c, which is the same as the Azduino7b binary, but with the correct CRC attached.
4651
* Bugfix: #1014, named constants for ADCPowerOptions() did not work on 0/1-series parts. The 4 valid options are now given named defines, and the rest are #defined as `badArg("This option is on 2-series tiny and AVR Ex-series only")`

megaavr/cores/megatinycore/Arduino.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,15 @@ uint32_t microsecondsToMillisClockCycles(uint32_t microseconds);
463463
*/
464464
#ifdef MILLIS_USE_TIMERD0
465465
#if (F_CPU == 20000000UL || F_CPU == 10000000UL ||F_CPU == 5000000UL)
466-
#define millisClockCyclesPerMicrosecond() ((uint16_t)(20)) // this always runs off the 20MHz oscillator
467-
#else
468-
#define millisClockCyclesPerMicrosecond() ((uint16_t)(16))
466+
#define millisClockCyclesPerMicrosecond() (20) // this always runs off the 20MHz oscillator
467+
#else //16. 8, 4, 2, 1
468+
#define millisClockCyclesPerMicrosecond() (16)
469469
#endif
470470
#else
471-
#define millisClockCyclesPerMicrosecond() ((uint16_t)((F_CPU / 1000000UL)))
471+
#define millisClockCyclesPerMicrosecond() ((F_CPU / 1000000UL))
472472
#endif
473-
#define millisClockCyclesToMicroseconds(__a__) ((uint32_t)(__a__ / millisClockCyclesPerMicrosecond()))
474-
#define microsecondsToMillisClockCycles(__a__) ((uint32_t)(__a__ * millisClockCyclesPerMicrosecond()))
473+
#define millisClockCyclesToMicroseconds(__a__) ((__a__ / millisClockCyclesPerMicrosecond()))
474+
#define microsecondsToMillisClockCycles(__a__) ((__a__ * millisClockCyclesPerMicrosecond()))
475475

476476
/* Timers and Timer-like-things
477477
* These are used for two things: Identifying the timer on a pin in
@@ -697,7 +697,13 @@ uint32_t microsecondsToMillisClockCycles(uint32_t microseconds);
697697
#define MILLIS_RUNNING (0x00)
698698
#define MILLIS_PAUSED (0x01)
699699
#define MILLIS_ON_ALT_TIMER (0x02)
700-
700+
// MILLIS_TYPE
701+
#define MILLIS_TCA (0x01)
702+
#define MILLIS_TCB (0x02)
703+
#define MILLIS_TCD (0x04)
704+
#define MILLIS_TCE (0x05)
705+
#define MILLIS_TCF (0x06)
706+
#define MILLIS_RTC (0x20)
701707

702708

703709
__attribute__ ((noinline)) void _delayMicroseconds(unsigned int us);

0 commit comments

Comments
 (0)