Em thiết kế mạch để chạy thử trên Proteur thì nó bão lỗi như ảnh phía dưới.E gửi cả project lên trong đo có File hex các bác xem hộ em nó bị lỗi gì mà nó lại báo "Can't create or open card image file".Cảm ơn các bác trước
Thông báo
Collapse
No announcement yet.
Giúp em về lỗi MMC
Collapse
X
-
Chạy giả lập thế này ko ổn đâu.
Tuy nhiên tui có thể giúp bạn fix lỗi này. Bởi vì cái MMC nó dùng 1 file để giả lập nên dùng file bình thường không được đâu. Down cái WinImage ở đây để tạo file cho nó: http://www.winimage.com/winimage.htm|
Comment
-
- Mô phỏng MMC trên proteus V7 Sp2> ổn mà, tuy nhiên nó chỉ ổn ở phần ghi theo kiểu dữ liệu raw thôi, chứ không theo fat phiếc gì hết. Cậu chỉ có thể kiểm tra đã ghi vào block thế nào, dữ liệu trên một block thế nào ... thôi, chứ không thể burn ngược từ file ảnh MMC sang một cái MMC thật rồi đút vào PC để check lại etc..
- Có một cách tạo file ảnh cho MMC, nếu winimage không tạo trực tiếp file ảnh cho MMC dạng *.MMC thì có thể save ảnh của nó dưới dạng raw ( tôi dùng All Image V1.1 down trên www.download.com), sau đó save lại dạng *.img, đổi đuôi thành *.MMC là không thắc mắc gì nữa.
Tôi chưa test thử, vì đang trong giai đoạn tìm hiểu nốt mấy cái FAT. Có một đoạn mô phỏng cho MMC ở dưới. Bạn nào hứng thú thì down
- Proteus có nhiều cái chuối, nhưng có rất nhiều cái hay. Check thử sample có phần data logging qua HDD ATA cũng hay phết. Nó cho phép tự tạo device dựa theo chuẩn giao tiếp, dữ liệu ... cơ màAttached FilesMồm chó vó ngựa
Comment
-
Nguyên văn bởi sonbka2002 Xem bài viếtGiờ thì làm lý thuyết chạy ầm ầm đcọ ghi Oki nhưng khổ lỗi khi ráp mạch thì nó lại không đọc ghi được vào MMC.bác có kinh nghiệm gì không ?
Comment
-
Diagram thì phía trên em đã Post.còn Code 2 File xử lý với MMC thì đây
Code:#include <Avr/io.h> #include "mmc.h" #include "uart.h" #include "rprintf.h" #include "debug.h" #include<stdio.h> char FAT_SECTOR_BUFFER_ADDR[512]; int main() { int i =0; uartInit(); // initialize UART (serial port) uartInitBuffers(); uartSetBaudRate(9600); // set UART speed to 9600 baud rprintfInit(uartSendByte); // configure rprintf to use UART for output rprintf("Hello World\r\n"); delay_ms(100); char buff[512]; #define MMC_DEBUG mmcTest(); // mmcInit(); // mmcReset(); // mmcRead(0,buff); // for(i =1;i<=32;i++) // { // buff[i]=i+64; // } // memset(buff,'A',512); // mmcWrite(0,buff); // rprintfStr(buff); } void delay_ms(unsigned short ms) { unsigned short outer1, outer2; outer1 = 200; while (outer1) { outer2 = 1000; while (outer2) { while ( ms ) ms--; outer2--; } outer1--; } } void mmcTest(void) { u32 sector=1; u08 buffer[0x200]; u08 buffRead[0x200]; int c; int i =0; for(i =1;i<=512;i++) { buffer[i]=65; } // initialize MMC interface mmcInit(); mmcReset(); // print new prompt rprintf("\r\nNhap vao ma : I-Init r-Read w-Write >"); // testing loop while(1) { // check for keypress if((c=uartGetByte()) != -1) { rprintf("%c",c); switch(c) { case 'i': // initialize card rprintf("\r\nResetting MMC/SD Card\r\n"); mmcReset(); break; case 'r': // read current sector into buffer rprintf("\r\nRead Sector %d\r\n", sector); mmcRead(sector, buffRead); delay_ms(3000); for(i =1;i<=512;i++) { rprintf("%c",buffRead[i]); } // print buffer contents //debugPrintHexTable(0x200, buffer); break; case 'w': // write current sector with data from buffer rprintf("\r\nWrite Sector %d\r\n", sector); mmcWrite(sector, buffer); delay_ms(3000); break; // move to new sector case '+': sector++; rprintf("\r\nSector = %d", sector); break; case '-': sector--; rprintf("\r\nSector = %d", sector); break; case '*': sector+=512; rprintf("\r\nSector = %d", sector); break; case '/': sector-=512; rprintf("\r\nSector = %d", sector); break; case '\r': default: break; } // print new prompt rprintf("\r\nNhap vao ma : I-Init r-Read w-Write >"); } } }
Code:/*! \file mmc.c \brief MultiMedia and SD Flash Card Interface. */ //***************************************************************************** // // File Name : 'mmc.c' // Title : MultiMedia and SD Flash Card Interface // Author : Pascal Stang - Copyright (C) 2004 // Created : 2004.09.22 // Revised : 2006.06.12 // Version : 0.1 // Target MCU : Atmel AVR Series // Editor Tabs : 4 // // NOTE: This code is currently below version 1.0, and therefore is considered // to be lacking in some functionality or documentation, or may not be fully // tested. Nonetheless, you can expect most functions to work. // // This code is distributed under the GNU Public License // which can be found at http://www.gnu.org/licenses/gpl.txt // //***************************************************************************** //----- Include Files --------------------------------------------------------- #include <avr/io.h> // include I/O definitions (port names, pin names, etc) #include <avr/interrupt.h> // include interrupt support #include "global.h" // include our global settings #include "spi.h" // include spi bus support #include "rprintf.h" #include "mmc.h" // include project-specific hardware configuration #include "mmcconf.h" // Global variables // Functions void mmcInit(void) { // initialize SPI interface spiInit(); // release chip select sbi(MMC_CS_DDR, MMC_CS_PIN); sbi(MMC_CS_PORT,MMC_CS_PIN); } u08 mmcReset(void) { u08 i; u08 retry; u08 r1=0; retry = 0; do { // send dummy bytes with CS high before accessing for(i=0;i<10;i++) spiTransferByte(0xFF); // resetting card, go to SPI mode r1 = mmcSendCommand(MMC_GO_IDLE_STATE, 0); #ifdef MMC_DEBUG rprintf("MMC_GO_IDLE_STATE: R1=0x%x\r\n", r1); #endif // do retry counter retry++; if(retry>10) return -1; } while(r1 != 0x01); // TODO: check card parameters for voltage compliance // before issuing initialize command retry = 0; do { // initializing card for operation r1 = mmcSendCommand(MMC_SEND_OP_COND, 0); #ifdef MMC_DEBUG rprintf("MMC_SEND_OP_COND: R1=0x%x\r\n", r1); #endif // do retry counter retry++; if(retry>100) return -1; } while(r1); // turn off CRC checking to simplify communication r1 = mmcSendCommand(MMC_CRC_ON_OFF, 0); #ifdef MMC_DEBUG rprintf("MMC_CRC_ON_OFF: R1=0x%x\r\n", r1); #endif // set block length to 512 bytes r1 = mmcSendCommand(MMC_SET_BLOCKLEN, 512); #ifdef MMC_DEBUG rprintf("MMC_SET_BLOCKLEN: R1=0x%x\r\n", r1); #endif // return success return 0; } u08 mmcSendCommand(u08 cmd, u32 arg) { u08 r1; // assert chip select cbi(MMC_CS_PORT,MMC_CS_PIN); // issue the command r1 = mmcCommand(cmd, arg); // release chip select sbi(MMC_CS_PORT,MMC_CS_PIN); return r1; } u08 mmcRead(u32 sector, u08* buffer) { u08 r1; u16 i; // assert chip select cbi(MMC_CS_PORT,MMC_CS_PIN); // issue command r1 = mmcCommand(MMC_READ_SINGLE_BLOCK, sector<<9); #ifdef MMC_DEBUG rprintf("MMC Read Block R1=0x%x\r\n", r1); #endif // check for valid response if(r1 != 0x00) return r1; // wait for block start while(spiTransferByte(0xFF) != MMC_STARTBLOCK_READ); // read in data for(i=0; i<0x200; i++) { *buffer++ = spiTransferByte(0xFF); } // read 16-bit CRC spiTransferByte(0xFF); spiTransferByte(0xFF); // release chip select sbi(MMC_CS_PORT,MMC_CS_PIN); // return success return 0; } u08 mmcWrite(u32 sector, u08* buffer) { u08 r1; u16 i; // assert chip select cbi(MMC_CS_PORT,MMC_CS_PIN); // issue command r1 = mmcCommand(MMC_WRITE_BLOCK, sector<<9); #ifdef MMC_DEBUG rprintf("MMC Write Block R1=0x%x\r\n", r1); #endif // check for valid response if(r1 != 0x00) return r1; // send dummy spiTransferByte(0xFF); // send data start token spiTransferByte(MMC_STARTBLOCK_WRITE); // write data for(i=0; i<0x200; i++) { spiTransferByte(*buffer++); } // write 16-bit CRC (dummy values) spiTransferByte(0xFF); spiTransferByte(0xFF); // read data response token r1 = spiTransferByte(0xFF); if( (r1&MMC_DR_MASK) != MMC_DR_ACCEPT) return r1; #ifdef MMC_DEBUG rprintf("Data Response Token=0x%x\r\n", r1); #endif // wait until card not busy while(!spiTransferByte(0xFF)); // release chip select sbi(MMC_CS_PORT,MMC_CS_PIN); // return success return 0; } u08 mmcCommand(u08 cmd, u32 arg) { u08 r1; u08 retry=0; // send command spiTransferByte(cmd | 0x40); spiTransferByte(arg>>24); spiTransferByte(arg>>16); spiTransferByte(arg>>8); spiTransferByte(arg); spiTransferByte(0x95); // crc valid only for MMC_GO_IDLE_STATE // end command // wait for response // if more than 8 retries, card has timed-out // return the received 0xFF while((r1 = spiTransferByte(0xFF)) == 0xFF) if(retry++ > 8) break; // return response return r1; }
Comment
-
Khi toi viet code cho AVR toi khong bao gio dung len nhu the nay: a = (a & (1 << b)). Toi khong biet y nghia cua lenh nay nhu the nao nua.
Tai soa khong or , xor, and, cho khoe lam vay lam chi vay
Cac bac nao hieu ro chi dum cho
Tui da thu chay roi va card doc ghi tot binh thuongLast edited by sphinx; 17-10-2007, 19:28.
Comment
-
Nguyên văn bởi onggia Xem bài viếtKhi toi viet code cho AVR toi khong bao gio dung len nhu the nay: a = (a & (1 << b)). Toi khong biet y nghia cua lenh nay nhu the nao nua.
@sonbka2002, thay con 1K trong SCH thành con 2k2, mã lệnh thứ 2 dùng cho MMC thì đúng.
Comment
-
Nguyên văn bởi phamthaihoa Xem bài viếtDịch trái b 1 lần (nhân nó với 2)
hình như phải là dịch trái 1 đi b lần rồi and với a chứ. Xin chỉ giáo rõ hơn một chút. Hình như trong C thì đối tượng phải dịch đứng trước, đối tượng dịch đứng sau. CHECK lại hộ cái, cái này mình không rõ lắm. nhưng mình thường viết đối tượng phải dịch đứng trước.
Comment
-
Nguyên văn bởi phamthaihoa Xem bài viếtTớ khuyên thật, cầm mỏ hàn đê, đừng mang câu hỏi giả lập bằng proteus nên diễn đàn để hỏi. Chạy thật, lỗi thật thì còn biết đường mà trả lời.
Comment
Bài viết mới nhất
Collapse
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi mèomướpDạ thấy chú dinh... có vẻ mặn nồng với đèn sự cố nên cháu rình lúc chị hàng xóm đi vắng bắc thang trèo lên chụp mấy cái đèn nhà chị ấy ạ. Tầm vài trăm cái dùng tuýp led 220v bình thường ấy ạ. Dùng chiếu sáng thay bóng tuýp luôn Hơn...
-
Channel: Điện tử công suất
Hôm qua, 22:38 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi bqvietTheo sơ đồ bạn đã vẽ thì đây chỉ là mạch nguồn flyback không cách ly, phản hồi cả dòng lẫn áp thôi mà. Một dạng nguồn CC-CV thông dụng. Kiếm con chip tốt làm là được, nếu chịu chạy dãy LED có cách ly thì càng tốt.
Vấn đề...-
Channel: Điện tử công suất
Hôm qua, 21:56 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi dinhthuong80Phật có dạy là CHÁNH NIỆM (hay CHÍNH gì ấy, ĐT bị... rối loạn ngôn ngữ và trí nhớ, mong lượng thứ!) - CHÁNH NGỮ - CHÁNH HÀNH ĐỘNG, đó là đường hướng tới CHÁNH ĐẠO.
ĐT ngu muội nên cứ áp dụng vào điện tử: phải cố...-
Channel: Điện tử công suất
06-02-2025, 06:16 -
-
Trả lời cho [HELP] mạch cầu H inverter 100vdc to 100v ?bởi ngoctn93Em cũng có nguồn 250 đến 280vdc muốn chuyển sang 100vac bằng mạch cầu H dùng esg002. Có bác nào làm rồi chỉ em hoặc bán em với ạ. Em xin cảm ơn ạ
-
Channel: Điện tử công suất
05-02-2025, 23:00 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi mèomướpCháu thấy chú nhat... viết toàn cái gì gì ấy ạ khó hiểu ghê, chắc mai cháu phải đi hỏi mấy anh chị lớp lớn hơn xem sao ạ. Những việc lớn tầm cỡ thì hông phải ai cũng có đủ kiến thức, thời gian, sức khỏe, tiền bạc, đam mê, kiên...
-
Channel: Điện tử công suất
05-02-2025, 22:11 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi nhathung1101Bác bảo ai lớn tờ iếng tiếng?
Hùng là không nhé. Chỉ bảo tận tình chứ không tận diệt.
Yêu kỹ thuật nên vẫn tham gia cho vui thôi. Mấy của nợ này dùng con PIC hai chục ngàn còn ngon luôn....-
Channel: Điện tử công suất
05-02-2025, 21:38 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi vi van phamThôi mà, anh em giúp đỡ nhau, có gì mà lớn tiếng?
Ai không chịu giúp đỡ nhau thì vào đây nhậu với tui. Bà xã hôm nay ngũ sớm tui được tự do, solo buồn quá, Nhathung,Dinhthuong ,Đinh Vặn gì đó tui cân tuốt.-
Channel: Điện tử công suất
05-02-2025, 21:16 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi nhathung1101Thằng I Lôn Mút nó sắp đưa người lên sao Hỏa rồi.
Mấy anh em vẫn bàn cái "Một Phát Phải Thôi" thì nẫu quá.
Ngâm cứu cái gì cho đáng đi. Còn tôi nói gì hơi quá thì xin lỗi nhé.-
Channel: Điện tử công suất
05-02-2025, 19:45 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi nhathung1101Và tôi thấy cái này như con bò sữa thôi mà. Nếu xét nguyên lý.
Bóp bóp bóp... đến hết thì thôi. Cái mạch thì nguồn sơ đẳng. Con để bóp thì vu nó lại cáo cào cao.
Ắc qui hay pin thì vưỡn giá nào xào nấy. Inverter thì...-
Channel: Điện tử công suất
05-02-2025, 19:33 -
-
Trả lời cho Giúp em về mạch MPPT và Solar Panel với!?bởi nhathung1101Chip hay trở? Chip tôi có vài bịch để từ trước tết, mai giặt.
Trở thì tồn vài cân. Toàn hàng đặt, sai số 1%.
Nhưng ở đây ko buôn bán, chỉ tặng....-
Channel: Điện tử công suất
05-02-2025, 19:14 -
Comment