The main loop of the program is as follows. When the processor boots up, it enters the RESET vector. RESET initializes all the port settings, loads the timer 1A Compare with 666 cycles for 6000Hz sampling (in order to keep w/in Nyquist limit). The RESET vector also sets up the UART and defaults the processor to calculate "no effect".
Upon exiting RESET, the program enters the main loop where it spins, waiting for the timer 1A compare interrupt to set a flag, ADCFLAG. Once the program gets the flag, it executes the ADC code which loads in serially the data from the 1110 ADC. The code stores this value in a register called AnaLo, which is left over from when we were using the 8535 to do the ADC conversion. This value is stored in a section of external RAM called Delayline, which is the 15,000 element array where guitar samples are stored and read from. To prevent the RAM pointer from going out into the ozone, we make sure the pointer wraps back around to the begining of the array once the end is reached.
The next part of the code switches on the EFFECT register which keeps track of which special effect the processor is choosing. This code involves reading back a sample from Delayline, depending where the effect specifies, and then maybe doing a manipulation on the sample. After all the math stuff is completed, the value is then pumped out into PortB (after being Or'd with 1 to prevent messing with the ADC Chip Select), where it goes off towards the DAC. The code then goes and sits in the ADCFLAG wait loop and repeats the process indefinately, or at least as long as power is still applied.
You may be wondering how the effect gets changed if it sits in the above loop forever. The answer to that inquiry is as simple as i-n-t-e-rrupts. The two UART pins are wired to the PC running the front-end, so that when a user presses the "Send" button, it causes a RX Complete interrupt. The interrupt code looks at the effect number sent to it and determines if more parameters are needed to be recieved from the PC. If it needs more information to set-up the effect, then the code exchanges acknowledgements for more parameter variables. Once all the information is recieved into the processor, the code will return back to the main loop, or in the case of delay, set-up the Y register (which controls where data is being output from) to a new place down the delayline.
There are six special effects that are implemented by the processor. The first effect, "no effect" really isn't a special effect because it just outputs the sampled-value in real-time to the amp. The second effect is "delay" and it does just what it sounds like it should. It plays back a sample at a specified time later. This is done by having the playback poitner offset from the current sample pointer. The third effect is "spectrum inversion." By complementing every other byte, a neat effect of having the sound play down when a note is played up. The fourth effect is "volume," by where one can regulate the level of sound coming out. This is done by clipping the sample off at some threshold around the median. The fifth effect is simply called "swap" becuase it swaps the high and low nibble of the sample before being played out. This creates a really funky distortion. The sixth effect is "echo." This plays back at sample divided by two at a certain time, and another sample divided by 4 that time again later.
EE 476 - Final Project - Sp '00