Main Site Documentation

Driver for Msd Shield from Watterott


#1

Hallo,

i am a newbie. Is there a way to use this shield with the panda.
At this time i use it with the “arduino uno” and the optional TFT display. I dont know, how to convert the libs for this shield.

mfg santje243


#2

Do you have a link to the shield you are talking about?


#3

He means this one: http://www.watterott.com/de/Arduino-mSD-Shield
The C++ code is offered and shouldn’t be too difficult. Take a look at the S65 Shield on Fezzer - it’s pretty similar. Both are limited by the SPI speed, which isn’t too good. Excellent candidates for RLP.
Also, the on-board SDCard is SPI-mode, which means - for the time being - that you can’t use it, since the Panda file system doesn’t allow using SPI as a transport interface.


#4

Using that will be a very bad idea! FEZ Panda support real SD card interface not over SPI bus.

See this for details on adding SD or get the new FEZ Panda II with SD card or FEZ Domino

edit: just realized the missing link http://www.microframeworkprojects.com/index.php?title=SD_Card_Connection_Guide


#5

No contest. A lot of the Arduino boards have an SPI micro-SD card holder on them - so it pains to not be able to use them. That’s life!


#6

you can solder wires to a SD to micro-SD adapter fairly simply, and wire them to the Fez Panda SD card pins. Easy way of adding what you need and lots of people have those uSD adapters lying around so it’s minimal cost (even buying a 2gb card plus adapter is only a few bucks on ebay).

Another option is http://www.instructables.com/id/Cheap-DIY-SD-card-breadboard-socket/

What Gus implies is that netmf and the GHI boards in particular supports file systems on SD card when it uses the native SD card interface, not SPI. You can still use an SPI shield but you then have to be responsible for the file system portion, which is a much bigger problem than SD vs SPI… so if you have that shield leave it in the cupboard and for a few bucks, move to either a genuine Fez solution or DIY.


#7

I’ve looked at the socket - maybe I’ll try soldering wires for the MCI. Looks pretty tiny. Panda II would have been better, but I jumped and picked up several Panda I boards. I have some SDCard boards from Futurlec (China) coming soon - I can try those as well.
I thought there might be an extension of the File Class to allow adding an SPI hardware transport, but I think the class is “married” to the MCI. Otherwise RPL would have been a good possibility.
Not a major problem - my basement is full of printers and stuff that became obsolete 5 days after I bought it :wink:


#8

I meant you could solder onto the SD-card size adapter that typical uSD cards come with - no way I’d wave a soldering iron at my original uSD card :slight_smile:


#9

Take a look at this project

http://www.microframeworkprojects.com/index.php?title=SD_Card_Connection_Guide


#10

Hi,

i´ve take a look on the S65-Shield on Fezzer, but i don´t know, how to convert the c++ lib from the MSD Shield (Watterott) to use the TFT.

Can someone help or some code snippets.

mfg santje243


#11

I tried to translate the code, but it doesn´t work.

