NoOneYouKnow
Member
Hello! Several years ago I received some excellent help with an ammo counter project, and I would like to add to it.
Basically, I was using a PIC12F629 to simulate gunfire. Here's what I came up with thanks to som excellent assistance.
It works great, so that's no issue. What I would like to do now, is add audio playback. Basically, I need it to playback a very small audio file each time the trigger is pulled, along with the flash.
Now, I've seen several projects involving PIC audio playback;
https://www.dmitry.gr/index.php?r=05.Projects&proj=02.%20Single-chip%20audio%20Player
https://www.enide.net/webcms/index.php?page=pcm2pwm
https://nerdclub-uk.blogspot.com/2012/10/playing-audio-with-pic-16f1825.html
https://www.uchobby.com/index.php/2008/07/21/dspic-wav-player/
Unfortunately, despite my greatest efforts, I cannot get any of the code to work in SourceBoost with BoostC.
Could someone help me figure this all out? Fortunately my hardware skills are excellent, but my understanding of programming is terrible. I do know that I would like to stick to a PIC similar in structure to the PIC12F629, and if possible, I would like to store the audio file on a flash ic.
Any help would be massively appreciated!
Basically, I was using a PIC12F629 to simulate gunfire. Here's what I came up with thanks to som excellent assistance.
Code:
#include <system.h>
#include <PIC12F629.h>
#include <boostc.h>
#pragma DATA _CONFIG, _CPD_OFF&_CP_OFF&_BODEN_OFF&_MCLRE_OFF&_PWRTE_ON&_WDT_OFF&_INTRC_OSC_NOCLKOUT
#pragma CLOCK_FREQ 4000000
void main()
{
cmcon = 7; // Comparator off, digital I/O
trisio = 0b00100100; // All Output, GP5/2 input
gpio = 0; // Make all outputs '0'
option_reg.NOT_GPPU = 0; // Enable weak pull-ups
wpu = 0; // All Pull-ups Off
wpu.5 = 1; // Enable GP5 Pull-Up
wpu.2 = 1; // Enable GP2 Pull-Up
for(;;) // Forever
{
if(gpio.5 ==0) // Debounce Check
{
delay_ms(50);
if(gpio.5 == 0) // While GP5 switch held low
{
gpio.4 = 0; // GP4 LED Off
delay_ms(10); //
gpio.4 = 1; // GP4 LED On
delay_ms(35); //
gpio.4 = 0; // GP4 LED Off
delay_ms(122); //
}
}
}
}
It works great, so that's no issue. What I would like to do now, is add audio playback. Basically, I need it to playback a very small audio file each time the trigger is pulled, along with the flash.
Now, I've seen several projects involving PIC audio playback;
https://www.dmitry.gr/index.php?r=05.Projects&proj=02.%20Single-chip%20audio%20Player
https://www.enide.net/webcms/index.php?page=pcm2pwm
https://nerdclub-uk.blogspot.com/2012/10/playing-audio-with-pic-16f1825.html
https://www.uchobby.com/index.php/2008/07/21/dspic-wav-player/
Unfortunately, despite my greatest efforts, I cannot get any of the code to work in SourceBoost with BoostC.
Could someone help me figure this all out? Fortunately my hardware skills are excellent, but my understanding of programming is terrible. I do know that I would like to stick to a PIC similar in structure to the PIC12F629, and if possible, I would like to store the audio file on a flash ic.
Any help would be massively appreciated!