реклама на сайте
подробности

 
 
> Работа с MMC в Codevision
Krik99
сообщение Jun 19 2009, 17:14
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 45
Регистрация: 11-05-08
Из: Украина
Пользователь №: 37 411



Вот начал переделывать эту либу http://www.captain.at/electronic-atmega-mmc.php под CodeVision и вроде всё ОК, только как сделать в их функции чтения чтобы можно было выбирать сектор для чтения? Подскажите плиз, может кто уже делал с этой либой, а то хочется чтобы всё правельно работал. За ранние спасибо!

Сообщение отредактировал Krik99 - Jun 19 2009, 17:15


--------------------
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
Krik99
сообщение Jun 20 2009, 05:33
Сообщение #2


Участник
*

Группа: Участник
Сообщений: 45
Регистрация: 11-05-08
Из: Украина
Пользователь №: 37 411



Код
....
char Command(unsigned char befF, unsigned int AdrH, unsigned int AdrL, unsigned char befH ){    // sends a command to the MMC
    SPI(0xFF);
    SPI(befF);
    SPI((unsigned char)(AdrH >> 8));
    SPI((unsigned char)AdrH);
    SPI((unsigned char)(AdrL >> 8));
    SPI((unsigned char)AdrL);
    SPI(befH);
    SPI(0xFF);
    return SPI(0xFF);    // return the last received character
}  

int MMC_Init(void) { // init SPI
    unsigned char i;                
    PORTB.4=1; // disable MMC
    // start MMC in SPI mode
    for(i=0; i < 10; i++) SPI(0xFF); // send 10*8=80 clock pulses
    PORTB.4=0; // enable MMC

    if (Command(0x40,0,0,0x95) !=1) goto mmcerror; // reset MMC

st: // if there is no MMC, prg. loops here    
    if (Command(0x41,0,0,0xFF) !=0) goto st;
    return 1;
mmcerror:      
    return 0;
}  
.....
int sendmmc(void) { // send 512 bytes from the MMC via the serial port
    unsigned int i;  
    usart_tx_text("MMC read \r\n");
    // 512 byte-read-mode
    if (Command(0x51,0,512,0xFF)!= 0){usart_tx_text("MMC: read error 1 \r\n"); return 1; }
    // wait for 0xFE - start of any transmission
    // ATT: typecast (char)0xFE is a must!
    while(SPI(0xFF)!=(char)0xFE);
        
    for(i=0; i < 512; i++) {
        while(!(UCSRA & (1 << 5))); // wait for serial port
        UDR = SPI(0xFF);  // send character
    }    
        usart_tx_text("\r\n");
    // at the end, send 2 dummy bytes
    SPI(0xFF); // actually this returns the CRC/checksum byte
    SPI(0xFF);
    return 0;
}
......

Да ну переписывать весь код, вот мой подскажите плиз что надо изменить.


--------------------
Go to the top of the page
 
+Quote Post

Сообщений в этой теме


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 25th July 2025 - 20:12
Рейтинг@Mail.ru


Страница сгенерированна за 0.01358 секунд с 7
ELECTRONIX ©2004-2016