.


:




:

































 

 

 

 


 

() _________

 

:

(, )

..

_____________________

 

 

___ (_________________)

____ _____________2011

 

 

- 2011

 

1. . 2

1.1. . 3

2. . 4

2. . 11

2.1. . 11

2.2. . 12

2.3. . 13

2.4. . 14

2.5. DataFlash. 17

2.6. . 18

2.7. . 22

3. .. 24

4. : 26

5. . 35

6. . 36

 


, , , AVR , AT45DB161 DataFlash .

AT45DB161 DataFlash 2.7 - . 16 4096 528 . DataFlash 2 SRAM 528 . DataFlash .

AT45DB161 SPI . , , , . DataFlash , . DataFlash SPI 13 4 . DataFlash ( 2.7 3.6).

DataFlash (SPI), , DataFlash AVR .

AVR AT90S8535 . SPI / DataFlash. . - (<550 ), AT90S2333 (28- 2 -).


 

 

  • 8-
  • 8
  • 4
  • 4 1/4
  • 550

 


 

DataFlash, . .


1.

-, ( 1) , ( 2). , . ( -), , , . , . .


2.

3000 . () .

3000 , 6000 . . , RC-, . .

, , . ( 3). . , 256 8- 10 . . . , .. (3 8 ). AT90S8535 , AGND AREF .


3.

, , , .

. , / (SNR) .

4 , . .


4.

, . . , . max ( 5).


5.

8 . DataFlash.

DataFlash . , DataFlash . ( 200K bps), , . , 8 . , , .

, . , , . .

, .

DataFlash 1. (528 ), 529 . , . , , DataFlash. , .

DataFlash. , .

DataFlash , . , ( , ), , , DataFlash . , 510 8- .

, . , . , , . DataFlash .


6.

- (). 6, 2 3 . : - , (8 ), - . , , . .

, , , . , , , ( ).

, , .


7.

4000 , (15.686 ).

.

8 , 10- 3922 (8 / 2? 210 = 3922 ), 7843 9- , 15.686 8- .

(15.686 ) , 4000 . , 10- 8-.

. , 8. ( , .. 8 ) , ( 1).


8.


9.

, : , . , VCC PD0PD2. GND.

LED, .

