Comments (10)
Workaround: using CCPWrite
from here.
from dxcore.
Why not use the compiler provided builtin, _PROTECTED_WRITE()? That is what DxCore uses for setting protected registers...Looks like its... exactly the same as CCPWrite()
from dxcore.
Except that it has an unnecessary disabling of interrupts (when CCP is written, interrupts are automatically disabled - see datasheet; that implementation disables them around the call to CCP, which just wastes uh... 6 bytes of flash and 3 CPU clocks?
from dxcore.
(it = CCPWrite() - _PROTECTED_WRITE() does it correctly.... )
Though, I'm surprised that cpufunc has changed? I don't suppose you could post the exact linker error?
from dxcore.
@SpenceKonde Didn't know that macro. Thanks for the pointer!
Though, I'm surprised that cpufunc has changed? I don't suppose you could post the exact linker error?
I'll prepare a minimal example...
from dxcore.
#include <avr/cpufunc.h>
void setup() {
uint8_t temp;
temp = CLKCTRL.OSC32KCTRLA;
temp |= CLKCTRL_RUNSTDBY_bm;
ccp_write_io((uint8_t*)&CLKCTRL.OSC32KCTRLA, temp);
}
void loop() {
}
Arduino: 1.8.13 (Linux), Board: "AVR DB-series (no bootloader), AVR128DB28, 24 MHz internal, No, 1.9V, Disabled/Disabled, EEPROM retained, Hardware Reset (recommended), TCB2, Enabled, 8ms"
/opt/arduino-1.8.13/arduino-builder -dump-prefs -logger=machine -hardware /opt/arduino-1.8.13/hardware -hardware /home/user/.arduino15/packages -hardware /home/user/src/Arduino/hardware -tools /opt/arduino-1.8.13/tools-builder -tools /opt/arduino-1.8.13/hardware/tools/avr -tools /home/user/.arduino15/packages -built-in-libraries /opt/arduino-1.8.13/libraries -libraries /home/user/src/Arduino/libraries -fqbn=DxCore:megaavr:avrdb:chip=128DB28,clock=24internal,serialevent=no,bodvoltage=1v9,bodmode=disabled,eesave=enable,resetpin=reset,millis=tcb2,mvio=enabled,startuptime=8 -vid-pid=1A86_7523 -ide-version=10813 -build-path /tmp/arduino_build_302614 -warnings=default -build-cache /tmp/arduino_cache_613580 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-azzy1.path=/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1 -prefs=runtime.tools.arduinoOTA.path=/home/user/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/user/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /tmp/arduino_modified_sketch_9454/sketch_dec10a.ino
/opt/arduino-1.8.13/arduino-builder -compile -logger=machine -hardware /opt/arduino-1.8.13/hardware -hardware /home/user/.arduino15/packages -hardware /home/user/src/Arduino/hardware -tools /opt/arduino-1.8.13/tools-builder -tools /opt/arduino-1.8.13/hardware/tools/avr -tools /home/user/.arduino15/packages -built-in-libraries /opt/arduino-1.8.13/libraries -libraries /home/user/src/Arduino/libraries -fqbn=DxCore:megaavr:avrdb:chip=128DB28,clock=24internal,serialevent=no,bodvoltage=1v9,bodmode=disabled,eesave=enable,resetpin=reset,millis=tcb2,mvio=enabled,startuptime=8 -vid-pid=1A86_7523 -ide-version=10813 -build-path /tmp/arduino_build_302614 -warnings=default -build-cache /tmp/arduino_cache_613580 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-azzy1.path=/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1 -prefs=runtime.tools.arduinoOTA.path=/home/user/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/user/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /tmp/arduino_modified_sketch_9454/sketch_dec10a.ino
Using board 'avrdb' from platform in folder: /home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a
Using core 'dxcore' from platform in folder: /home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a
Detecting libraries used...
/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=avr128db28 -DF_CPU=24000000L -DARDUINO=10813 -DARDUINO_avrdb -DARDUINO_ARCH_MEGAAVR -DDXCORE=1.1.1 -DDXCORE_MAJOR=1UL -DDXCORE_MINOR=2UL -DDXCORE_PATCH=0UL -DDXCORE_RELEASED=1 -DMILLIS_USE_TIMERB2 -DCLOCK_SOURCE=0 -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/cores/dxcore/api/deprecated -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/cores/dxcore -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/variants/28pin-standard /tmp/arduino_build_302614/sketch/sketch_dec10a.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=avr128db28 -DF_CPU=24000000L -DARDUINO=10813 -DARDUINO_avrdb -DARDUINO_ARCH_MEGAAVR -DDXCORE=1.1.1 -DDXCORE_MAJOR=1UL -DDXCORE_MINOR=2UL -DDXCORE_PATCH=0UL -DDXCORE_RELEASED=1 -DMILLIS_USE_TIMERB2 -DCLOCK_SOURCE=0 -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/cores/dxcore/api/deprecated -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/cores/dxcore -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/variants/28pin-standard /tmp/arduino_build_302614/sketch/sketch_dec10a.ino.cpp -o /tmp/arduino_build_302614/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE
/opt/arduino-1.8.13/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/arduino_build_302614/preproc/ctags_target_for_gcc_minus_e.cpp
Sketch wird kompiliert...
/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1/bin/avr-g++ -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=avr128db28 -DF_CPU=24000000L -DARDUINO=10813 -DARDUINO_avrdb -DARDUINO_ARCH_MEGAAVR -DDXCORE=1.1.1 -DDXCORE_MAJOR=1UL -DDXCORE_MINOR=2UL -DDXCORE_PATCH=0UL -DDXCORE_RELEASED=1 -DMILLIS_USE_TIMERB2 -DCLOCK_SOURCE=0 -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/cores/dxcore/api/deprecated -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/cores/dxcore -I/home/user/.arduino15/packages/DxCore/hardware/megaavr/1.2.0-a/variants/28pin-standard /tmp/arduino_build_302614/sketch/sketch_dec10a.ino.cpp -o /tmp/arduino_build_302614/sketch/sketch_dec10a.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /tmp/arduino_cache_613580/core/core_e338eab05b22211458d2037f06274d6b.a
Linking everything together...
/home/user/.arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azzy1/bin/avr-gcc -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--section-start=.text=0x0,--section-start=.FLMAP_SECTION1=0x8000,--section-start=.FLMAP_SECTION2=0x10000,--section-start=.FLMAP_SECTION3=0x18000 -mmcu=avr128db28 -o /tmp/arduino_build_302614/sketch_dec10a.ino.elf /tmp/arduino_build_302614/sketch/sketch_dec10a.ino.cpp.o /tmp/arduino_build_302614/../arduino_cache_613580/core/core_e338eab05b22211458d2037f06274d6b.a -L/tmp/arduino_build_302614 -lm
/tmp/ccagVgyB.ltrans0.ltrans.o: In function `setup':
/tmp/arduino_modified_sketch_9454/sketch_dec10a.ino:8: undefined reference to `ccp_write_io(unsigned char*, unsigned char)'
exit status 1
from dxcore.
_PROTECTED_WRITE
did the trick. Thanks, again!
As I'm playing with the PIT at the moment, do you know a way to calibrate the internal 32k osc? It's a tad too slow. From the datasheet I see that there's RTC.CALIB
, but it's only available for the external 32k crystal...
from dxcore.
Don't think you can; that is not what it is meant for! It's meant to be a "save as much power as you can by sacrificing accuracy" option... If you want accuracy, they would tell you to use a watch crystal or 32kHz active oscillator.
It's also fairly strongly dependent temperature (used to be dependent on voltage too... but they run the internal oscillators on the Dx-series from Vddcore which is regulated down from Vdd, and varies little - if anything - over operating voltage range.... That's why they are spec'ed for the full 4-24 MHz over the full voltage range; Semiconductor performance = f(p, V, T) - process (manufacturing process, including design, etc), voltage (positive correlation) and temperature (negative correlation)
Actually, now that would be an interesting experiment... monitor the frequency of PWM, on a part with BOD disabled while you sloooooowly lower the voltage. At some Vddlow suddenly the frequency will start to change with voltage. This Vddlow = Vddcore+Vdropout of their core voltage regulator, wouldn't it?
from dxcore.
By the way, if you do anything spiffy with the PIT, I'd love to hear about it. I just enabled discussions here, so there's a mini-forum attached to DxCore repo now :-)
(that scream you heard in the distance was gitter, the github-repo-focused discussion forum site :-P )
from dxcore.
Sure. I just thought there was something similar to the SIGROW.TEMPSENSE[01]
that I missed...
Nothing spiffy: I'll simply use it as the time source for FreeRTOS on megaavr like we do with the WDT on avr.
from dxcore.
Related Issues (20)
- D7 LED not blinking after burning bootloader into 32DD14 configured for Serial on D4/D5 (Serial0, Swap3) HOT 11
- On AVR-DD Parts can't configure MVIO for Single Supply via Tools MVIO Option in Arduino IDE HOT 1
- EVENT AND COMPARATOR ISSUES WITH EA and EB parts HOT 5
- How to do OTA? AVR128DB64 HOT 2
- Wrong timer for millis() on 14-pin DD part HOT 2
- HV programmer for DD series (and newer)
- Board Manager SSH Certificate Expired HOT 2
- AVR128DB48 unexpected behaviour HOT 5
- linking error: section .bss' is not within region data' HOT 1
- program avr128da28 chip using arduino uno as a programmer HOT 4
- error when burning the bootloader for avr128DA28 and arduino uno as updi HOT 4
- Is there a -r option hidden in the DxCore settings? HOT 3
- AVR64DU32 Curiosity Nano Board
- GPIOR registers used by core contrary to the documentation HOT 4
- What is GCSE optimisation? HOT 5
- AVR128DA48 and AVR128DB48 Curiosity Nano boards don't work on 1.5.8 or later HOT 2
- Autocomplete does not work with DxCore (and some megaTinyCore boards) in Arduino IDE 2.3.2 on 64-bit Linux HOT 1
- PWM off TCD on 14-pin DD series HOT 1
- AVR32EA64 uploads once only HOT 2
- EA Timers HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dxcore.