Pages: 1 [2] 3   Go Down
Author Topic: ATMega1284p issues with SD Card  (Read 2671 times)
0 Members and 1 Guest are viewing this topic.
Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's a very good description, although it still all seems inconsistenly
bizarre with the section 3.2 spec info you gave in reply #7.

Why?

Let's look at AVR chips, eg. the ATtiny85 comes in two flavors, normal and 'V':

Operating Voltage
– 1.8 - 5.5V for ATtiny25V/45V/85V
– 2.7 - 5.5V for ATtiny25/45/85


Both work at 5.5V, only one works at 1.8V. Is that also "bizarre" to you? If you were designing a PCB to work with a randomly chosen ATtiny85, what supply voltage would you choose?

If there was another variant that worked at 3.4-5.5V, what voltage would you choose?

Just because there exists a 1.8V version, doesn't mean you design to it.

I don't know if there are any 2.7V SD cards or not but when they wrote the spec they allowed for it. It doesn't mean a randomly chosen SD card will run at 2.7V.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2073
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

..so, based on this discussion - has a designer to provide a programmable VCC source (2.7-3.6V) for the sdcard in order to be safe??  smiley-confuse
« Last Edit: May 06, 2013, 07:01:46 am by pito » Logged

New York
Offline Offline
Sr. Member
****
Karma: 4
Posts: 366
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What does this have to do with Bobuino? Nothing that I can see.  I request you take Bobuino out of the title.
Hmm ok I removed it. But question was relevant and about Bobuino as well as other variants of 1284p bootloaders, and why they don't work with SD card while Sanguino version did on my version of hardware... Was hoping to get some hints, this was not meant to critique your variant smiley
« Last Edit: May 06, 2013, 07:39:55 am by bratan » Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

..so, based on this discussion - has a designer to provide a programmable VCC source (2.7-3.6V) for the sdcard in order to be safe??  smiley-confuse

You could do that ... or you can just provide 3.6V.


Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27089
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

[Edit: Bobuino removed from all titles by moderator]
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

bratan, getting back to the original problem, have you ever gotten the
RFM12s to work with any Arduino chip at all? Also, which library and sketches
are you using?
 
If you're using the jeelib s.w., from my experience, none of the sketches work
correctly, including the demo sketch. I only ever got the RFM12s to work by
using the sketches shown in the Arduino Cookbook.
Logged

New York
Offline Offline
Sr. Member
****
Karma: 4
Posts: 366
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

bratan, getting back to the original problem, have you ever gotten the
RFM12s to work with any Arduino chip at all? Also, which library and sketches
are you using?
 
If you're using the jeelib s.w., from my experience, none of the sketches work
correctly, including the demo sketch. I only ever got the RFM12s to work by
using the sketches shown in the Arduino Cookbook.
Yes in fact I only got it working using ATMega1284 running  "Mighty 1284p 16Mhz w/ Optiboot". I ran it as a reciever, sketch is below (it uses Felix's RFM12B library which is derivative of Jeelib's but much better). I modified library slightly to include 1284p pin definition, because it only had 644p.
Code:
// Simple serial pass through program
// It initializes the RFM12B radio with optional encryption and passes through any valid messages to the serial port
// felix@lowpowerlab.com

#include <RFM12B.h>

// You will need to initialize the radio by telling it what ID it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. You can change it by calling .SetCS(pin) where pin can be {8,9,10}
#define NODEID           1  //network ID used for this unit
#define NETWORKID       1  //the network ID we are on
#define SERIAL_BAUD 115200

#define LED_ID 23 // Pin for LED indicator
//encryption is OPTIONAL

// Need an instance of the Radio Module
RFM12B radio;
void setup()
{
   Serial.begin(SERIAL_BAUD);
  pinMode(LED_ID, OUTPUT); // Turn on LED port for output
  Serial.println ("Initializing Radio");
  radio.Initialize(NODEID, RF12_915MHZ, NETWORKID);
 // radio.Encrypt(KEY);      //comment this out to disable encryption
 
  Serial.println("Listening...");
}

void loop()
{
  if (radio.ReceiveComplete())
  {
    digitalWrite(LED_ID,HIGH); // Turn on LED
    if (radio.CRCPass())
    {
      Serial.print('[');Serial.print(radio.GetSender());Serial.print("] ");
      for (byte i = 0; i < *radio.DataLen; i++) //can also use radio.GetDataLen() if you don't like pointers
        Serial.print((char)radio.Data[i]);

      if (radio.ACKRequested())
      {
        radio.SendACK();
        Serial.print(" - ACK sent");
      }
    }
    else
      Serial.print("BAD-CRC");
    
    Serial.println();
    delay (10);
    digitalWrite(LED_ID,LOW); // Turn of LED
  }
}

I have Moteino setup as trasmitter and it's hooked up to DS18B20 temp sensor (on breadboard) and transmits temperature readings. Setup works like a charm. But as I said with Mighty 1284p boot SD card stops working. With Sanguino SD card works but RF12B doesn't work...