DataFlash AVR SPI. ISP AVR, Chip Select(#CS) DataFlash . ISP , .

, AVCC, VCC RC- . AVCC.

(22 ) .


10.

. R1 R9 ( = R1/R9). R4 , C1 DC . R2 R3 . R5 8 . R5 , .

.

(R6, R7, R8, C2, C7 R7, R10, R11, C9, C5) (R11, C4). () . 4000 , (15.686 ).

.

C3 DC .

, . setup ().

SPI , , , . , AVR , DataFlash . AT90S8535, , , SS I/O.

SPI AT90S8535 PortB (PB5PB7). , DataFlash PortB (PB0PB2 PB4). (PB3) LED. , Serial Clock(SCK), Master Out/Slave In(MOSI), Chip Select(#CS), Write Protect(#WP) Reset(#RST) , Master In/Slave Out(MISO) Ready/Busy(RDY/#BSY) . PB3 LED PortB, 0xBD.

PortB : , - .

AT90S8535 PortA. PortA .

PortD . Timer1 PD4.

. , (ADC Timer1 Overflow), , .

, . , LED , , .

, , .

, LED , , .


11.


 

Data Flash .

12.

erase (), , , DataFlash.

SPI DataFlash. . DataFlash : MIB , AT90S8535 - .

DataFlash SCK, , #CS (SPI 0), SCK, , #CS (SPI 3), . SPI 3. , , SPI 2 , 8 .

, #CS DataFlash, (), 0x50, 9- 13 . . , SPI (SPSR) , SPI , . , #CS , . Ready/Busy DataFlash , , . , . , 512 . 0xFF.

, . ADC0, , (ADMUX) . (ADCSR) 32, , , . - . , (832 448). , , , , .

15.686 . , () .

15.686 , 510 (15.686 x 510 = 8 ). , 510 32. 14 . 14 x 32 = 448 .

, . 62 (510448), .

10- , 2 . 10 AGND AREF ( 0 5). 2.3…3.5. 10- . 0x1D5 2.3. , 3.5, MSB. , , flash_data char (8-). 8- DataFlash .


13.


 

DataFlash


14. DataFlash

DataFlash , , , .

write_to_flash j , k , . , DataFlash , .

, , , .

, .

, #CS DataFlash 0x84. 14 10- . 8- .

. SPI (SPSR), SPI , . #CS .

, DataFlash. , .

, , . , , , .

, DataFlash 8- 15.686 . , , . . , 16- / 1 OC1B. / A B (TCCRA/TCCRB). , 1.

, 1, #CS DataFlash. , #CS . Ready/Busy DataFlash , , 1 . 2. , 1, DataFlash 2.

, DataFlash . SPI , SPI (SPDR) . DataFlash, SPDR AVR DataFlash.


15.

0, 1 . DataFlash . AVR, , 1 . / 1 B (OCR1B), , (255 8- ).

, .

, / 1 .

16.


17.

. , , AREF.

, DataFlash, , . .

.

(.. wait playback). . , ACIS1 ( (ACSR)) , .

15.686 ( 510 ), . (/ 0 / 2), .


 

1.
Timer 1 8- Timer 1 ( )
3 I/O PORT B SPI DataFlash  
4 I/O PORT B DataFlash  
1 I/O PORT B LED  
1 I/O PORT A
3 I/O PORT D  
1 I/O PORT D  

:

2.

R1 10 Chip Select DataFlash
R2 1 LED
R3 100
LED  
C1, C2 22
C3 100
8
AT45DB161 DataFlash 16
AVR AT90S8535 RISC -

3.

R1 10
R2 10
R3 10
R4 1
R5 12 RC-
R6 5
R7 1
R8 470
R9 1
R10 15
C1 1
C2 1
C3 1
C4 22 RC-
C5 100
C6 100
C7 1
C8 4.7 RC-
C9 2.2
U1 LM324
2 - 3.5  
  3.5
  3.5

 

4. :

/* . 1. ,

. DataFlash 1 2

.

*/

 

#include io8535.h

#include

#include stdlib.h

#include dataflash.h

 

//

void setup (void);

void erasing (void);

void recording (void);

void interrupt[ADC_vect] sample_ready (void);

void write_to_flash (unsigned char ad_data);

void playback (void);

void next_page_to_next_buffer (unsigned char active_buffer, unsigned int page_counter);

void interrupt[TIMER1_OVF1_vect] out_now(void);

void active_buffer_to_speaker (unsigned char active_buffer);

 

//

volatile unsigned char wait = 0;

 

 

void setup(void)

{

DDRB = 0xBD; // SPI

// SCK, MISO, MOSI, CS, LED, WP, RDYBSY, RST

// PB7, PB6, PB5, PB4, PB3, PB2, PB1, PB0

// O I O O O O I O

// 1 0 1 1 1 1 0 1

PORTB = 0xFF; // ,

(LED )

DDRA = 0x00; // Port A

PORTA = 0x00;

DDRD = 0x10; // Port D (D4: )

 

_SEI(); //

}

 

 

void erasing(void)

{

unsigned int block_counter = 0;

unsigned char temp = 0x80;

ACSR |= 0x02; // , ,

 

// , SPI , , MSB, 3 SPI, Fcl/4

SPCR = 0x5C;

 

while (block_counter < 512)

{

PORTB &= ~DF_CHIP_SELECT; // DataFlash

SPDR = BLOCK_ERASE;

while (!(SPSR & temp)); //

SPDR = (char)(block_counter>>3);

while (!(SPSR & temp)); //

SPDR = (char)(block_counter<<5);

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

PORTB |= DF_CHIP_SELECT; // DataFlash

 

block_counter++;

while(!(PINB & 0x02)); //

}

SPCR = 0x00; // SPI

}

 

 

void recording(void)

{

// , SPI , , MSB, 3 SPI, Fcl/4

 

SPCR = 0x5C;

ADMUX = 0x00; // = 0

ADCSR = 0xDD; // , fCK/32,

while (!(PIND & 8)); //

( 3)

 

ADCSR = 0x00; //

SPCR = 0x00; // SPI

}

 

 

void interrupt[ADC_vect] sample_ready(void)

{

unsigned char count = 0;

 

while (count < 6) count++; //

ADCSR |= 0x40; //

write_to_flash(ADC-0x1D5); // , 8

}

 

 

void write_to_flash(unsigned char flash_data)

{

static unsigned int buffer_counter;

static unsigned int page_counter;

unsigned char temp = 0x80;

 

if((ACSR & 0x02)) // ,

{

buffer_counter = 0;

page_counter = 0; //

ACSR &= 0xFD; //

}

 

while(!(PINB & 0x02)); //

 

PORTB &= ~DF_CHIP_SELECT; // DataFlash

 

SPDR = BUFFER_1_WRITE;

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

 

SPDR = (char)(buffer_counter>>8); // +

while (!(SPSR & temp)); //

 

SPDR = (char)buffer_counter; // (. 2^8 = 256

)

while (!(SPSR & temp)); //

SPDR = flash_data; // SPI

while (!(SPSR & temp)); //

 

 

PORTB |= DF_CHIP_SELECT; // DataFlash

 

buffer_counter++;

 

if (buffer_counter > 528) // ,

{

buffer_counter = 0;

if (page_counter < 4096) //

{

PORTB &= ~DF_CHIP_SELECT; // DataFlash

 

SPDR = B1_TO_MM_PAGE_PROG_WITHOUT_ERASE; //

1

while (!(SPSR & temp)); //

SPDR = (char)(page_counter>>6);

while (!(SPSR & temp)); //

SPDR = (char)(page_counter<<2);

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

 

PORTB |= DF_CHIP_SELECT; // DataFlash

 

page_counter++;

}

else

{

PORTB |= 0x08; // LED

while (!(PIND & 8)); //

( 3)

}

}

}

 

 

void playback(void)

{

unsigned int page_counter = 0;

unsigned int buffer_counter = 0;

unsigned char active_buffer = 1; // = 1

unsigned char temp = 0x80;

 

TCCR1A = 0x21; // 8 , COM1B

TCNT1 = 0x00; // 1

TIFR = 0x04; // 1

TIMSK = 0x04; // 1

TCCR1B = 0x01; // . 1 = 1

OCR1B = 0x00; // B

 

// , SPI , , MSB, 3 SPI, Fcl/4

 

SPCR = 0x5C;

 

next_page_to_next_buffer (active_buffer, page_counter); // 0

1

 

while (!(PINB & 0x02)); // 0

1

while ((page_counter < 4095)&(!(PIND & 2))) //

( 1)

{

page_counter++; //

 

next_page_to_next_buffer (active_buffer, page_counter);

active_buffer_to_speaker (active_buffer);

 

if (active_buffer == 1) // 1

{

active_buffer++; // 2

}

else //

{

active_buffer--; // 1

}

}

TIMSK = 0x00; //

TCCR1B = 0x00; // 1

SPCR = 0x00; // SPI

}

 

 

void next_page_to_next_buffer (unsigned char active_buffer, unsigned int page_counter)

{

unsigned char temp = 0x80;

while(!(PINB & 0x02)); // ,

 

PORTB &= ~DF_CHIP_SELECT; // DataFlash

 

if (active_buffer == 1) // 1

{

SPDR = MM_PAGE_TO_B2_XFER; //

2

}

else //

{

SPDR = MM_PAGE_TO_B1_XFER; //

1

}

while (!(SPSR & temp)); //

SPDR = (char)(page_counter >> 6);

while (!(SPSR & temp)); //

SPDR = (char)(page_counter << 2);

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

PORTB |= DF_CHIP_SELECT; // DataFlash

}

 

 

void interrupt[TIMER1_OVF1_vect] out_now(void)

{

wait = 0; //

}

 

 

void active_buffer_to_speaker (unsigned char active_buffer)

{

//

unsigned int buffer_counter = 0;

unsigned char temp = 0x80;

 

PORTB &= ~DF_CHIP_SELECT; // DataFlash

 

if (active_buffer == 1) // 1

{

SPDR = BUFFER_1_READ; // 1

}

else //

{

SPDR = BUFFER_2_READ; // 2

}

 

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

SPDR = 0x00; // 0

while (!(SPSR & temp)); //

SPDR = 0x00; //

while (!(SPSR & temp)); //

 

while (buffer_counter < 528)

{

SPDR = 0xFF; //

while (!(SPSR & temp)); //

while(wait); // 1

OCR1B = SPDR; //

wait = 1; //

 

buffer_counter++;

}

 

PORTB |= DF_CHIP_SELECT; // DataFlash

}

 

 

void main(void)

{

setup();

 

for(;;)

{

if (!(PIND & 8)) // ( 3)

{

PORTB &= 0xF7; // LED

recording();

}

if (!(PIND & 4)) // ( 2)

{

PORTB &= 0xF7; // LED

erasing();

while (!(PIND & 4)); //

( 2)

}

if (!(PIND & 2)) // ( 1)

{

PORTB &= 0xF7; // LED

playback();

while (!(PIND & 2)); //

( 1)

 

}

PORTB |= 0x08; // LED

}

}

 

DataFlash.h

 

// 19.04.1999

// 8535

 

#include ina90.h

#pragma language=extended

 

// DataFlash (PB 0)

#define DF_RESET 0x01

 

// DataFlash / (PB 1)

#define DF_RDY_BUSY 0x02

 

// DataFlash (PB 2)

#define DF_WRITE_PROTECT 0x04

 

// DataFlash (PB 4)

#define DF_CHIP_SELECT 0x10

 

// 1

#define BUFFER_1 0x00

 

// 2

#define BUFFER_2 0x01

 

//

 

// 1

#define BUFFER_1_WRITE 0x84

 

// 2

#define BUFFER_2_WRITE 0x87

 

// 1

#define BUFFER_1_READ 0x54

 

// 2

#define BUFFER_2_READ 0x56

 

// 1

#define B1_TO_MM_PAGE_PROG_WITH_ERASE 0x83

 

// 2

#define B2_TO_MM_PAGE_PROG_WITH_ERASE 0x86

 

// 1

#define B1_TO_MM_PAGE_PROG_WITHOUT_ERASE 0x88

 

// 2

#define B2_TO_MM_PAGE_PROG_WITHOUT_ERASE 0x89

 

// 1

#define MM_PAGE_PROG_THROUGH_B1 0x82

 

// 2

#define MM_PAGE_PROG_THROUGH_B2 0x85

 

// 1

#define AUTO_PAGE_REWRITE_THROUGH_B1 0x58

 

// 2

#define AUTO_PAGE_REWRITE_THROUGH_B2 0x59

 

// 1

#define MM_PAGE_TO_B1_COMP 0x60

 

// 2

#define MM_PAGE_TO_B2_COMP 0x61

 

// 1

#define MM_PAGE_TO_B1_XFER 0x53

 

// 2

#define MM_PAGE_TO_B2_XFER 0x55

 

// DataFlash , ,

// /

#define STATUS_REGISTER 0x57

 

//

#define MAIN_MEMORY_PAGE_READ 0x52

 

// 528

#define PAGE_ERASE 0x81

 

// 512

#define BLOCK_ERASE 0x50

 

#define TRUE 0xff

#define FALSE 0x00


 

: , (SPI) DataFlash - () .


1. Proakis, J.G. and Manolakis, D.G. (1992)

Digital Signal Processing: Principles, Algorithms, and Applications

2. Datasheets:

Atmel AVR AT90S8535



<== | ==>
| 3 . 060101
:


: 2016-10-22; !; : 385 |


:

:

.
==> ...

1456 - | 1439 -


© 2015-2024 lektsii.org - -

: 0.683 .