class MSDShield2
    {
        private static SPI spiInterface;
        private static SPI.Configuration spiConfig;

        private static OutputPort lcdResetPin;
        private static OutputPort lcdCsPin;

        private static int width;
        private static int height;

        public static int Width { get { return width; } }
        public static int Height { get { return height; } }

        const int LCD_ID = 0;
        const int LCD_DATA = ((0x72) | (LCD_ID >> 2));
        const int LCD_REGISTER = ((0x70) | (LCD_ID >> 2));

        public void Setup()
        {
            width = 320;
            height = 240;

            try
            {
                spiConfig = new SPI.Configuration(Pins.GPIO_PIN_D4,
                    false,
                    0,
                    0,
                    false,
                    true,
                    1000,
                    SPI.SPI_module.SPI1);
                spiInterface = new SPI(spiConfig);
            }
            catch (Exception) { }

            try
            {
                lcdResetPin = new OutputPort(Pins.GPIO_PIN_D5, false);
                lcdCsPin = new OutputPort(Pins.GPIO_PIN_D6, true);
                lcdCsPin.Write(true);
            }
            catch (Exception) { }

            lcdResetPin.Write(true);
            Thread.Sleep(50);
            lcdResetPin.Write(false);
            Thread.Sleep(50);

            WriteCommand(0xEA, 0x0000);
            WriteCommand(0xEB, 0x0020);
            WriteCommand(0xEC, 0x000C);
            WriteCommand(0xED, 0x00C4);
            WriteCommand(0xE8, 0x0040);
            WriteCommand(0xE9, 0x0038);
            WriteCommand(0xF1, 0x0001);
            WriteCommand(0xF2, 0x0010);
            WriteCommand(0x27, 0x00A3);

            WriteCommand(0x1B, 0x001B);
            WriteCommand(0x1A, 0x0001);
            WriteCommand(0x24, 0x002F);
            WriteCommand(0x25, 0x0057);

            WriteCommand(0x23, 0x008D);

            WriteCommand(0x18, 0x0036);
            WriteCommand(0x19, 0x0001);
            WriteCommand(0x01, 0x0000);
            WriteCommand(0x1F, 0x0088);
            Thread.Sleep(5);
            WriteCommand(0x1F, 0x0080);
            Thread.Sleep(5);
            WriteCommand(0x1F, 0x0090);
            Thread.Sleep(5);
            WriteCommand(0x1F, 0x00D0);
            Thread.Sleep(5);

            WriteCommand(0x17, 0x0005);

            WriteCommand(0x36, 0x0000);

            WriteCommand(0x28, 0x0038);
            Thread.Sleep(40);
            WriteCommand(0x28, 0x003C);

            WriteCommand(0x16, 0x00A8); //set Orientation

        }

        private static ushort[] outData = new ushort[1];
        private static byte[] outByte = new byte[1];

        private static void WriteCommand(byte reg, byte param)
        {
            lcdCsPin.Write(false);
            //outData[0] = (ushort)((LCD_REGISTER << 8) | reg);
            outData[0] = (ushort)(LCD_REGISTER);
            spiInterface.Write(outData);
            outData[0] = (ushort)(reg);
            spiInterface.Write(outData);
            lcdCsPin.Write(true);

            lcdCsPin.Write(false);
            //outData[0] = (ushort)((LCD_DATA << 8) | param);
            outData[0] = (ushort)(LCD_DATA);
            spiInterface.Write(outData);
            outData[0] = (ushort)(param);
            spiInterface.Write(outData);
            lcdCsPin.Write(true);
        }

        public static void setArea(int x0, int y0, int x1, int y1)
        {
            WriteCommand(0x03, (byte)(x0 >> 0)); //set x0
            WriteCommand(0x02, (byte)(x0 >> 8)); //set x0
            WriteCommand(0x05, (byte)(x1 >> 0));
            WriteCommand(0x04, (byte)(x1 >> 8));
            WriteCommand(0x07, (byte)(y0 >> 0));
            WriteCommand(0x06, (byte)(y0 >> 8));
            WriteCommand(0x09, (byte)(y1 >> 0));
            WriteCommand(0x08, (byte)(y1 >> 8));
        }

        public void clear(UInt16 color)
        {
            uint size;

            setArea(0, 0, (width - 1), (height - 1));

            drawStart();
            for (size = (320 * 240 / 8); size != 0; size--)
            {
                draw(color);
                draw(color);
                draw(color);
                draw(color);
                draw(color);
                draw(color);
                draw(color);
                draw(color);
            }
            drawStop();
        }

        private void drawStart()
        {
            lcdCsPin.Write(false);
            outData[0] = (ushort)(LCD_REGISTER);
            spiInterface.Write(outData);
            outData[0] = (ushort)(0x22);
            spiInterface.Write(outData);
            lcdCsPin.Write(true);

            lcdCsPin.Write(false);
            outData[0] = (ushort)(LCD_DATA);
            spiInterface.Write(outData);
        }

        private void draw(int color)
        {
            outData[0] = (ushort)(color >> 8);
            spiInterface.Write(outData);
            outData[0] = (ushort)color;
            spiInterface.Write(outData);
        }

        private void drawStop()
        {
            lcdCsPin.Write(true);
        }
    }

#12

You should be able to use this:


        private static ushort[] outData = new ushort[2];
 
        private static void WriteCommand(byte reg, byte param)
        {
            outData[0] = (ushort)(LCD_REGISTER);
            outData[1] = (ushort)(reg);
            spiInterface.Write(outData);
            outData[0] = (ushort)(LCD_DATA);
            outData[1] = (ushort)(param);
            spiInterface.Write(outData);
        }

What is the link for the shield?


#13

Here is the link: http:// www.watterott.com/de/Arduino-mSD-Shield


#14

You don’t need lcdCsPin. CS pin should be first parameter of the SPI configuration. SPI implementation will take care of setting CS Pin for you.

I suggest to read about SPI in the free eBook, first:

This should help understand how SPI works.


#15

It looks like commands need packing into 2 16bit writes, not 4 bytes each :stuck_out_tongue:


#16

As I mentioned above, the S-65 Shield example on Fezzer should help. The sequence is similar, even though the actual values differ. This shows how to set up the SPI requests.
I don’t think you’ll be happy with the speed on the 240x320 screen though.


#17

we have a good story for 240x320 display on Panda :slight_smile: Stay tuned for announcements soon. You will be surprised with what little NETMF devices can do.


#18

You’ve been playing with our nerves for a week now Gus … where’s the beef?
:wink:


#19

You should have came to Embedded World and I would have been happy to show you all the cool toys :slight_smile:


#20

OK, rub it in.
Any chance the “toys” from EW will be shown as videos in internet?