Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rampinglight
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Greiner
rampinglight
Commits
424e0495
Commit
424e0495
authored
Jan 01, 2019
by
Sven Greiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix multiple or missing executions in ticks
Consumes a huge amount of flash...
parent
929262aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
rampinglight.c
rampinglight.c
+11
-4
No files found.
rampinglight.c
View file @
424e0495
...
...
@@ -102,6 +102,7 @@ enum State state __attribute__((section(".noinit")));
uint8_t
output
__attribute__
((
section
(
".noinit"
)));
uint8_t
fast_presses
__attribute__
((
section
(
".noinit"
)));
uint8_t
ramping_up
__attribute__
((
section
(
".noinit"
)));
uint8_t
lvp_overflow
__attribute__
((
section
(
".noinit"
)));
register
Options
options
asm
(
"r7"
);
register
uint8_t
output_eeprom
asm
(
"r6"
);
...
...
@@ -317,10 +318,14 @@ static uint8_t battery_voltage(void) {
ISR
(
TIM0_OVF_vect
)
{
if
(
!--
microticks
)
{
++
ticks
;
}
if
(
ticks
==
4
)
{
// ~440 ms
fast_presses
=
0
;
if
(
ticks
==
4
)
{
// ~440 ms
fast_presses
=
0
;
}
if
((
ticks
&
0x7F
)
==
14
)
{
// Every ~14 s starting after ~1.5 s
lvp_overflow
=
1
;
}
}
}
...
...
@@ -330,6 +335,7 @@ ISR(TIM0_OVF_vect) {
int
main
(
void
)
{
microticks
=
0
;
ticks
=
0
;
lvp_overflow
=
0
;
// Fast PWM, system clock with /8 prescaler
// Frequency will be F_CPU/(8*256) = 2343.75 Hz
...
...
@@ -529,7 +535,8 @@ int main(void) {
}
#ifdef LOW_VOLTAGE_PROTECTION
if
((
ticks
&
0x7F
)
==
14
)
{
// Every ~14 s starting after ~1.5 s
if
(
lvp_overflow
)
{
lvp_overflow
=
0
;
// TODO Take several measurements for noise filtering?
const
uint8_t
voltage
=
battery_voltage
();
if
(
voltage
<=
BAT_CRIT
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment