Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FabScope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Z Yuan
FabScope
Commits
99270fa2
Commit
99270fa2
authored
6 years ago
by
Ben Z Yuan
Browse files
Options
Downloads
Patches
Plain Diff
update for xmega proto1
parent
19de9d82
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fabscope_proto1.pdf
+0
-0
0 additions, 0 deletions
fabscope_proto1.pdf
firmware/main.c
+14
-15
14 additions, 15 deletions
firmware/main.c
firmware/makefile
+3
-0
3 additions, 0 deletions
firmware/makefile
with
17 additions
and
15 deletions
fabscope_proto1.pdf
0 → 100644
+
0
−
0
View file @
99270fa2
File added
This diff is collapsed.
Click to expand it.
firmware/main.c
+
14
−
15
View file @
99270fa2
...
...
@@ -133,16 +133,16 @@ void ADC_Init()
ADCA
.
CTRLA
=
ADC_ENABLE_bm
;
// enabled, no DMA, no started conversion, no flush
ADCA
.
CTRLB
=
(
1
<<
4
);
// high impedance, no limit, signed, non-freerunning, 12-bit right
ADCA
.
REFCTRL
=
ADC_
BANDGAP
_bm
;
//
Internal 1v ref
ADCA
.
REFCTRL
=
(
ADC_
REFSEL1_bm
)
|
(
ADC_REFSEL0
_bm
)
;
//
AREFB
ADCA
.
EVCTRL
=
0
;
// no events
ADCA
.
PRESCALER
=
ADC_PRESCALER_DIV4_gc
;
ADCA
.
PRESCALER
=
ADC_PRESCALER_DIV
6
4_gc
;
ADCA
.
CALL
=
ReadSignatureByte
(
0x20
)
;
//ADC Calibration Byte 0
ADCA
.
CALH
=
ReadSignatureByte
(
0x21
)
;
//ADC Calibration Byte 1
_delay_us
(
400
);
// Wait at least 25 clocks
ADCA
.
CH0
.
CTRL
=
ADC_CH_GAIN_
1
X_gc
|
1
;
ADCA
.
CH0
.
MUXCTRL
=
0
;
// ADC0
ADCA
.
CH0
.
CTRL
=
ADC_CH_GAIN_
4
X_gc
|
ADC_CH_INPUTMODE_DIFFWGAIN_gc
;
ADCA
.
CH0
.
MUXCTRL
=
ADC_CH_MUXPOS_PIN0_gc
|
ADC_CH_MUXNEG_PIN4_gc
;
ADCA
.
CH0
.
INTCTRL
=
0
;
// no interrupt
}
...
...
@@ -150,22 +150,21 @@ int32_t ADC_Read(void)
{
int32_t
res
=
0
;
// throw away
5
reading
s
and
averag
e the next
128 (software denoising attempt)
// throw away
1
reading and
tak
e the next
one
for
(
uint8_t
i
=
0
;
i
<
5
;
i
++
)
{
//
for(uint8_t i = 0; i <
1
; i++) {
ADCA
.
CH0
.
CTRL
|=
ADC_CH_START_bm
;
// Start conversion
while
(
ADCA
.
INTFLAGS
==
0
)
;
// Wait for complete
ADCA
.
INTFLAGS
=
ADCA
.
INTFLAGS
;
// writing 1 to INTFLAGS clears it
}
//
}
for
(
uint8_t
i
=
0
;
i
<
128
;
i
++
)
{
ADCA
.
CH0
.
CTRL
|=
ADC_CH_START_bm
;
// Start conversion
while
(
ADCA
.
INTFLAGS
==
0
)
;
// Wait for complete
ADCA
.
INTFLAGS
=
ADCA
.
INTFLAGS
;
// writing 1 to INTFLAGS clears it
res
+=
ADCA
.
CH0RES
;
}
return
res
>>
7
;
//for(uint8_t i = 0; i < 1; i++) {
ADCA
.
CH0
.
CTRL
|=
ADC_CH_START_bm
;
// Start conversion
while
(
ADCA
.
INTFLAGS
==
0
)
;
// Wait for complete
ADCA
.
INTFLAGS
=
ADCA
.
INTFLAGS
;
// writing 1 to INTFLAGS clears it
res
=
ADCA
.
CH0RES
;
//}
return
res
;
}
/** Configures the board hardware and chip peripherals for the demo's functionality. */
...
...
This diff is collapsed.
Click to expand it.
firmware/makefile
+
3
−
0
View file @
99270fa2
...
...
@@ -49,3 +49,6 @@ program-dfu: $(TARGET).hex
program-avrisp2
:
$(TARGET).hex
avrdude
-p
$(
MCU
)
-c
avrisp2
-U
flash:w:
$(
TARGET
)
.hex
program-avrisp2-dfu-fuses
:
avrdude
-p
$(
MCU
)
-c
avrisp2
-U
fuse2:w:0xBF:m
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment