中级会员
 
- 积分
- 497
- 金钱
- 497
- 注册时间
- 2013-4-1
- 在线时间
- 25 小时
|
发表于 2014-5-10 17:59:35
|
显示全部楼层
其实还是自己找原因比较好,既然51能跑,stm32怎么可能不能跑!
// 录音地址的设定与芯片型号有关系,以ISD4004-8为例,ISD4004-8录音时间为8
// 分钟,即8*60=480S, 根据4004的资料,480秒可分为2400段,也就是1S的段数为
// 5段,即从,0000-0005H的内容为1秒。
#include "isd4004.h"
#include "stm32f10x.h"
#include "delay.h"
#include "sys.h"
void ISD_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE); //使能PA,PD端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 |GPIO_Pin_11 |GPIO_Pin_12;// 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOC, GPIO_Pin_10 |GPIO_Pin_11 |GPIO_Pin_12);//上拉
}
void play(u16 addr)
{
u16 y;
SS=0;
MOSI=0;//发送开始
SCLK=0;
for(y=0;y<8;y++)
{
SCLK=0;
if((ISDPOWERUP>>y)&0x01)
MOSI=1;
else
MOSI=0;
delay_us(3);
SCLK=1;
delay_us(3);
}//发送结束
SS=1;//上电结束
delay_ms(50);
SS=0;
MOSI=0;//发送地址
SCLK=0;
for(y=0;y<16;y++)
{
SCLK=0;
if((addr>>y)&0x01)
MOSI=1;
else
MOSI=0;
delay_us(3);
SCLK=1;
delay_us(3);
}//发送地址结束
MOSI=0;//放音
SCLK=0;
for(y=0;y<8;y++)
{
SCLK=0;
if((PLAYSET>>y)&0x01)
MOSI=1;
else
MOSI=0;
delay_us(3);
SCLK=1;
delay_us(3);
}
SS=1;
SS=0;
MOSI=0;//放音
SCLK=0;
for(y=0;y<8;y++)
{
SCLK=0;
if((PLAYCUR>>y)&0x01)
MOSI=1;
else
MOSI=0;
delay_us(3);
SCLK=1;
delay_us(3);
}
SS=1;
} |
|