??? 10/24/08 20:58 Read: times |
#159330 - some more details Responding to: ???'s previous message |
Per Westermark said:
1) You say you don't have any success - but you do not say what happens in comparison to what you expected to happen. i'm trying to use a sd card to store some data. you can talk to your sd card using spi. To do this you have to send it some commands and the sd card normally gives corresponding answers. The sd card never answers... i've tried different cards. Per Westermark said:
2) All your delays are based on a for loop without any synchronization with real hardware. Get rid of it immediately and base your timing on something measureable - for example looking at the ticks of a timer. right. But, the ds89c420 is the master here in the transaction and gives the tempo. the spi protocol is synchronous. Per Westermark said:
3) Why so varying indentation? Try not to mix tabs and spaces. It is often best to configure the editor to use spaces for indentation. That is always repeatable when you open the source code in another program, or when you post the code on a web page. Mea Culpa... One more thing learn today... Per Westermark said:
4) Have you spent any time with an oscilloscope, checking what happens with your signals or what baudrate you get? i simulated it on logic analyzer made by Keil ... seems good. ( for the lines going to the sd card) On real hardware, my scope is showing same signals. but nothing coming from the sd card side Per Westermark said:
5) Why do you write while (1) { if (i==0) break; i--; } instead of using a do { ... } while (condition); loop or rewriting to use a for (x;y;z) { ... } loop or possibly a while (nbre_byte--) { ... } loop? ok, will be done Per Westermark said:
6) You have an array spidata[] that you assign values to (in reverse order to kind of confuse the situation a bit). Then you call your write function spireadwrite() to emit the 6 bytes. But the spireadwrite() function do: spitmp=spidata; ... spidata=spitmp; What do you think the first assign should do? spidata[] is an array, or basically equivalent to a pointer. spitmp is not a pointer, but a char variable. What do you think the second assign is expected to do? How where you planning on stepping through the 6 elements in the spidata[] array? spitmp=spidata[_i_]; ... spidata[_i_]=spitmp; i don't know why the [_i_] don't survive the copy paste (may be html ?) Thanks for your remarks, my next code will be more " pure " Gonzague |
Topic | Author | Date |
bit banged spi on ds89C420 for sd card | 01/01/70 00:00 | |
Some notes about the code | 01/01/70 00:00 | |
some more details | 01/01/70 00:00 | |
Have you found the "real" specification? | 01/01/70 00:00 | |
Keil logic analyzer | 01/01/70 00:00 | |
GIGO - verify with the so-called standard | 01/01/70 00:00 | |
I agree ! | 01/01/70 00:00 | |
More comments | 01/01/70 00:00 | |
some answers | 01/01/70 00:00 | |
Have you considered.... | 01/01/70 00:00 | |
3V3 to 5V is easily accomplished ..![]() | 01/01/70 00:00 | |
To Show My Point | 01/01/70 00:00 |