Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Programming Questions / Trouble with Serial1 port in SPI mode - Port mapping problem on 2560? on: March 02, 2013, 03:56:53 am
Hello,

I am using a Seeduino Mega 2560 mega. Very similar to Arduino mega 2560, except it has accessible headers for some of the pins that are not accessible on the Arduino mega. I am able to run the 1st serial port(Serial) in SPI mode, but I am having trouble running the 2nd serial port(Serial1) in SPI. I suspect it has to do with the missing port mappings when IDE compiles the code, but I am not sure how to fix. Can somebody give me a hint or lead on how to fix problem? 

Thanks,

-diesel

//Init
UBRR1H = 0;                                   
UCSR1A = _BV (TXC1);               
XCK1_DDR |= (1<<XCK1);                   
UCSR1C = _BV (UMSEL10) | _BV (UMSEL11);
UCSR1B = _BV (TXEN1) | _BV (RXEN1);   
UBRR1H =0;

//Transfer byte
while (!(UCSR1A & _BV (UDRE1)));
UDR1 = _data;
while (!(UCSR1A & _BV (RXC1)));
return UDR1;



2  Using Arduino / Storage / Re: SPI Sram with pointers? on: February 19, 2013, 12:49:59 am
Paul,

I am trying to use the sram with the uip network stack, which uses an a pointer to an internal sram array to compose and parse packets. I would like to use external sram instead.

Pito,

Thanks for the info, sounds interesting, the examples are what I am looking for, but I am not sure how to implement that. Yes, I agree, that would be great to have in the Arduino environment.

Thanks,

-diesel
3  Using Arduino / Storage / SPI Sram with pointers? on: February 17, 2013, 11:14:15 pm
Hello,

I recently received some 23LC1024 chips. They are 5V 1Mbit spi sram chips that I am using with an Arduino 328p. I found a library online that is pretty good http://code.google.com/p/arms22/downloads/detail?name=SPISRAM-001.zip (which I modified for 24 bit addressing). This library is nice in that it lets you address the memory as if it were an array, like myarray[address]=#, however, I was wondering is there another programming technique that I could use to work with the sram as a pointer? Could I overload operators in the library to simulate a pointer type interface? I have read that other Atmel chips have the ability to address external memory as if it were internal, but it doesn't look like this is an option with the 328p. Am I wrong, is it possible to use the XYZ registers to address the memory like a pointer?  

Thanks,

-diesel
4  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 13, 2013, 01:34:47 am
Nick,

Thanks I will give that a try. I confirmed it was xck0 pin not being accessible that was the problem on the arduino mega. Bought a seeduino mega board that has the xck0(pe2) accessible, got spi on uart working on this board.

