Compare commits

..

2 Commits

Author SHA1 Message Date
true
9827a8f6be don't run timers in stop mode while debugging 2025-04-27 21:37:56 -07:00
true
57f7b1b48d fix setting clock divider to /1 when it should be /2
misinterpreted docs. too much ARM in my life.
the system sets up the clock divider with /2 and expects it to stay there.
was setting the divider to /1 thinking it only affected peripherals.
adjusted timings to compensate for the new divider.
2025-04-27 21:36:50 -07:00
4 changed files with 85 additions and 83 deletions

View File

@ -1073,6 +1073,8 @@ void tinyNeoPixel::show(uint16_t leds) {
interrupts();
/*
#if (!defined(MILLIS_USE_TIMERNONE) && !defined(MILLIS_USE_TIMERRTC) && !defined(MILLIS_USE_TIMERRTC_XTAL) && !defined(MILLIS_USE_TIMERRTC_XOSC))
endTime = micros();
// Save EOD time for latch on next call
@ -1080,6 +1082,7 @@ void tinyNeoPixel::show(uint16_t leds) {
#else
#pragma message("micros() is not available because millis is disabled from the tools subemnu. It is your responsibility to ensure a sufficient time has passed between calls to show(). See documentation.")
#endif
*/
}
// Set the output pin number

View File

@ -16,7 +16,7 @@
<Name>HSC_Wand</Name>
<RootNamespace>HackSpaceCon_AS7</RootNamespace>
<ToolchainFlavour>Native</ToolchainFlavour>
<KeepTimersRunning>true</KeepTimersRunning>
<KeepTimersRunning>false</KeepTimersRunning>
<OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam>
@ -43,7 +43,8 @@
<avrtool>com.atmel.avrdbg.tool.snap</avrtool>
<avrtoolserialnumber>021038102RYN</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x1E9227</avrdeviceexpectedsignature>
<avrtoolinterface>UPDI</avrtoolinterface>
<avrtoolinterface>
</avrtoolinterface>
<com_atmel_avrdbg_tool_snap>
<ToolOptions>
<InterfaceProperties>

View File

@ -34,15 +34,13 @@ uint8_t rgbled[3 * RGB_COUNT];
void conf_rgb_timer()
{
// this timer will run at half speed.
// so 8MHz / 2 (prescale) / 1 (CLK_PER) = 4MHz
// this will allow a full cycle time of ~61Hz.
_PROTECTED_WRITE(CLKCTRL_MCLKCTRLB, 0); // disable CLK_PER divider
// so 8MHz / 2 (timer prescale) / 2 (CLK_PER) = 2MHz
// this will allow a cycle time with 33333 counts to be 60Hz.
disable_rgb_timer();
TCB0.CTRLA = TCB_CLKSEL_CLKDIV2_gc; // prescale timer to run at half speed
TCB0.CCMP = 0xffff; // count to full
TCB0.CCMP = 33333 - 1; // count to full
TCB0.CNT = 0;
}