DosOnChip interface code anybody

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Has anybody managed to get DOSonChip working under SPI on an Mega128? I have the SparkFun breakout board.

I've modeled my attempt on the 8085 code available from DosOnChip. Have read helpful words at: http://forum.sparkfun.com/viewto...

Happy to post working code as soon as I crack it. Anybody else struggling?

My setup is as follows:

// clock: default high, phase: rising edge
SPCR = (1<<SPE)|(1<<MSTR)|(1<<CPOL)|(1<<CPHA);
SPSR &= ~(1<<SPI2X);

// toggle the reset line
DOS_PORT1 &= ~(1<<DOS_RESET); // lower the reset line
hwdelay(100);
DOS_PORT1 |= (1<<DOS_RESET); //

// wait for chip to become ready
for (junk=DOS_HANDSHAKE_OFF; junk==DOS_HANDSHAKE_OFF; ) {
DOC_SEL
junk = spi_transfer(DOS_HANDSHAKE_POLL);
DOC_DESEL
}

Never exits the above loop.
ChipSel, Clock, and MOSI all scope out as expected.
No response on MISO

//Mike

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CAVEAT EMPTOR:
I received this feedback from one of DosOnChip's suppliers SparkFun:

Hi,
Thanks for checking with us on this. The DOS on chip board is a decent enough board. But is hard to support anymore. We do not have direct contact with any one involved with the product. We have been carrying another product that works well as a substitute for the dos on chip. It can be found here.
http://www.sparkfun.com/commerce...
Thanks,
Timothy

DosOnChip has a website with no "contact us" or "support" links. Further research reveals a skype address which seems to be busy.

As always, happy to retract, correct any/all of this if DosOnChip contacts me to refute.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well from what it looks like, messing with all of the SPI mess is what was to be partially avoided by going for an integrated solution.

Unfortunately, it seems as if that DOC doesn't provide that.

After banging my head into the wall for at least 5 work hours trying to get a SD card working, I looked into the products you mentioned.

It seems as if the uDrive is the way to go, especially if you have spare UARTs. It is also $30, which is outrageous considering they aren't keen on selling the chip itself to hobbyists.

I'd fight tooth and nail to get SF to take back the DOC and send you a uDrive. Good luck!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hah! SF won't take it back because I soldered onto it. I'm really not sure how I could have discovered the shortfalls without actually using it - or at least soldering the SPI link.

The attraction of DOC was that it encapsulated all the FAT32 stuff and could access a 32Gig card, and wouldn't soak up another serial port. I think it is highly likely that it works fine with SPI if you can figure out the initialization. They have SPI code for an 8051 which I slavishly converted to AVRland, but clearly got the polarity and phase settings inverted, but getting them right didn't solve it either.

I'm still hoping that someone will spring out of the woodwork shouting "RTFM" and pointing me at the pertinent information.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have managed to communicate with the DOC, but my code sucks. I was just supposed to write some code showing that the PCB I made works, then another guys were supposed to write the real software, but he never did.

The code I have is very messy as it is just for testing and includes a lot of other tests for an accelerometer and a LCD.

Just wanted to say it is possible. To that I can add that it sucks. It is very slow, and took some time to understand how to do it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have no clue to what I have done, it was a very long time ago.

//___________________________________________________________________
// Read data from DOSonCHIP
//___________________________________________________________________
void readDOSonCHIP(unsigned char print, unsigned char row, unsigned char numberOfChars ) {
        unsigned char dataBuffer[40];
        unsigned char data;
        unsigned char bufferCounter=0;
        unsigned char color=0b00011111;
        if ( SD_DIR==0 && SD_BUSY==0 ) {
                // SPI Type: Master
                // SPI Clock Rate: 2*500,000 kHz
                // SPI Clock Phase: Cycle Half
                // SPI Clock Polarity: Low
                // SPI Data Order: MSB First
                SPCR=0x51;
                SPSR=0x01;
                SD_CS=0;
                delay_us(5);
                do {
                        data=spi(0xFF);
                        if (data<0x7F && data>0x1F && data!='>' && print==1 && bufferCounter
        initDOSonCHIP();
        readDOSonCHIP(0, 6, 0);
        
        // plot DOSonChip
        carrigeReturn_lcd();
        color=0b00011111;
        wrightSignBold_lcd('D'-32, color, 5);
        wrightSignBold_lcd('O'-32, color, 5);
        wrightSignBold_lcd('S'-32, color, 5);
        wrightSignBold_lcd('o'-32, color, 5);
        wrightSignBold_lcd('n'-32, color, 5);
        wrightSignBold_lcd('C'-32, color, 5);
        wrightSignBold_lcd('h'-32, color, 5);
        wrightSignBold_lcd('i'-32, color, 5);
        wrightSignBold_lcd('p'-32, color, 5);
        wrightSignBold_lcd(':'-32, color, 5);
        
        if ( SD_BUSY==0 ) {
                // SPI Type: Master
                // SPI Clock Rate: 2*500,000 kHz
                // SPI Clock Phase: Cycle Half
                // SPI Clock Polarity: Low
                // SPI Data Order: MSB First
                SPCR=0x51; // SPI on
                SPSR=0x01;
                SD_CS=0;
                delay_us(5);
                spi('v');
                spi(0x0D);
                SD_CS=1;  
                delay_us(5);
                SPCR=0x00; // SPI off
                SPSR=0x00;
        };
        
        readDOSonCHIP(1, 6, 15);
        
        if ( SD_BUSY==0 ) {
                // SPI Type: Master
                // SPI Clock Rate: 2*500,000 kHz
                // SPI Clock Phase: Cycle Half
                // SPI Clock Polarity: Low
                // SPI Data Order: MSB First
                SPCR=0x51; // SPI on
                SPSR=0x01;
                SD_CS=0;
                delay_us(5);
                spi('t');
                spi(0x0D);
                SD_CS=1;  
                delay_us(5);
                SPCR=0x00; // SPI off
                SPSR=0x00;
        };
        
        readDOSonCHIP(1, 7, 16);

I think this just read the version of the DOC or something. But for some reason, it was all commented out in my code. I know I got this part working. But I think writing to the SD-card was just done by me writing a USART to SPI code, and I did it all from the PC using Hyper Terminal or similar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks folks. Given the tone of the feedback I've decide not to bother any more with DosOnChip.

Mike