我使用的是微芯片v8.63中的pic18F4550:我为picdem使用了C程序语言:我们创建了以下程序:我们检索转换为8bit 8000Hz的.wav文件的二进制数据(声音是:有人说s“red”),我们将数据写入picdem的rom。每个值将被写入端口=>;有一个盒子连接到。
问题是:我不能在这里,原来的声音(有人说s:“红色”)而不是听到一个响亮的其他声音(没有噪音或噼啪声),而是一个巨大的其他声音。
这就是代码:
unsigned int b = 0;
unsigned int i = 0;
unsigned int j= 0;
#pragma romdata const_table = 0x1200
const rom char my_const_array[] = "0b01010101
,0b10101010
,0b10101010
,0b10101010
,0b10101001
,0b01010101
,0b01010110
,0b10100101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010100
,0b10110101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01001010
,0b10101010
,0b11010101
,0b00101010
,0b10101011
,0b01010101
,0b01010101
,0b01010101
,0b01001010
,0b10101010
,0b11010100
,0b10101010
,0b10101010
,0b10110101
,0b01010101
,0b01010101
,0b01001010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101101
,0b01010100
,0b10101010
,0b10011010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10110010
,0b10100101
,0b01010110
,0b10101010
,0b10100101
,0b01011010
,0b10101010
,0b10101010
,0b11001010
,0b10010101
,0b01011010
,0b10101001
,0b01010101
,0b01101010
,0b10101010
,0b10101101
,0b00101001
,0b01010101
,0b10101010
,0b10010101
,0b01010101
,0b10101010
,0b10101010
,0b11010010
,0b10010101
,0b01011010
,0b10101001
,0b01010101
,0b01011010
,0b10010101
,0b10101101
,0b00101001
,0b01010101
,0b10101010
,0b01010100
,0b11010101
,0b10100101
,0b01011010
,0b11001010
,0b01010101
,0b01011010
,0b10100101
,0b00101101
,0b01010101
,0b01010110
,0b10110010
,0b10010011
,0b01010110
,0b10010101
,0b00101011
,0b01010101
,0b01010101
,0b01101010
,0b01010100
,0b10101011
,0b01100101
,0b00101010
,0b10110101
,0b01010101
,0b01011010
,0b10010101
,0b00101011
,0b01010101
,0b00101010
,0b10110101
,0b01010011
,0b00110101
,0b10100100
,0b10101010
,0b11010101
,0b01001010
,0b10101010
,0b11010010
,0b10101101
,0b01100100
,0b10101010
,0b11010101
,0b01001010
,0b10101010
,0b10101010
,0b10101011
,0b01101001
,0b00101010
,0b10110101
,0b01001010
,0b10101010
,0b11001010
,0b10101011
,0b01010101
,0b00101010
,0b10101101
,0b01010010
,0b10101010
,0b10110010
,0b10101010
,0b11010101
,0b00101010
,0b10101011
,0b00101010
,0b10101010
,0b10101010
,0b10101010
,0b10110101
,0b00100101
,0b01011010
,0b10101010
,0b10010101
,0b01101010
,0b10011010
,0b10101101
,0b00100101
,0b01010110
,0b10101010
,0b10010101
,0b01010110
,0b10100101
,0b10101011
,0b01001001
,0b01010101
,0b10101010
,0b10010101
,0b01010110
,0b10100101
,0b01101010
,0b10101001
,0b01010101
,0b01101010
,0b10100101
,0b01010101
,0b01100101
,0b01010110
,0b10101010
,0b01010101
,0b01010110
,0b10010101
,0b01010101
,0b01010101
,0b01010101
,0b01101010
,0b10010101
,0b01001101
,0b01010101
,0b01001011
,0b01010101
,0b01010101
,0b01010101
,0b10100100
,0b10101010
,0b11010101
,0b01010010
,0b10101011
,0b01010100
,0b10110101
,0b01010101
,0b01001010
,0b10101011
,0b01010101
,0b00101010
,0b10101010
,0b10101010
,0b10101011
,0b01010100
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101101
,0b01010010
,0b10100101
,0b10101010
,0b10101010
,0b01011010
,0b10101010
,0b10101010
,0b10110101
,0b01001010
,0b10010101
,0b10101010
,0b10101001
,0b01010110
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b01010101
,0b01011010
,0b10101010
,0b10101010
,0b01010110
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b01010101
,0b01010110
,0b10101010
,0b10101010
,0b10100101
,0b01011010
,0b10101010
,0b10101010
,0b10010101
,0b01010101
,0b10010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b00000000";
#pragma romdata
//void Delay(unsigned int);
void main (void)
{
TRISD = 0x00; // PORTD als uitgang
TRISB = 0b00110000; // RB4 en RB5 als ingang
TRISA = 0x00; // RA output
RCONbits.IPEN = 0; // prioriteit uit
INTCONbits.GIE = 1; // enable interrupt
INTCONbits.RBIE = 1; // interrupt portB aan
while(1)
{
_asm sleep _endasm
}
}
#pragma interrupt ISR
void ISR (void)
{
if (INTCONbits.RBIF==1)
{
if(PORTBbits.RB5==0)
{
TBLPTR = (short long) 0x1200;
for(i = 0 ; i<sizeof(my_const_array); i++) {
_asm TBLRDPOSTINC _endasm
LATAbits.LATA2=TABLAT;
b = 0;
do{
b++;
}while(b < 200);
}
}
}
INTCONbits.RBIF = 0;
}