Go Down

Topic: ATMega1284p issues with SD Card (Read 3162 times) previous topic - next topic

fungus


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.

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

pito

#16
May 06, 2013, 01:58 pm Last Edit: May 06, 2013, 02:01 pm by pito Reason: 1
..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??  :~

bratan

#17
May 06, 2013, 02:11 pm Last Edit: May 06, 2013, 02:39 pm by bratan Reason: 1

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 :)
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

fungus


..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??  :~


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


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

CrossRoads

[Edit: Bobuino removed from all titles by moderator]
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

oric_dan

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.

bratan

#21
May 06, 2013, 08:01 pm Last Edit: May 06, 2013, 08:37 pm by bratan Reason: 1

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: [Select]
// 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...
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

oric_dan

#22
May 06, 2013, 09:05 pm Last Edit: May 06, 2013, 09:32 pm by oric_dan Reason: 1
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.

pito

..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..

bratan

#24
May 06, 2013, 10:12 pm Last Edit: May 06, 2013, 11:39 pm by bratan Reason: 1

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 :)
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

oric_dan

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

bratan

#27
May 07, 2013, 03:50 am Last Edit: May 07, 2013, 04:59 am by bratan Reason: 1

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 :)
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: [Select]
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!!! :)

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?
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

oric_dan

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.

bratan

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! :)
Uploaded unmodified example sketch from SDFat: works!
Sketch from WaveShield: it talks! :)
Receiver sketch for RF12B: receives!
Haven't tried both at the same time yet :)

Thank you again!
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, and purchasing info :)

Go Up