Another question, can you switch uart line back over to serial mode by just doing Serial.begin(#)? I would think you could. Should you make any other register changes?

Thanks,

-diesel

5  Using Arduino / Networking, Protocols, and Devices / Uart port in SPI mode on Arduino Mega 1280 on: February 08, 2013, 03:12:50 pm
Hello,

I was able to operate the Uart port in SPI mode on the Arduino 328. However, when I try to run on the Arduino Mega 1280, I am unable to get it working. I believe the issue is because xck0 line is not routed to pin 4(or any pin for that matter). In fact, none of the xck# lines are routed to pins. It seems odd that none are routed to pins. Is there a way to access the functionality of these pins from another accessible pin? Could an interrupt be used?

Thanks,

-diesel
6  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 08, 2013, 12:00:15 am
Nick,

OK, I will look around and see if someone has done something like that. Thanks for your help!!

-diesel
7  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 07, 2013, 11:39:10 pm
Nick,

I can start a new post if you like? I think that I have found the problem. XCKO is not mapped to an accessible pin. Ref. http://arduino.cc/en/Hacking/PinMapping2560 (which I believe has the same mapping as the 1280). If you search on XCK, none are mapped to an accessible pin. Are there any options of accessing the function of those pins?

Thanks,

-diesel
8  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 07, 2013, 10:33:20 pm
Nick,

I hooked up the SPI ram, it works on the arudino 328p, which is great, thanks! Unfortunately, I can't get it working on the mega 1280. The registers and bits seem to be the same. I looked over the datasheets for the 328 and the 1280, they both look same w/regards to UART in SPI mode. Do you know what maybe the problem?

Thanks,

-diesel
9  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 07, 2013, 12:50:14 am
Nick,

I put a logic analyzer on both so that you could see. I attached two images, 1st with Uart SPI and 2nd with Arduino std SPI. On the Uart SPI I get 255...255,\r,\n from serial. Nothing but 255 for the array of characters. On the Arduino std SPI I get ->hello there \r\n(although not perfect). The best software serial baud seemed to be 38400, I ranged from 9600-115200( best defined by what I received from Arduino SPI) . I also tried connecting the Arduino up with only 9v power supply, disconnecting usb, I thought that might be giving me interference, no change in output, still 255 from Uart SPI. Any other suggestions? I have a arduino mega 1280, perhaps I could give that a try w/the 2nd hardware serial port. Would I have to change the registers?

Thanks,

-diesel
10  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 06, 2013, 10:08:30 am
Nick,

The plan is to use the secondary spi port to use with SPI ram. First, I want to make sure it is working, so now I am just reading and writting from SoftwareSerial. I am attempting to write and read into the SPI port, which works using the hardware spi.

Thanks, I will give the higher baud rate a try.

-diesel

11  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 06, 2013, 12:12:32 am
Nick,

I was messing around with code trying to get it to work, that is why they were different.

I modified as you suggested, but same output......,......,. I did switch back to my first listed code and noticed for a short period of time it would output ......., .......,  then it went back to hello there. Maybe it is a timing thing? I saw something in the datasheet that it talks about setting up interrupts, are those necessary?

Thanks,

-diesel
12  Using Arduino / Networking, Protocols, and Devices / Re: Setting up the second SPI port on the Arduino Uno on: February 05, 2013, 10:50:44 pm
Nick,

Thanks for posting the code to create SPI port on uart pins. I am, however, having a problem with it. I tried setting up a simple test. I am using an Arduino Uno w/no devices attached. Since I was having a problem, I tried this simple test using std SPI library, works as you would expect. I am using FTDI breakout from Sparkfun to read. hello there, hello there....

Code:
#include <SPI.h>
#include <SoftwareSerial.h>
SoftwareSerial DebugPort = SoftwareSerial(2,3);

char mystring[100]="hello there";
char mystring2[100]="";
void setup() {
  // put your setup code here, to run once:
  DebugPort.begin(9600);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.setDataMode(SPI_MODE0);
}

void loop() {
  uint8_t x=0;
  digitalWrite(SS,LOW);
 for(x;x<(strlen(mystring));x++){
  mystring2[ x ] = SPI.transfer( mystring [ x ] ) ;
 }
 digitalWrite(SS,HIGH);
 mystring2[x+1]='\0';
 DebugPort.println(mystring2);
}

*************
Then I tried a similar setup using the code you posted. On this I get an output of ......,......,...... (yes dots). Do you know what may be the problem?
************



Code:
#include <SoftwareSerial.h>
SoftwareSerial DebugPort = SoftwareSerial(2,3);
const byte MSPIM_SCK = 4;
const byte MSPIM_SS = 5;
char mystring[100]="hello there";
char mystring2[100]="";
// sends/receives one byte
char MSPIMTransfer (char c)
{
  // wait for transmitter ready
  while ((UCSR0A & _BV (UDRE0)) == 0)
    {}
    
  // send byte
  UDR0 = c;
  
  // wait for receiver ready
  while ((UCSR0A & _BV (RXC0)) == 0)
    {}
    
  // receive byte, return it
  return UDR0;
}  // end of MSPIMTransfer

// select slave, write a string, wait for transfer to complete, deselect slave
void spiWriteString (const char * str)
  {
  if (!str) return;  // Sanity Clause
  
  char c;

  // enable slave select
  digitalWrite (MSPIM_SS, LOW);
 // const char * mystr = str;
  uint8_t count =0;
  // send the string
  while (c = *str++){
   mystring[count] =MSPIMTransfer (c);
  }

  // wait for all transmissions to finish
 while ((UCSR0A & _BV (TXC0)) == 0)
    {}

  // disable slave select
  digitalWrite (MSPIM_SS, HIGH);
  }  // end of spiWriteString
 
void setup()
  {
  DebugPort.begin(9600);
  pinMode (MSPIM_SS, OUTPUT);   // SS
  // must be zero before enabling the transmitter
  UBRR0 = 0;
  UCSR0A = _BV (TXC0);  // any old transmit now complete
  pinMode (MSPIM_SCK, OUTPUT);   // set XCK pin as output to enable master mode
  UCSR0C = _BV (UMSEL00) | _BV (UMSEL01);  // Master SPI mode
  UCSR0B = _BV (TXEN0) | _BV (RXEN0);  // transmit enable and receive enable
  // must be done last, see page 206
  UBRR0 =3;// 3;  // 2 Mhz clock rate
  }  // end of setup

void loop()
  {
    
      uint8_t x=0;
  digitalWrite(MSPIM_SS,LOW);

 for(x;x<(strlen(mystring));x++){
  mystring2 [ x ] =MSPIMTransfer( mystring  [ x ] );
 }
 digitalWrite(MSPIM_SS,HIGH);
  mystring2[x+1]='\0';
  DebugPort.println(&mystring2[0]);  
}

Thanks,

-diesel

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)
13  Using Arduino / Networking, Protocols, and Devices / Re: SPI question - Scope of slave pin(s) on: February 04, 2013, 12:41:55 am
Hello,