* IMG_2240.jpg (1630.21 KB, 2000x1614 - viewed 28 times.)
« Last Edit: May 06, 2013, 01:37:51 pm by bratan » Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good, that's a step in the right direction from jeelib, I think. I've heard of the
lowpower RFM12 library, but not used it.

Your sketch doesn't show specifically how your library code is using the SPI port,
but I imagine that's where the problem is. IE, proper control of the SS and CS pins
between the RFM12 and the SD card. And as noted before, the SS pin always has
to be configured as output, whether it's used or not.

Also, of course, RFM12 comms will not work properly unless an interrupt is used,
so that needs be treated properly in the RFM12 code too.

EDIT: I assume you also assign different node IDs to the 2 different modules,
meaning modify the sketch between Arduino boards.
« Last Edit: May 06, 2013, 02:32:55 pm by oric_dan » Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2073
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

..what about the SPI speed?? It could happen the SDdriver sets it to a freq RFM does not like and vice versa..based on the board variant..
Logged

New York
Offline Offline
Sr. Member
****
Karma: 4
Posts: 366
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good, that's a step in the right direction from jeelib, I think. I've heard of the
lowpower RFM12 library, but not used it.

Your sketch doesn't show specifically how your library code is using the SPI port,
but I imagine that's where the problem is. IE, proper control of the SS and CS pins
between the RFM12 and the SD card. And as noted before, the SS pin always has
to be configured as output, whether it's used or not.

Also, of course, RFM12 comms will not work properly unless an interrupt is used,
so that needs be treated properly in the RFM12 code too.

EDIT: I assume you also assign different node IDs to the 2 different modules,
meaning modify the sketch between Arduino boards.
Correct, I'm using totally different sketch for transmitter (attaching if you interested).
You gave a good idea about setting SS as high, that could be the issue.  So I need to set that port to high (i.e. DigitalWrite(SS_PIN,HIGH) in order to start using it?  
But let's forget for a minute RF12B. I'm trying an SD card code only (i.e. quickstart sketch from SDFat library) and it just doesn't work... So even if I'm not invoking RF12b in any way in the code it somehow still interferes on hardware level?

..what about the SPI speed?? It could happen the SDdriver sets it to a freq RFM does not like and vice versa..based on the board variant..
Again even when I'm totally ignore RF12b module in software (not including libraries, etc), why wouldn't SD card still work?

I'm thinking for adding pullup resistor to RF12b just in case and if that doesn't work I'll solder another board and not attach RF12b components to it, just SD card parts and see if it helps...

BTW I really appreciate you guys trying to help me!  At least I have some hope now smiley

* temperature_send.ino (3.5 KB - downloaded 10 times.)
« Last Edit: May 06, 2013, 04:39:03 pm by bratan » Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27089
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

SS (D10) must be an output, whether you use it for chip select to some device or not.
The Sdfat library will correctly drive whatever pin you assign for SD card CS to the correct hi/low levels.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If both devices are using the same SPI port, then you obviously need to
hold their CS pins HIGH when not accessing.
Logged

New York
Offline Offline
Sr. Member
****
Karma: 4
Posts: 366
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If both devices are using the same SPI port, then you obviously need to
hold their CS pins HIGH when not accessing.
GENIUS!!!!  Thank you thank you thank you!!!
That was it smiley
I didn't know I have to hold unused port HIGH!
As soon as I added this to the setup of the SD Card test sketch:
Code:
pinMode(18,OUTPUT); // Set Output for RF12B SPI SS
  digitalWrite (18,HIGH); // Set RF12B SPI SS high
It immediately started to list files on the SD card!!! smiley

I think I understand now why Wave Shild had pullup resistor on SS line... I'm pretty sure I need to add one to RF12B so I don't have to pull it high from the code, right?
« Last Edit: May 06, 2013, 09:59:56 pm by bratan » Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think I understand now why Wave Shild had pullup resistor on SS line... I'm pretty sure I need to add one to RF12B so I don't have to pull it high from the code, right?
Good to hear things are working now. It's always a good idea to have a pullup on a
-CS line, especially for a ckt on a shield, or for the small amount of time during Arduino
bootup, however, it'll only do something if the Arduino I/O is configured as INPUT.

When the pin is configured as OUTPUT, then you specifically have to set it HIGH/LOW
on purpose - for obvious reasons.
Logged

New York
Offline Offline
Sr. Member
****
Karma: 4
Posts: 366
xronosclock.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just soldered 10K resistor between CS (hex buffer pin going to RF12B) and +5V line. And everything works without having to do anything in the code at all! smiley
Uploaded unmodified example sketch from SDFat: works!
Sketch from WaveShield: it talks! smiley
Receiver sketch for RF12B: receives!
Haven't tried both at the same time yet smiley

Thank you again!
Logged

Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info smiley

Pages: 1 [2] 3   Go Up
Jump to: