fatfs, libm.a issues...

Go To Last Post
66 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

a.mlw.walker wrote:

0x04 is the SS line. I dont have the sd card on the SS line but it needs to be an output to state that the 1284 is master. So a) PORTB &= ~0x04 is just setting the SS line low - If the sd card was on SS for CS then that would be saying "get ready for data". But thats in the power_off function?

Because when cutting the card power you cannot leave any pins to the card high, or you power it through protection diodes which is bad. All card IO pins must be low when power is removed.

a.mlw.walker wrote:

Then the other line, PORTB |= 1; what is that supposed to be doing? is that setting PB0 high or something? All in all they are wrong I think? I have CS on PB1 and also have the two defines setup:

#define CS_LOW()	PORTB &= ~0b00000010		
#define	CS_HIGH()	PORTB |= 0b00000010	

so why are those lines in power_on/_off not using the defines instead of the 0x04 lines? In fact those two lines have completely confused me...

Yes, it sets pin B0 high. Hard to say why they do not use the defines. But you need to get the code to work with your pins. I would have just used the AVR SS pin for card CS, but it really does not matter, as long as AVR SS pin is always an output or high input or it won't work.

You have modified the hardware so you must modify the code. You have removed features to detect the card, detect the write protect, and control the card power. If I recall some things do not get reset until card power is toggled. Could have been the exit from SPI mode, but you don't need to exit SPI mode.

Edit: Umm just noticed, 0x04 is NOT AVR SS pin, 0x04 is PB2. AVR SS is PB4 which is 0x10.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah. that would explain why IRQ was changing state with MOSI... thanks for that. Late now, I'll try these things tomorrow.
Cheers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, double check the code that PB4 (NRF INT) is configured as an input. Having both AVR and NRF set the pins as outputs but in different direction might fry something.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow!
I just ran my finger very delivately over the SPI pins (where NRF+ would connect if it were there) and the card initialized and wrote a text file successfully to the sd card. If I restart, it fails until I lightly touch the connections - just a gentle stroke.
I assume some capacitance stuff is occuring, should I have any series resistors on MOSI/MISO or capacitors anywhere, at the moment all my SPI pins are directly connected to the avr no peripherals...
I

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

all my SPI pins are directly connected to the avr

If poking your finger at them affects operation I'd say there's a strong chance you are wrong about that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In that?...
You think there is probably a short? because I cant see any issues on the scehmatic I posted in the beginning of this thread, any suggestions for further analysis?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds like you should enable the internal AVR pull-ups on AVR input pins, so that the pins do not float and have a defined state.

The series resistor or small capacitors to ground are not absolutely necessary, but they help with problems caused by fast signal edges on longish buses, such as reflections and ringing. Most likely lack of these is not a problem here.

Any issues on schematic? Well, one thing is that there is no bypass caps drawn for any chip. We don't know where you power the thing. Maybe a card draws a huge current spike when initializing, and voltage dips so much it cannot succeed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chan says this: does it suggest anything to you:

Quote:

Any signals that can be floated should be pulled low or high properly via a resister. This is a generic design rule on MOS devices. Because DI and DO are normally high, they should be pulled-up. According to SDC/MMC specs, from 50k to 100k ohms is recommended to the value of pull-up registers. However the clock signal is not mentioned in the SDC/MMC specs because it is always driven by host controller. When there is a possibility of floating, it should be pulled to the normal state, low.

http://elm-chan.org/docs/mmc/mmc...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, it suggests to me that you are not following these suggestions.

But when AVR SPI is used, the MOSI pin is a push-pull output, so it should not need a pull-up. Only the MISO pin must be pulled up so it does not float, as the card initially is initialized in the SD mode to SPI mode, and during that time the card DO is floating, until it is in SPI mode. SCK is definitely the least problem.

But it clearly shows that lack of these pull-up resistors affect the initialization sequence, and putting your finger there creates a good enough pull-up (or pull-down) so things are stable.

Maybe you should compensate for the lack of these by putting some kind of bus init sequence after you have initialized SPI and IO pins, before you call the card init. The bus init sequence should make sure IO pins are in correct states and some amount of unused bits are transferred, so the card init sequence can work. But I think if IO pins are correct, the standard card init sequence (transfer at least 10 0xff bytes) should take care of that, if other IO pins like CS are correct.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

But it clearly shows that lack of these pull-up resistors affect the initialization sequence, and putting your finger there creates a good enough pull-up (or pull-down) so things are stable.


Or OP simply has ratty connection(s).

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all your tips guys. The Pull up on MISO was the trick that did it.

Could someone please conclude this thread with something about the things to look out for when using to SPI devices on the same bus?
As I understand it:
CS of the active device must be low, all other devices high.
Remove power to the other devices while using an SPI device - what if the device gets power directly from source? Do I then just worry about CS line?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

a.mlw.walker wrote:

As I understand it:
CS of the active device must be low, all other devices high.

That would depend on CS polarity of course, but yes, only one slave can be made active at once, and if all devices have active low CS, then only one CS can be low at once.

a.mlw.walker wrote:

Remove power to the other devices while using an SPI device - what if the device gets power directly from source? Do I then just worry about CS line?

No power must not be removed, as the unpowered slave will pull the bus signal voltages towards ground by sucking power through protection diodes. Leave them powered, and just worry about CS line.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Remove power to the other devices while using an SPI device

Where did THAT come from. Unless you have suitable buffering it's very unwise to have only part of any circuit that is not being powered. With SPI the only requirement is that there's never more than one slave selected (and all devices respect slave select and tri-state their output when not selected) but there's no suggestion they power off.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It came from the post earlier where I was asking what chan was doing in the power_on/_off functions, and I understood the response to be that he was removing power from all pins to the sd card - I probably understood the reponse as remove power to the sd card..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

His design might have only the SD card on the SPI bus. His design may allow power to be cut from the card. His design supports hotplugging (live insertion). So it is also needed to set all IO pins between chips low, if card power is off.

But your hardware does not allow card power to be turned on/off, and you cannot leave an unpowered card on the bus or you won't be able to communicate with other chips then. So your design does not need to set SPI pins low, or cannot, because you have the NRF chip there too.

Pages