Show Posts
Pages: 1 ... 55 56 [57] 58 59 ... 98
841  Using Arduino / Storage / Re: Micro-SD Card not formatted on: July 29, 2012, 09:17:23 am
It's definitely an SPI problem.  It appears to nearly work.  This may because SdFat does retries during initialization.

Arduino does not support hardware CRC but SdFat has software CRC which is normally disabled.

Could you please edit SdFatConfig.h at about line 35 and enable CRC like this:
Code:
#define USE_SD_CRC 2

Then run SdInfo again.  This may give a better indication of where the problem is.

It would be great if there was a way to connect MISO directly without the level shifter.  Most SD shields connect MISO directly.  This works even though a high level of 3.3V seem marginal as an input to the ATmega.  

The spec says the Min high input is 0.6Vcc.  Guess it works since the Max low input is 0.3Vcc.

Edit:

I checked some posting on AVR Freaks and the claim is:
Quote
The AVR clearly has much better specification, as at 5V vilmax is 0.42*Vcc=2.1V and vihmin is 0.52*Vcc=2.6V.
I guess this is why commercial shields work well.
842  Using Arduino / Storage / Re: undocumented classes Sd2Card, SdVolume and SdFile on: July 28, 2012, 04:32:37 pm
I am not part of the Arduino company so I can only guess about the company's policy.

I believe the reason for the success of Arduino is that the company has targeted beginners and to do this simplicity is key. 

SD.h provides beginners with adequate functionality so from the Arduino company's point of view it "gets the job done".

This appears to be an excellent business policy but can be frustrating for more advanced users.

There is plenty of third party software but don't expect the Arduino group to support advanced users.
843  Development / Suggestions for the Arduino Project / Re: How about adding digitalToggle(pin)? on: July 28, 2012, 04:13:59 pm
Guess I didn't make my case for toggle very well.  Here is an example where toggle is very useful.

In protocols like SPI, clock can have a polarity and signals have a phase.  This leads to the four SPI modes and makes handling clock messy in a general software SPI library.

There were lot of hard to understand lines like this where all I really wanted to do was toggle clock:
Code:
  fastDigitalWrite(SckPin, MODE_CPHA(Mode) ? MODE_CPOL(Mode) : !MODE_CPOL(Mode));
The code is much cleaner when write is replaced with toggle:
Code:
  fastDigitalToggle(SckPin);
I am finding far more cases than I expected like the above where toggle is useful.

There was no speedup in the above case since all arguments are constant but in many cases you get a speedup and simpler code.
844  Using Arduino / Storage / Re: Micro-SD Card not formatted on: July 28, 2012, 02:24:10 pm
Most likely it is not a format problem.  The only sure way to format an SD card to the SD standard is to use SDformatter https://www.sdcard.org/downloads/formatter_3/.

Other utilities do not comply with the standard and won't help solve your problem.

Most likely you have a low level I/O problems. 

It would be helpful if you ran two example from the SdFat library.  SdFat is located here http://code.google.com/p/sdfatlib/downloads/list.

Run the SdInfo and QuickStart examples and post the error messages with error codes.

If you get a message like this with an errorCode, you have a basic SPI I/O problem.

From SdInfo:
Quote
card.init failed
SD errorCode: 0X1
SD errorData: 0XFF

From QuickStart:
Quote
SD initialization failed.
Do not reformat the card!
Is the card correctly inserted?
Is chipSelect set to the correct value?
Is there a wiring/soldering problem?
errorCode: 0x1, errorData: 0xff
845  Development / Suggestions for the Arduino Project / Re: How about adding digitalToggle(pin)? on: July 28, 2012, 01:30:22 pm
Paul,

Of course the case of fast write for a constant pin number has been around for years.  I have posted several versions based on classes and static functions that compile to a single sbi or cbi.  I like using static const arrays which the compiler optimizes out.  I did that in December 2009 for software SPI in SdFat but didn't post it until I saw your macros. 

For classes I use templates which forces a constant pin number without the gcc __builtin_constant_p(pin).

Toggle is useful for a constant pin number since it will toggle a pin in 125 ns.  You don't need to know the state of a pin to toggle it.

For a variable pin number it is fast since you don't need to do the atomic stuff.  You just write the bit you want to toggle to the PIN register.

As for digital I/O on SAM3X or ARM Cortex M in general, I hope I am not limited to the least common subset between AVR and ARM.  This is another reason I can't believe in AVR/ARM compatibility.

I don't expect to see toggle In the Arduino core but I added it to my digital libraries and was surprised how useful it can be.  I will be posting a new version of these libraries soon.
846  Development / Suggestions for the Arduino Project / How about adding digitalToggle(pin)? on: July 28, 2012, 10:45:37 am
Here is a neat feature of AVR I/O ports:
Quote
The Port Input Pins I/O location is read only. However, writing a logic one to a bit in the PINx Register, will result in a toggle in the corresponding bit in the Data Register
This means that you could implement an efficient atomic digitalToggle(pin) function.  It should be faster than digitalWrite().  

It would be handy when you need to pulse a pin.  You just call digitalToggle(pin) twice.

I implemented toggle() like this as an inline function in a digital I/O class:
Code:
 void toggle() {*pinReg_ = bit_;}
This function executes in 8 cycles or 500 ns on a 16 MHz CPU.  This allows generation of a 500 ns pulse.

