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.exefrom https://zadig.akeo.ie/ -
Run the program (as an Admin) and select the
libusbKdriver. -
Then, when using
avrdude, use the following options:+-
avrdude -P usb -c usbasp
(and other options for your particular target,-p m128ra1aor-p attiny85) -
-U flash:w:filename.hex:iis 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
JP1connects theRSTpin 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!
-
OCR1Asets the output signal’s duty cycle using the Timer1 hardware connected to the speaker pin. -
timer_countis a static variable that counts how many times the ISR has run since reset.-
Difference between
staticvariable inside a function vs. a "global" variable in C.
-
-
The ADC is handled every
ADC_PERIODticks, ⇒
Resulting period / frequency ⇒ -
The input button is handled every
INPUT_PERIODticks, ⇒
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
OCR1Avalue.-
DO NOT call
signal_synth()from the ISR (why?)
-
-
Is there a better way to handle user button input detection?