I've been trying to get Roman's Btc 1 bit sound encoding to work with a pic but all I hear is noise. Below is my code and attached is the output of pin RA5. Please let me know if there is anything wrong. The sound sample is at 8KHz and the pic is running at 8Mhz/4=2Mhz a cycle.
const char sound_data[] =
{0xAB,0x54,0xAB,0x29,0xAD,0x52,0x55,0xB5
,0x2A,0xD5,0x29,0x5D,0xA8,0x8B,0xB6,0x92
...
...
}
#define testbit_on(data,bitno) ((data>>bitno)&0x01)
OPTION = 0b11001000; // bit 4 set means no prescale
T0IE = 1; //enable TMR0 overflow interrupts
ei(); // enable global interupts
char c_bit =7;
int i =0;
char byte = 0;
for (;
{
count = 0;
if(f_Play)
{
if (c_bit<=0)
{
c_bit=7;
i++;
}
if (byte = sound_data)
{
RA5 = testbit_on(byte,c_bit);
}
f_Play=0;
c_bit--;
}
}
void interrupt Timer0_ISR(void)
{
T0IF=0; //clear TMR0 flag
f_Play=1;
}
const char sound_data[] =
{0xAB,0x54,0xAB,0x29,0xAD,0x52,0x55,0xB5
,0x2A,0xD5,0x29,0x5D,0xA8,0x8B,0xB6,0x92
...
...
}
#define testbit_on(data,bitno) ((data>>bitno)&0x01)
OPTION = 0b11001000; // bit 4 set means no prescale
T0IE = 1; //enable TMR0 overflow interrupts
ei(); // enable global interupts
char c_bit =7;
int i =0;
char byte = 0;
for (;
{
count = 0;
if(f_Play)
{
if (c_bit<=0)
{
c_bit=7;
i++;
}
if (byte = sound_data)
{
RA5 = testbit_on(byte,c_bit);
}
f_Play=0;
c_bit--;
}
}
void interrupt Timer0_ISR(void)
{
T0IF=0; //clear TMR0 flag
f_Play=1;
}
Attachments
-
23.6 KB Views: 77