Not as good as the 125 ns that is possible when a pin number is a constant but is about 8 times faster than digitalWrite() which takes about 4 us.
847  Using Arduino / Storage / Serious bug affects SD.h and String on: July 28, 2012, 09:59:38 am
There is a serious bug in 1.01 and some earlier Arduino versions that may cause crashes when you use SD.h and/or String.

The bug is in the function free() which deallocates memory.  

SD.h calls free() when you close a file.  

String may call free() when the size of a string changes or in destructors.

Frequent opening and closing of files, especially multiple file, may cause a crash in SD.h.

See this for an example of the String problem http://arduino.cc/forum/index.php/topic,115552.0.html.

The above topic also describes two fixes for the free() bug.

The SdFat library does not call free().  The bug is in the Arduino SD.h wrapper for SdFat.
848  Development / Suggestions for the Arduino Project / Re: String corrupts the heap and crashes on: July 28, 2012, 09:41:29 am
The free bug() explains another problem I have searched for in SD.h. 

Often users of the SD.h library open and close files frequently.  Some of the SD.h examples open a file, write a line, and close the file each time through loop.  These programs sometimes crash in strange ways.

SD.h allocates and frees memory to for the SdFat file object and file name.  I got really close but never suspected that free could be the cause.

I did a search for free in 1.01 and found these lines in the core and libraries:
Quote
D:\arduino-1.0.1\hardware\arduino\cores\arduino\new.cpp
     10: free(ptr);
D:\arduino-1.0.1\hardware\arduino\cores\arduino\WString.cpp
    104: free(buffer);
    121: if (buffer) free(buffer);
    172: free(buffer);
D:\arduino-1.0.1\libraries\Firmata\Firmata.cpp
    391: free(tmpArray);
D:\arduino-1.0.1\libraries\SD\File.cpp
    134: free(_file);

Looks like String and SD.h are the big problems.  I suspect new() and Firmata are used very little.
849  Development / Other Hardware Development / Re: New Olimex STM32-E407 on: July 28, 2012, 09:02:25 am
I don't plan on buying a P407 board but found the P407 in several more places so I have hope for the E407.

Looks like one will need to shop for price on these new boards.  I found the P407 for as high as $174.

Olimex has the H407 for 30 EUR, the E407 for 40 EUR and the P407 for 110 EUR.  I hope the E407 is under $60 in the U.S.

850  Development / Other Hardware Development / Re: New Olimex STM32-E407 on: July 27, 2012, 06:41:54 pm
I tried Mouser, DigiKey, and several others.

I found the P407 which has a lot more features http://microcontrollershop.com/product_info.php?products_id=4963&osCsid=mkehf6s3r54a3t1vvdlsttigl1.
851  Development / Suggestions for the Arduino Project / Re: Is 1.01 pinMode an improvement? on: July 27, 2012, 06:31:48 pm
By this:
Quote
I can't imagine making a reasonable Arduino port for Cortex ARM processors.
I meant a port that would work on the various families of ARM Cortex processors with access to most of the features.  Other than the Cortex core, these processors are very different.

RTOSs have a HAL layer so you can access the features of a given processor but programs are not easily portable between processors.

The single threaded Arduino system is OK for AVR.  I don't think I could be satisfied with a system like that on ARM Cortex.

For the last 40 years I have used RTOSs in embedded systems that I developed professionally.  For hobby projects I use ChibiOS/RT on ARM Cortex and often on AVR.

I suspect you will do well with your port, likely better than the Arduino group.
852  Development / Suggestions for the Arduino Project / Re: delay() documentation include interrupt caveat on: July 27, 2012, 06:08:38 pm
If a flag will work, you don't need the timer ISR.  Just do something like this:
Code:
const uint32_t INTERVAL_USEC = 1000000;

// time in usec of last sensor read
uint32_t last = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  // this works even when micros() rolls
  // over after about 4295 seconds.
  while ((micros() - last) < INTERVAL_USEC) {}
  // Replace  next println with the stuff in your ISR
  Serial.println(micros());
  last += INTERVAL_USEC;
}
This prints the time in usec with a jitter of a few usec with a one second interval.  Replace the println with whatever you do in the ISR.
853  Development / Other Hardware Development / Re: New Olimex STM32-E407 on: July 27, 2012, 11:39:59 am
Anyone know of a U.S. source? 

Shipping from Olimex is 29 EUR for FedEx.  Air mail is 8.50 EUR but Olimex says this can take forever (eight weeks in Dec 2011 to USA).

Looks like a nice board.  The SD is connected to SDIO so it will be extremely fast.
854  Using Arduino / Storage / Re: SdFat update on: July 27, 2012, 09:50:24 am
It shouldn't matter how you close the file.  You can close the file before calling Sd2Card::writeData().  That's what raw write means.  You are writing directly to the SD by raw block address.

You can reopen the file with open() and find the location of the file's blocks with contiguousRange().

The problem is knowing where to start writing.  You need to keep track of the last block written in the file and start at that position.  You could rewrite the first block of the file with that type of info or write the last block address to another file.
855  Development / Suggestions for the Arduino Project / Re: delay() documentation include interrupt caveat on: July 27, 2012, 09:32:37 am
You can enable interrupts in an ISR and then delay will work.  Just be sure to return from the ISR before the next interrupt from the timer.

I use this trick in a number of libraries to get a high priority thread.  I did a library, WaveHC, for the Adafruit Wave shield that uses this thread to read data from an SD. Thousands of people use this library http://code.google.com/p/wavehc/.

It is extremely unlikely that the Arduino team will modify the documentation.  The Arduino corporation take very little input from users.
Pages: 1 ... 55 56 [57] 58 59 ... 98