View previous topic :: View next topic |
Author |
Message |
tiket
Joined: 14 Apr 2005 Posts: 31
|
Posted: Mon Jan 21, 2008 11:37 am Post subject: SD HW SPI not work |
|
|
HI
I'm using ATmega128+SD card with test_dos_drive.bas.
If I set in config_mmc.bas soft spi (Const cMMC_Soft =1) work correctly and in the terminal I read:
Wait for Drive
Init File System ... OK
Filesystem: 6
FAT Start Sector: 4
Root Start Sector: 24
Data First Sector: 56
Max. Cluster Nummber: 3295
Sectors per Cluster: 4
Root Entries: 512
Sectors per FAT: 10
Number of FATs: 2
but I set HW spi (Const cMMC_Soft =0) in the terminal I read:
"wait for drive" (there is a long timeout) and then the error: "error during drive init:225"
Can someone help me?
Best regards
Giorgio |
|
Back to top |
|
|
rrioja
Joined: 05 Jun 2006 Posts: 43 Location: GA, USA
|
Posted: Mon Jan 21, 2008 3:47 pm Post subject: |
|
|
Giorgio,
I have never been able to get the lib that comes with Bascom to work. I wrote my own which I am attaching. Try it and tell me if it works for you. It only supports SD cards and hardware SPI. It works very well for me with an ATmega128.
Robert |
|
Back to top |
|
|
tiket
Joined: 14 Apr 2005 Posts: 31
|
Posted: Mon Jan 21, 2008 5:03 pm Post subject: |
|
|
Hi Robert,
thanks for the library. Can you send me an example how to use this library with avr_dos?
best regards
Giorgio |
|
Back to top |
|
|
rrioja
Joined: 05 Jun 2006 Posts: 43 Location: GA, USA
|
Posted: Tue Jan 22, 2008 1:51 pm Post subject: |
|
|
Giorgio,
I have used my library with AVR-DOS but I don't have any sample code at the moment. However, I am sending you a program called MAIN.bas that INCLUDEs a module called CONFIG_SD.bas which calls my library. MAIN uses INPUT and PRINT statements so you can control the SD card through BASCOM's terminal emulator.
As I recall, there is a CONFIG_AVR-DOS.bas that comes with AVR-DOS that you would use with your own program. Just make sure that everything points to my library instead of the libraries that come with BASCOM.
When I have time, I will add much more to my library to make it more robust. For example, none of the libraries (including mine) handle well hardware errors in the card. There are ways of implementing hardware error checking and I will do it in the near future.
Let me know how you progress.
Robert |
|
Back to top |
|
|
rrioja
Joined: 05 Jun 2006 Posts: 43 Location: GA, USA
|
Posted: Tue Jan 22, 2008 2:00 pm Post subject: |
|
|
Giorgio,
I forgot to send you the attached file. It is a schematic showing how I connect the SD card (running at 3.3V) to my ATmega128 (running at 5V). If your AVR runs on 3.3V then you don't need this circuit and you can connect the SD directly to the AVR.
Robert |
|
Back to top |
|
|
|