با سلام.
با توجه به مشکلاتی که برای راه اندازی آی سی صدا ISD4004 وجود داشت و خودم هم درگیرش بودم ، خواستم این پروژه رو برای کمک به دوستانی که برای راه اندازی و آدرس دهی به مشکل بر خوردند تو سایت بذارم .
Chip type : ATmega16
Program type : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
************************************************** ***/
#include <mega16.h>
#include <spi.h>
#include <stdio.h>
#include <delay.h>
unsigned char POWERUP=0x20;
unsigned char REC=0xb0;
unsigned char STOP=0x30;
unsigned char PLAY=0xf0;
unsigned char SETREC=0xa0;
unsigned char SETPLAY=0xe0;
unsigned char RINT=0x30;
unsigned char SETMC=0xe8;
unsigned char MC=0xf8;
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;
// Port B initialization
// Func7=Out Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In
// State7=0 State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0xB0;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x03;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
// INT1: Off
// INT2: Off
GICR|=0x40;
MCUCR=0x02;
MCUCSR=0x00;
GIFR=0x40;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 62.500 kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: LSB First
SPCR=0x73;
SPSR=0x00;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei"
spi(POWERUP);
delay_ms(25);
PORTB.4=1;
while (1)
{
if(PINC.0==0)
{
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x00);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x0A);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x14);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x1E);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
}
if(PINC.1==0)
{
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x1E);
spi(0x00);
spi(SETPLAY);
//PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x14);
spi(0x00);
spi(SETPLAY);
// PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x0A);
spi(0x00);
spi(SETPLAY);
// PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x00);
spi(0x00);
spi(SETPLAY);
// PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
}
};
}
من خودم ازش درست جواب گرفتم میتونید آدرسهای حافظه رو خودتون تغییر بدین.
فقط یه نکته بسیار مهم هست که هر خونه حافظه 200 میلی ثانیه برای ضبط صدا جا داره البته برای ISD4004-8M . پس قبل از تغییر آدرس ها محاسبه کنید که خونه بعدی حافظه چه آدرسی باید داشته باشه.مثلا اگر اولین صدا رو خونه 0x00 حافظه ذخیره کنید و مدت ضبط صدا 5 ثانیه باشه باید خونه بعدی برای آدرستون 0x19 باشه . ( 5000 میلی ثانیه تقسیم بر 200 میلی ثانیه = خونه 25 حافظه که به هگز میشه 0x19) پس همین طور برای صداهای بعدی بر طبق زمان ضبط صدا محاسبه کنید و در برنامه بذارید .ان شا الله که جواب میگیرید چون خودم جواب گرفتم.
با توجه به مشکلاتی که برای راه اندازی آی سی صدا ISD4004 وجود داشت و خودم هم درگیرش بودم ، خواستم این پروژه رو برای کمک به دوستانی که برای راه اندازی و آدرس دهی به مشکل بر خوردند تو سایت بذارم .
Chip type : ATmega16
Program type : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
************************************************** ***/
#include <mega16.h>
#include <spi.h>
#include <stdio.h>
#include <delay.h>
unsigned char POWERUP=0x20;
unsigned char REC=0xb0;
unsigned char STOP=0x30;
unsigned char PLAY=0xf0;
unsigned char SETREC=0xa0;
unsigned char SETPLAY=0xe0;
unsigned char RINT=0x30;
unsigned char SETMC=0xe8;
unsigned char MC=0xf8;
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;
// Port B initialization
// Func7=Out Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In
// State7=0 State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0xB0;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x03;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
// INT1: Off
// INT2: Off
GICR|=0x40;
MCUCR=0x02;
MCUCSR=0x00;
GIFR=0x40;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 62.500 kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: LSB First
SPCR=0x73;
SPSR=0x00;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei"

spi(POWERUP);
delay_ms(25);
PORTB.4=1;
while (1)
{
if(PINC.0==0)
{
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x00);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x0A);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x14);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(100);
PORTB.4=0;
spi(0x1E);
spi(0x00);
spi(SETREC);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
}
if(PINC.1==0)
{
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x1E);
spi(0x00);
spi(SETPLAY);
//PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x14);
spi(0x00);
spi(SETPLAY);
// PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x0A);
spi(0x00);
spi(SETPLAY);
// PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
PORTB.4=0;
spi(POWERUP);
PORTB.4=1;
delay_ms(50);
PORTB.4=0;
spi(0x00);
spi(0x00);
spi(SETPLAY);
// PORTA.0=1;
//PORTA.0=0;
//spi(PLAY);
PORTB.4=1;
delay_ms(2000);
PORTB.4=0;
spi(STOP);
PORTB.4=1;
delay_ms(500);
}
};
}
من خودم ازش درست جواب گرفتم میتونید آدرسهای حافظه رو خودتون تغییر بدین.
فقط یه نکته بسیار مهم هست که هر خونه حافظه 200 میلی ثانیه برای ضبط صدا جا داره البته برای ISD4004-8M . پس قبل از تغییر آدرس ها محاسبه کنید که خونه بعدی حافظه چه آدرسی باید داشته باشه.مثلا اگر اولین صدا رو خونه 0x00 حافظه ذخیره کنید و مدت ضبط صدا 5 ثانیه باشه باید خونه بعدی برای آدرستون 0x19 باشه . ( 5000 میلی ثانیه تقسیم بر 200 میلی ثانیه = خونه 25 حافظه که به هگز میشه 0x19) پس همین طور برای صداهای بعدی بر طبق زمان ضبط صدا محاسبه کنید و در برنامه بذارید .ان شا الله که جواب میگیرید چون خودم جواب گرفتم.
دیدگاه