ISD4004 voice chip C51 driver source code

/ * spi isd4004.h * /
#include "reg51.h"
#include "intrins.h"

sbit _cs = p0 ^ 0;
sbit _sclk = p0 ^ 3;
sbit _mosi = p0 ^ 1;
sbit _miso = p0 ^ 2;
sbit _rac = p0 ^ 4;
sbit _int = p0 ^ 5;


void delay (unsigned int i) // Delay procedure
{
while (i--);
}

void stopmode () // stop
{
unsigned char m, i, j;
_cs = 1;
_sclk = 0;
_cs = 0;

m = 0x30;
for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_mosi = cy;
_sclk = 0;
_sclk = 1;
}
_cs = 1;
}
void powerdown () // Power off
{
unsigned char m, i, j;
_cs = 1;
_sclk = 0;
_cs = 0;

m = 0x10;
for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_mosi = cy;
_sclk = 0;
_sclk = 1;
}
_cs = 1;
}

void powerup () power on
{
unsigned char m, i, j;
_cs = 1;
_sclk = 0;
_cs = 0;

m = 0x20;
for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_mosi = cy;
_sclk = 0;
_sclk = 1;
}
_cs = 1;
}
void record4004 (unsigned int address) recording address--recording address 0 --- 2400
{
unsigned char i, m, j;
unsigned int datasoute = 0;


powerup ();
delay (5118); // Power on delay
powerup ();
delay (5118); // Power on delay
delay (5118); // Power on delay
_cs = 1;
_sclk = 0;
m = 0xa0;
_cs = 0;
for (i = 0; i <16; i ++)
{
address = _iror_ (address, 1);
datasoute = address << 1;
_mosi = cy;
_sclk = 0;
_sclk = 1;
}
for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_mosi = cy;
_sclk = 0;
_sclk = 1;
}
_cs = 1;
_sclk = 0;
m = 0xb0;
_cs = 0;

for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_mosi = cy;
_sclk = 0;
_sclk = 1;
}
_cs = 1;
p0 = 0xff;
datasoute = 0;
while (_int == 1) // Store address newline flag
{
if (_rac) {delay (20000); datasoute ++;} // Record the number of lines occupied by this recording (that is, how big this recording is)
//
// You should add your own program here, that is, the recording exit program
//
}
} // while end;

void audioout (unsigned int address) // Playback program
{
unsigned char i, m, j;
unsigned int datasoute;


powerup ();
_cs = 1;
_sclk = 0;
_cs = 0;
m = 0xe0;
for (i = 0; i <16; i ++)
{
address = _iror_ (address, 1);
datasoute = address << 1;
_sclk = 0;
_mosi = cy;
_sclk = 1;
}
for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_sclk = 0;
_mosi = cy;
_sclk = 1;
}

_cs = 1;
_sclk = 0;
m = 0xf0;
_cs = 0;
for (i = 0; i <8; i ++)
{
m = _cror_ (m, 1);
j = m << 1;
_sclk = 0;
_mosi = cy;
_sclk = 1;
}
_cs = 1;

p0 = 0xff;
while (_int == 1)
{
} // while end;
}

main ()
{
record4004 (0);
audioout (0);
while (1);
}

Maintenance Free Nickel-Cadmium Battery

Maintenance Free Nickel-Cadmium Battery

Maintenance Free Battery,low maintenance nicd battery

Henan Xintaihang Power Source Co.,Ltd , https://www.taihangbattery.com

Posted on