How to change port/pin definitions? in library file? (ethernet & microVGA)

Hi Everyone,

i'm trying to use the latest ethernet shield, the one with micro sd card, with the microVGA module. on a Arduino Uno

I've successfully used the microVGA module before, with the library modifications found in the old forum.

but I also want to connect the ethernet module, this is where the trouble starts.

some pins are shared....

MICROVGA:
this is taken from the arduino_uvga.c file found in the library
#define DD_SS 2 // PB2 | Arduino Digital 10 *
#define DD_MOSI 3 // PB3 | Arduino Digital 11
#define DD_MISO 4 // PB4 | Arduino Digital 12
#define DD_SCK 5 // PB5 | Arduino Digital 13 *
#define DD_RDY 0 // PB0 | Arduino Digital 8

ETHERNET SHIELD PINS found in the old forum:
D2 - Ethernet interrupt (optional with solder bridge "INT")
D4 - SD SPI CS
D10 - Ethernet SPI CS *
D11 - Not connected (but should be SPI MOSI)
D12 - Not connected (but should be SPI MISO)
D13 - SPI SCK *
A0 - SD Write Protect
A1 - SD Detect

i thought it would be best to change the arduino_uvga.c file because the microVGA module is connected with wires.

now what do i change the code in? to use other ouputs so the modules don't interfere with each other?

The microVGA library uses SPI, and multiple devices can be connected to it at the same time, as long as they are not transmitting simultaneously. You only need to change the CS/SS pin in the UVGA library to an unused pin, and make sure that one device is always deselected before another is selected.

D11 - Not connected (but should be SPI MOSI)
D12 - Not connected (but should be SPI MISO)

What do you mean by this? The ethernet shield talks to arduino over SPI, using 11 and 12 as MOSI and MISO.

bilbo:
The microVGA library uses SPI, and multiple devices can be connected to it at the same time, as long as they are not transmitting simultaneously. You only need to change the CS/SS pin in the UVGA library to an unused pin, and make sure that one device is always deselected before another is selected.

D11 - Not connected (but should be SPI MOSI)
D12 - Not connected (but should be SPI MISO)

What do you mean by this? The ethernet shield talks to arduino over SPI, using 11 and 12 as MOSI and MISO.

Well it's what i found in the old forum, it seems that information was wrong...

maybe i should further clarify what i'm trying to do here...

this is the ethernet adapter code working:

//net
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xAF };
byte ip[] = { 192,168,1,121 };

byte server[] = { 195, 211, 72, 36 }; 
//twitter 199.59.149.230
//google  74.125.79.104
//thepaintjob 195.211.72.36

// Initialize 
Client client(server, 80);

void setup() {
  //net
  Ethernet.begin(mac, ip);
  //serial
 Serial.begin(9600);
  
}

void loop()
{
  if (client.available()) {
    char c = client.read(); 
     Serial.print(c);
          
           if (c == '^') {
                Serial.println();
               
                }
           }
           
          

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    client.stop();
    delay(5000);
    Ethernet.begin(mac, ip);
    if (client.connect()) {
        // Make a HTTP request:
        client.println("GET /~deb5250/other/arduino/twit.php");
    } 
    else {
      //Serial.println("connection failed");
  }
  }
}

this is what i would want to do,

//vga
#include <arduino_uvga.h>
#include <conio.h>

//net
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xAF };
byte ip[] = { 192,168,1,121 };

byte server[] = { 195, 211, 72, 36 }; 
//twitter 199.59.149.230
//google  74.125.79.104
//thepaintjob 195.211.72.36

// Initialize 
Client client(server, 80);

void setup() {
  //net
  Ethernet.begin(mac, ip);
   //vga
   microvga_init();
   clrscr();
  
}

void loop()
{
  if (client.available()) {
    char c = client.read(); 
     _putch (c);
  }       

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    client.stop();
    delay(5000);
    Ethernet.begin(mac, ip);
    if (client.connect()) {
        // Make a HTTP request:
        client.println("GET /~deb5250/other/arduino/twit.php");
    } 
    else {
      //Serial.println("connection failed");
  }
  }
}

still i need to modify the microVGA library so it will work together with the ethernet shield, i'm not sure how to change it according to you suggestion:

You only need to change the CS/SS pin in the UVGA library to an unused pin, and make sure that one device is always deselected before another is selected.

i understand i need to change the following:

#define DD_SS     2   // PB2   | Arduino Digital 10 *

but if 2 represents digital output 10 how would i change it to use output 7?

#define DD_SS 2 // PB2 | Arduino Digital 10 *
but if 2 represents digital output 10 how would i change it to use output 7?

Try to follow the code in the library how DD_SS value 2 is mapped upon Arduino pin 10.

The defines reference bitnumbers of PORTB e.g. PB2 ==> P=Port B=B 2 = bitnumber

Read - http://www.arduino.cc/en/Reference/PortManipulation - it fits this whole list of defines

#define DD_SS 2 // PB2 | Arduino Digital 10 *
#define DD_MOSI 3 // PB3 | Arduino Digital 11
#define DD_MISO 4 // PB4 | Arduino Digital 12
#define DD_SCK 5 // PB5 | Arduino Digital 13 *
#define DD_RDY 0 // PB0 | Arduino Digital 8

you can change #define DD_SS 2 // PB2 | Arduino Digital 10 * to #define DD_SS 1 // PB2 | Arduino Digital 9

succes

Did you get this working? And if so, what did you change?

I would be interested in this for making public displays, using the Ethernet Shield to receive messages and the microVGA for displaying them on a 19" monitor (which is in my opinion the cheapest way to display text)