Hello everyone. This is my first post so hopefully I put this in the right spot.
I am trying to design an AVR audio player that plays around 4-8 short recordings. about 4 seconds max.
I just need to know if I need to upgrade from what I have or if I'm doing something wrong in my code. I haven't been able to find much in regards to the Attiny412 and sample projects so I've been kinda winging it.
1. The quality doesn't have to be great, just enough to be able to understand speech. (8000Hz 8-bit audio) Sample rate can be lower if necessary
2. the data has to be stored either internally or on SPI flash. I guess i could go the sd card route but this thing has to be mass produced so I kinda wanna keep it cheap without a sd card slot and all.
3. The AVR has to be fast enough for either PCM audio playing or DAC output.
4. The entire thing has to be around 5 dollars max, maybe 8 if i cant get anything that cheap.
If anyone has any experience with anything like this please let me know an alternative I can go with or help me with what I have already.
I was initially trying to use an attiny412 and a 4Mbit SPI flash chip to play sounds but for some reason the audio that I get out of it is all garbled. I programmed the flash chip with my RPi and every page in memory has values that correspond to a sine wave. The most ive ever gotten was the shape of a sine wave on my oscilloscope when playing it from the AVR but the signal has these spikes where the signal is higher than it should be in that spot (its also quite a long time, not just a really quick blip.) If anyone has ever used a really old storage oscilloscope with a bad ADC it looks similar. Like some of the bits are stuck. Only I know that's not the case because I've tried multiple chips. I have uploaded the source code for this project that I have for the 412. Please ignore any weird things in the code because I have been troubleshooting this for weeks and haven't found a solution and cleaned it up.
Basically, It runs a counter that triggers an interrupt every time a sample should be taken (~8000hz normally but i slowed it down for my scope). When the interrupt occurs, the SPI transfer is initiated and it sends a read opcode followed by 3 address bytes and then I write to the data buffer again to receive data from the chip. I know that you're supposed to disable the DAC before writing data to it but I have tried that as well and no luck.
Thanks for your time.