Thanks for the replies. I think that I understand. I thought pin 6 could interfere with SPI communication, but for that to happen it would need to be hooked up to miso,mosi, and clk otherwise it has no effect on the spi port.

Thanks,

-diesel
14  Using Arduino / Networking, Protocols, and Devices / SPI question - Scope of slave pin(s) on: February 03, 2013, 11:42:03 pm
Hello,

I have a general understanding about how SPI works. I understand when your slave select pin goes low, communication begins. If you make pin 10 output high you can use another pin as the slave. Say, if you have another device on pin 4, you can switch between the two. Pulling each one low when you need it to communicate.

However, what happens if you are using another digital pin, say 6, used for a purpose other than SPI communication.  If you change that to output low, will that interfere with the communication with the other devices using SPI(if they happen to be low at the same point)? If so, is there some way to isolate pins, not permitting them to interfere with the SPI communication of the other devices?

Thanks,

-diesel

15  Using Arduino / Networking, Protocols, and Devices / Arduino wifi shield - Server mode - Get the client's remote port? on: January 22, 2013, 01:03:54 am
Hello,

I have an application using the arduino wifi shield as a server. Is there function to get the connect client's remote port in the Arduino wifi library?

I would suspect  that this information would be held in uint16_t WiFiClient::_srcport = 1024;(in WiFiClient.cpp), but it never updates when the client connects(stays 1024). I looked around the library for a command, but couldn't find anything. It appears that it would be listed in the enum in  wifi_spi.h(see enum exert below), but I don't see anything. 

enum {
   SET_NET_CMD       = 0x10,
   SET_PASSPHRASE_CMD   = 0x11,
   SET_KEY_CMD           = 0x12,
   TEST_CMD           = 0x13,

   GET_CONN_STATUS_CMD   = 0x20,
   GET_IPADDR_CMD      = 0x21,
   GET_MACADDR_CMD      = 0x22,
   GET_CURR_SSID_CMD   = 0x23,
......

Thanks,

-diesel
Pages: [1] 2 3 4