1. USBasp programmer
-
You can use your AD2 with Waveforms as an AVR ISP programmer.
1.1. OSX
Instructions for Mac OSX, including avr-gcc
and avrdude
:
https://bytes.usc.edu/ee109/macos-64-bit-toolchain/
1.2. Windows 10
Windows 10 apparently needs a USB driver for things to work properly.
-
Download
zadig-2.7.exe
from https://zadig.akeo.ie/ -
Run the program (as an Admin) and select the
libusbK
driver. -
Then, when using
avrdude
, use the following options:+-
avrdude -P usb -c usbasp
(and other options for your particular target,-p m128ra1a
or-p attiny85
) -
-U flash:w:filename.hex:i
is the option to program the flash from your HEX file.
-

1.3. USBasp dongle notes
USBasp - USB programmer for Atmel AVR controllers — the original design.
-
JP2
:
The clone versions we have add a 3.3 V voltage regulator to power the target at: 5 V, or 3.3 V, or none (target provides its own power).-
Use the none option when programming your SRXE.
-
-
Shorting
JP1
connects theRST
pin on the programming header to the programmer’s ATmega8. This lets you re-program the programmer with new firmware.
2. Porting ShortSquawker to an RTOS
-
Figure out the the original version!
-
Convert to tasks that operate independently of each other. Maybe add some communication between each task.
FreeRTOS documentation
[handout of the ISR code]
The Entire runtime is tick()'d by the TIMER0_COMPA interrupt which happens at 10 kHz or every 100 μs. That ISR needs to always finish in less than 100 μs!
-
OCR1A
sets the output signal’s duty cycle using the Timer1 hardware connected to the speaker pin. -
timer_count
is a static variable that counts how many times the ISR has run since reset.-
Difference between
static
variable inside a function vs. a "global" variable in C.
-
-
The ADC is handled every
ADC_PERIOD
ticks, ⇒
Resulting period / frequency ⇒ -
The input button is handled every
INPUT_PERIOD
ticks, ⇒
Resulting period / frequency ⇒
2.1. ISRs and sample rates
General principle: code for an ISR should be as short (time) as possible. It should only handle exactly the parts that need that level of deterministic and precise timing. Be prepared to justify why you may choose to violate this principle! → Document this decision in the code itself. |
Therefore, the Arduino version of ShortSquawker is horrible :(
Output sample rate must be smooth with no timing jitter.
Input sample rate (ADC) should have small timing jitter.
2.2. Improvements
-
Move the sound output ON/OFF decision out of the ADC handling block.
-
Also better handle the alternating tone feature.
-
-
Use a double-buffer for updating the
OCR1A
value.-
DO NOT call
signal_synth()
from the ISR (why?)
-
-
Is there a better way to handle user button input detection?