Commit Graph

14 Commits

Author SHA1 Message Date
Nico Tonnhofer efd8279c1a STM32F411: implement DMA for ADC
Eureka!!!
The STM32 has only one data register for all channels. So I want to use the ADC over DMA.
Issues are: It is not possible to stop the DMA or the ADC without uninit and init the hole parts.
We have more or less one option. Manually start the ADC.
So what we have now. We start the ADC after reading the values from DMA buffer. The ADC now make a conversion of all channels.
We can read also the values because it uses a double buffer mode. With that mode we can read the unused buffer.
2017-03-03 18:54:57 +01:00
Robert Konklewski 678184b037 Temp: request ADC reads only when necessary.
Issues ADC reads (via start_adc()) only when actually needed.
When EWMA is enabled, then reads are performed at every
temp_sensor_tick() call, i.e. every 10ms. That's to ensure EWMA
gets updated frequently enough.

When EWMA is disabled, then the only other use for analog reads
is heater control, i.e. heater_tick(). It's run on a 250ms clock,
so that's how often analog reads need to be performed in that
case.

Additionally, ADC conversions are being started 10ms in advance,
so that they can finish before their results are read.
2016-06-23 22:32:51 +02:00
Robert Konklewski b5cbba7ed8 Temp: read ADC on-demand, instead of constantly running.
On AVRs analog conversions were running in essentially
free-running mode, i.e.  next conversion was being started
immediately after the previous one ended. This caused many
unnecessary interrupts.

Now, conversions are initiated manually by start_adc(). This
causes a single read on each of the registered channels. Once
all channels are read, conversions stop until the next call of
start_adc().
2016-06-23 22:32:51 +02:00
Markus Hitter 56f6b381fd ARM: split out analog-avr.c from analog.c. 2015-08-12 14:26:37 +02:00
Markus Hitter 881629b74c analog.h: document and clean up.
No functional change.
2015-05-11 01:17:25 +02:00
Markus Hitter efa1e9bcbb analog.h: clamp ADC reference voltage to AVcc.
As none of the known controllers allow a meaningful other choice,
it's a bit pointless to provide this as a user choice via
config.h.
2015-05-11 01:14:22 +02:00
Phil Hord 21e5343552 Add config.h wrapper to simplify test automation
Test code which wants to customize config.h can do so without
touching config.h itself by wrapping config.h in a macro variable
which is passed in to the compiler.  It defaults to "config.h" if
no override is provided.

This change would break makefile dependency checking since the selection
of a different header file on the command line is not noticed by make
as a build-trigger.  To solve this, we add a layer to the BUILDDIR path
so build products are now specific to the USER_CONFIG choice if it is
not "config.h".
2014-03-04 19:56:23 +01:00
Phil Hord 452e2e5cd9 Restore simulation build target.
This code was accidentally removed long ago in a botched merge. This
patch recovers it and makes it build again. I've done minimal testing
and some necessary cleanup. It compiles and runs, but it probably still
has a few dust bunnies here and there.

I added registers and pin definitions to simulator.h and
simulator/simulator.c which I needed to match my Gen7-based config.
Other configs or non-AVR ports will need to define more or different
registers. Some registers are 16-bits, some are 8-bit, and some are just
constant values (enums). A more clever solution would read in the
chip-specific header and produce saner definitions which covered all
GPIOs. But this commit just takes the quick and easy path to support my
own hardware.

Most of this code originated in these commits:

	commit cbf41dd4ad
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:28:08 2010 +0200

	    document simulation

	commit 3028b297f3
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:15:59 2010 +0200

	    Add simulation code: use "make sim"

Additional tweaks:

Revert va_args processing for AVR, but keep 'int' generalization
for simulation. gcc wasn't lying. The sim really aborts without this.

Remove delay(us) from simulator (obsolete).

Improve the README.sim to demonstrate working pronterface connection
to sim. Also fix the build instructions.

Appease all stock configs.

Stub out intercom and shush usb_serial when building simulator.

Pretend to be all chip-types for config appeasement.

Replace sim_timer with AVR-simulator timer:

The original sim_timer and sim_clock provided direct replacements
for timer/clock.c in the main code. But when the main code changed,
simcode did not. The main clock.c was dropped and merged into timer.c.
Also, the timer.c now has movement calculation code in it in some
cases (ACCELERATION_TEMPORAL) and it would be wrong to teach the
simulator to do the same thing. Instead, teach the simulator to
emulate the AVR Timer1 functionality, reacting to values written to
OCR1A and OCR1B timer comparison registers.

Whenever OCR1A/B are changed, the sim_setTimer function needs to be
called. It is called automatically after a timer event, so changes
within the timer ISRs do not need to bother with this.

A C++ class could make this requirement go away by noticing the
assignment. On the other hand, a chip-agnostic timer.c would help
make the main code more portable. The latter cleanup is probably
better for us in the long run.
2013-12-06 19:24:58 +01:00
Markus Hitter 97a663a00c analog.c: trim down analog values storage.
Saves 10 bytes RAM and 16 bytes binary size on an 1284P (8 ADC
channels) running two sensors. Should also be a bit faster, as one
loop runs fewer iterations.

Also, checking for NUM_TEMP_SENSORS was a mistake, as temp sensors
_not_ using an analog pin exist. Extreme case is, temp sensors
exist, but zero ADC channels are used.
2012-09-29 23:00:11 +02:00
Michael Moon 0dc7d77885 Massive Doxygen documentation addition
'make doc' then point your browser at doc/html/

Needs plenty of cleanup and polishing, but the main bulk is here

even documents your configuration! ;)
2011-03-22 01:34:36 +11:00
Michael Moon 6a06eb7169 atmega644 has a 2.56v reference 2010-10-10 19:55:46 +11:00
Michael Moon e78381c56d Move configuration to config.h.dist 2010-09-27 09:20:07 +10:00
Michael Moon 6a58efbfa4 try out analog stuff, probably needs more work 2010-08-24 15:49:21 +10:00
Michael Moon 488e42605b skeleton of analog read subsystem 2010-08-16 14:06:37 +10:00