Jump to content
ELFORUM - Forumul Electronistilor
unuldinei

SD Card si Atmega32 wav player

Recommended Posts

Salutare , de cateva zile ma chinui cu schema unui indian ... http://blog.vinu.co.in/2012/02/tv-remote-controller-high-quality.html

Am pus de toate si sunt lipite correct. Am recompilat codul cu Atmel Studio 6 . Am formatat cardul FAT 16 (sub MSDOS) dar nu-l vede . Afisajul arata mesajele de initializare dar cand verifica locatia 0x36 valoarea e nula.

 

void fat16_init()            //BOOT SECTOR SCANNING//{    mmc_read_sector(0);    clear();    LINE1;    if((mmc_buf[0x36] == 'F') && (mmc_buf[0x39] == '1') && (mmc_buf[0x3a] == '6'))    string("FAT16 DETECTED",1);//mesaj pe lcd    else {        string("NOT A FAT16",1); //mesaj pe lcd     //   while(1);    }

 

Am incercat sa citesc sectorul 0 de 512 octeti si sa-l afisez pe LCD, dar valorile din buffer-ul pe care-l am in soft sunt toate zero , de unde trag concluzia ca de fapt nu citeste nimic .

Am reluat cu un proiect nou cu rutinele de pe situl http://www.avrprojects.info/avr-interfacing/reading-and-writing-sd-card-using-atmega16/ cu device-ul afferent .

Aceeasi interfata fizica (pin la pin, port la port) , insa de aceasta data initializarea sdcard-ului nu se mai face .

void ini_SD(void) {     char i;     PORTB |= _BV(CS);                    //disable CS     for(i=0; i < 10; i++)        SPI_sendchar(0xFF);                // Send 10 * 8 = 80 clock pulses 400 kHz     PORTB &= ~(_BV(CS));                 //enable CS     for(i=0; i < 2; i++)        SPI_sendchar(0xFF);                // Send 2 * 8 = 16 clock pulses 400 kHz     Command(0x40,0,0,0x95);              // resetidle_no:     if (Command(0x41,0,0,0xFF) !=0) //     goto idle_no;                        //idle = L?   !!!!AICI RAMANE BLOCAT!!!!     SPCR &= ~(_BV(SPR0));                //fosc/4}

De aici nu mai stiu ... Daca cineva a facut un proiect cu sdcard care a mers , cu ce fel de sdcard, cu ce fel microcontroller si cu ce biblioteci sau functii a reusit sa lucreze cu sdcard-ul respectiv.

Va multumesc, chiar daca nu ati ajuns sa cititi pana aici!

Share this post


Link to post
Share on other sites

Ei da pana la urma am reusit sa citesc sectiunea de inceput

-------------------------------------------------------SDCARD 2GB primii 512 octeti-------------------------------------------------------0000: eb3c904d53444f53352e300002400800 .<[email protected]: 0200020000f8ec003f00ff003f000000 ........?...?...0020: c1ef3a008000297d0a40b84e4f204e41 ..:...)}[email protected] NA0030: 4d4520202020464154313620202033c9 ME    FAT16   3.0040: 8ed1bcf07b8ed9b800208ec0fcbd007c ....{.... .....|0050: 384e247d248bc199e83c01721c83eb3a 8N$}$....<.r...:0060: 66a11c7c26663b07268a57fc750680ca f..|&f;.&.W.u...0070: 0288560280c31073eb33c98a461098f7 ..V....s.3..F...0080: 661603461c13561e03460e13d18b7611 f..F..V..F....v.0090: 608946fc8956feb82000f7e68b5e0b03 `.F..V.. ....^..00a0: c348f7f30146fc114efe61bf0000e8e6 .H...F..N.a.....00b0: 00723926382d741760b10bbea17df3a6 .r9&8-t.`....}..00c0: 6174324e740983c7203bfb72e6ebdca0 at2Nt... ;.r....00d0: fb7db47d8bf0ac9840740c487413b40e .}.}[email protected]: bb0700cd10ebefa0fd7debe6a0fc7deb .........}....}.00f0: e1cd16cd19268b551a52b001bb0000e8 .....&.U.R......0100: 3b0072e85b8a5624be0b7c8bfcc746f0 ;.r.[.V$..|...F.0110: 3d7dc746f4297d8cd9894ef2894ef6c6 =}.F.)}...N..N..0120: 06967dcbea030000200fb6c8668b46f8 ..}..... ...f.F.0130: 6603461c668bd066c1ea10eb5e0fb6c8 f.F.f..f....^...0140: 4a4a8a460d32e4f7e20346fc1356feeb JJ.F.2....F..V..0150: 4a525006536a016a10918b4618969233 JRP.Sj.j...F...30160: d2f7f691f7f64287caf7761a8af28ae8 ......B...v.....0170: c0cc020accb80102807e020e7504b442 .........~..u..B0180: 8bf48a5624cd136161720b4075014203 [email protected]: 5e0b497506f8c341bb000060666a00eb ^.Iu...A...`fj..01a0: b0424f4f544d4752202020200d0a5265 .BOOTMGR    ..Re01b0: 6d6f7665206469736b73206f72206f74 move disks or ot01c0: 686572206d656469612eff0d0a446973 her media....Dis01d0: 6b206572726f72ff0d0a507265737320 k error...Press 01e0: 616e79206b657920746f207265737461 any key to resta01f0: 72740d0a00000000000000accbd855aa rt............U.

Iar problema mea era ca functia pe care o aveam citea de la zero . Ei bine pentru cardurile pana in 2GB formatate FAT (adica FAT16) citirea primului sector se face de la octetul 63 , adica in softul WAV PLAYER functia asta arata asa

void mmc_read_sector(unsigned long int sector){   /* Numarul magic pe care nu-l stiam 63, la alte SD Card-uri am vazut ca ar fi 129*/    sector +=63;        int i;     sector *= 512;    command(17, sector, 0xff);    while (spi_read() != 0);    while (spi_read() != 0xfe);    for(i = 0; i < 512; i++)    mmc_buf[i] = spi_read();    spi_write(0xff);    spi_write(0xff);}

 

Iar o aplicatie foarte utila pentru read/write cam orice http://mh-nexus.de/en/hxd/.

Share this post


Link to post
Share on other sites
Guest Nicola Bogdan

Ai reusit sa-l faci? sunt curios cum citeste 192kb/s...

Share this post


Link to post
Share on other sites

Din pacate playerul nu mai e la mine , a fost transformat intr-o harpa cu 8 lasere si tot din pacate stiu ca la 48KHz 8 bit stereo zgomotul de cuantizare inca era sesizabil , mai sus nu am incercat deoarece era prea lent pentru ce-mi trebuia mie. Dar intradevar daca urci frecventa , zgomotul de cuantizare devine insesizabil si practic ai calitate de CD player  cu redare PWM . Si mare atentie ! CARDUL se formateaza FAT (adica FAT16) si depinde foarte mult de producator unde si cum are acel offset al sectoarelor , la mine dupa cum ai vazut era 63 ..{ /* Numarul magic pe care nu-l stiam 63, la alte SD Card-uri am vazut ca ar fi 129*/

sector +=63;

Edited by unuldinei

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.