Show Posts
Pages: 1 ... 54 55 [56] 57 58 ... 109
826  Development / Other Software Development / Re: ChibiOS/RT and FreeRTOS for Teensy 3.0 on: November 17, 2012, 09:41:01 am
I have been posting additional information about use of these RTOSs here http://forum.pjrc.com/threads/540-ChibiOS-RTand-FreeRTOS-for-Teensy-3-0.
827  Development / Other Software Development / ChibiOS/RT and FreeRTOS for Teensy 3.0 on: November 16, 2012, 11:29:09 am
I have posted a first beta of two Real Time Operating System kernels for Teensy 3.0 as Teensy3-RTOSbeta20121116.zip http://code.google.com/p/beta-lib/downloads/list.

These systems are packaged as Arduino libraries so they can be used with other Arduino software. Since these are preemptive kernels, careful design is required to avoid problems with normally single-threaded Arduino software.

These RTOSs must be used with the beta8 version of the Teensy 3.0 software.

ChibiOS/RT is version 2.4.2 http://www.chibios.org/dokuwiki/doku.php.

FreeRTOS is version 7.3.0 http://www.freertos.org/.

Warning: If this is your first use of a RTOS, you will likely experience the pain of my bugs and problems that are inherent to preemptive RTOSs. Please read the warnings in the included html documentation.

Four examples are included with each system. These example are described in the html included with the libraries.
828  Using Arduino / Storage / Re: Random Error Codes on: November 02, 2012, 10:19:59 am
The SparkFun microSD shields uses pin 8 for SD chip select.  Sometimes it will almost work with the wrong chip select pin.  This happens if pin 8 floats low.

Try changing this line
Code:
const uint8_t chipSelect = SS;
to this
Code:
const uint8_t chipSelect = 8;
829  Products / Arduino Due / Incorrect type for link() in syscalls.h prevents use of unistd.h on: October 30, 2012, 08:59:26 pm
The link() stub for newlib in syscalls.h has the wrong type and causes a conflicts with the correct definition in unistd.h. 

Here is an example sketch:

Code:
#include <unistd.h>
void setup() {
  Serial.begin(9600);
  Serial.println((int)sbrk(0));
}
void loop() {}

That results in this error:
Quote
D:\\arduino-1.5\hardware\arduino\sam\cores\arduino/syscalls.h:43: error: declaration of C function 'int link(char*, char*)' conflicts with
D:\arduino-1.5\hardware\tools\g++_arm_none_eabi\bin\../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/include/sys/unistd.h:107: error: previous declaration 'int link(const char*, const char*)' here

Changing the definition in syscalls.h to this:
Code:
extern int link(const  char *cOld, const char *cNew ) ;

And the implementation in syscalls_sam3.c to this:
Code:
extern int link(const char *cOld, const char *cNew )
{
    return -1 ;
}

Seems to fix the problem.
830  Using Arduino / Storage / Re: SD examples and chip select definition on: October 28, 2012, 11:00:00 am
The SD library has a long history and many of the examples are out of date or just plain wrong.

This comment is wrong.
Code:
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(10, OUTPUT);

The SD library always sets SS high as an output so no code is needed for that purpose.  Here is the code from Sd2Card.cpp in IDE version 1.01.
Code:
  // SS must be in output mode even it is not chip select
  pinMode(SS_PIN, OUTPUT);
  digitalWrite(SS_PIN, HIGH); // disable any SPI device using hardware SS pin

Future versions of the SD.h library will use the SPI.h library and it also makes SS as an output.  Here is code from the 1.5 SPI.h library.
Code:
  // Set SS to high so a connected chip will be "deselected" by default
  digitalWrite(SS, HIGH);

  // When the SS pin is set as OUTPUT, it can be used as
  // a general purpose output port (it doesn't influence
  // SPI operations).
  pinMode(SS, OUTPUT);

Here is the reason you may need to make some pins outputs and high.  If you have more than one device on the SPI bus, you must disable all devices other than the SD by making their chip select pin an output and high.

For the Ethernet shield, pin 10 is chip select for the Ethernet controller and pin 4 is chip select for the SD card.  So you should make pin 10 an output and set it high to disable the Ethernet controller, not because pin 10 is SS.

Much confusion results from the fact that on 328 Arduinos pin 10 is also SS.  On the Mega, people change the 10 to 53, the SS pin for the Mega, and then the SD on the Ethernet shield will not initialize.  The problem is that the Ethernet controller is no longer disabled on the Mega.

For the Ethernet shield you must always make pin 10 an output and high before initializing the SD card.  It has nothing to do with SS.


831  Development / Other Hardware Development / Re: Teensy 3.0 on: October 25, 2012, 09:39:06 pm
Yes you can connect it directly.
832  Using Arduino / Storage / Re: FAT16 vs FAT32 on: October 25, 2012, 06:36:34 am
Many of the fastest most reliable SD cards for embedded systems are small, 2GB or less, and based on SLC flash.  Larger SLC cards are available but are very expensive.
Quote
Performance
Due to the lower complexity in managing SLC flash, the write performance for SLC at the IC level is typically twice as fast. With controller multiplexing this can be reduced, but this accounts for the main delta in read speed versus write speed in retail flash products today.


SLC flash SDs last 20-100 times longer than consumer grade MLC flash SDs.
Quote
Endurance
3-Bit MLC technology (a.k.a. TLC) has an exponentially lower number of program/erase cycles. SLC technology, targeting embedded and mission critical applications, will continue to maintain an emphasis on endurance and reliability.
833  Using Arduino / Storage / Re: FAT16 vs FAT32 on: October 24, 2012, 04:51:01 pm
First, the SD standard specifies that 2GB and smaller cards should be formatted FAT16 and very small cards are FAT12.

Cards larger than 2GB must be FAT32.

The practical reason is that SD cards perform better with large clusters.  Small clusters causes many accessed to the FAT (File Allocation Table) and SD cards don't tolerate random access well.  They are designed for contiguous reads and writes

I's best to format SD cards with the SD Association's formatter https://www.sdcard.org/downloads/formatter_3/.  This program aligns file structures with the internal flash chips for optimum performance.

OS format utilities do not always produce an optimal layout.
834  Using Arduino / Storage / Re: New SdFat optimized for Mega and Teensy 3.0 on: October 24, 2012, 04:41:20 pm
I don't use the chip select feature in the SPI module since SD transfers are so large.

To use this feature you must select the proper pin multiplexing mode with the Port Control Module.

See chapter 10 and 11 of the chip data sheet.
Quote
Chapter 10
Signal Multiplexing and Signal Descriptions
10.1 Introduction
To optimize functionality in small packages, pins have several functions available via
signal multiplexing. This chapter illustrates which of this device's signals are multiplexed
on which external pin.
The Port Control block controls which signal is present on the external pin. Reference
that chapter to find which register controls the operation of a specific pin.
Quote
Chapter 11
Port control and interrupts (PORT)
11.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
11.1.1 Overview
The port control and interrupt (PORT) module provides support for port control, and
external interrupt functions. Most functions can be configured independently for each pin
in the 32-bit port and affect the pin regardless of its pin muxing state.
There is one instance of the PORT module for each port. Not all pins within each port are
implemented on a specific device.

I am not very knowledgeable about the Kinetis chip, Paul Stoffregen helped me configure the SPI to be compatible with his software for Teensy 3.0. 
835  Using Arduino / Storage / Re: New SdFat optimized for Mega and Teensy 3.0 on: October 23, 2012, 09:13:52 am
Yes you can read SPIx_POPR as a 32 bit register but only 16 bits are data.  See 3.9.2.5
Quote
Figure 43-1. DSPI Block Diagram  - shows 32bit data path to the shift register (and and extra for command)
Figure 43-1 is wrong.  See rule 8 in my previous post.  See  43.3.7 for the format of PUSHR.
Quote
43.1.2 "SPI frames longer than 16 bits can be supported using the continuous selection format"..
Continuous selection format just insures that CS remains low, it has nothing to do with the FIFOs.
Quote
CONT
Continuous Peripheral Chip Select Enable
Selects a continuous selection format. The bit is used in SPI Master mode. The bit enables the selected
PCS signals to remain asserted between transfers.
0 Return PCSn signals to their inactive state between transfers.
1 Keep PCSn signals asserted between transfers.

Quote
43.4.2 "The SPI frames can be 32 bits long."..

Frames can be any size but a max of 16 bits can be transferred to/from the FIFOs.  Unfortunately the data sheet uses Frame size for two things.

In the CTAR 43.3.3 it is how many bits wide the data field is in a FIFO.

In other places it is how many bits are sent in a transfer while CS is low.

Again the datasheet is a clue for Kinetis and point 8 above applies to many sections.
836  Using Arduino / Storage / Re: Program hangs on SD.begin() on: October 23, 2012, 08:42:49 am
If you want to use a serial port in SPI mode start with this version of SdFat SdFatBeta20121020.zip http://code.google.com/p/beta-lib/downloads/list.

It is designed to support various SPI controllers.  You just need to write the low level spi read/write functions for AVR serial ports.
837  Using Arduino / Storage / Re: New SdFat optimized for Mega and Teensy 3.0 on: October 23, 2012, 06:20:07 am
The RX FIFO appears to be 32-bits wide but:
Quote
3.9.2.5 RX FIFO Size
SPI supports up to 16-bit frame size during reception.
The TX FIFO is 32-bits wide but the high 16-bits are command bits.
Quote
43.3.7 DSPI PUSH TX FIFO Register In Master Mode (SPIx_PUSHR)
PUSHR provides the means to write to the TX FIFO. Data written to this register is
transferred to the TX FIFO . 8- or 16-bit write accesses to the Data Field of PUSHR
transfers the 16 bit Data field of PUSHR to the TX FIFO. Write accesses to the
Command Field of PUSHR transfers the 16 bit Command Field of PUSHR to the TX
FIFO. The register structure is different in Master and Slave modes. In Master mode, the
register provides 16-bit command and data to the TX FIFO. In Slave mode, the 16 bit
Command Field of PUSHR is reserved.

Even if you could send 32 bits, the byte order in memory is not in the correct order due to nature of a little-endian fetch from memory to a 32 bit register.

See above for the problem with 16-bit transfers.

The datasheet is not too clear in spots.  See point 8 in this list:
Quote
TOP TEN THINGS ENGINEERING SCHOOL DIDN'T TEACH YOU (from Rich Ries via Embedded Muse)
10. There are at least 10 types of capacitors.
9. Theory tells you how a circuit works, not why it does not work.
8. Not everything works according to the specs in the databook.
7. Anything practical you learn will be obsolete before you use it,
except the complex math, which you will never use.
6. Always try to fix the hardware with software.
5. Engineering is like having an 8 a.m. class and a late afternoon lab
every day for the rest of your life.
4. Overtime pay? What overtime pay?
3. Managers, not engineers, rule the world.
2. If you like junk food, caffeine and all-nighters, go into software.
1. Dilbert is not a comic strip, it's a documentary.
838  Development / Other Hardware Development / Re: Teensy 3.0 on: October 22, 2012, 09:56:21 pm
The main difference is that industrial cards use SLC flash and consumer cards use MLC flash.

SLC flash tends to perform better in embedded applications.  For example wear leveling remaps occurs more frequently for MLC flash since each cell has a lower maximum number of write cycles.

A comment on bus speed. 

The Teensy uses 1-bit wide SPI at 24 MHz.

Common Version 2.0 SD and SDHC cards support the 4-bit SD bus at 50 MHz.  This is about eight times the bandwidth that Teensy has.
839  Using Arduino / Storage / Re: New SdFat optimized for Mega and Teensy 3.0 on: October 22, 2012, 04:48:48 pm
pito,

I was able to try 16-bit frames.  The write rate increased from 1776.44 KB/sec to 2013.34 KB/sec.

The overhead is increased since a byte swap is required.  I form the 16-bit word to be sent like this:

Code:
    uint16_t w = *src++ << 8;
    w |= *src++;
840  Using Arduino / Storage / Re: New SdFat optimized for Mega and Teensy 3.0 on: October 22, 2012, 03:38:27 pm
I am using the FIFO on Teensy 3.0.

The maximum SPI frame size for the K20 is 16 bits, not 32 bits.

I have not tried 16 bit frames yet since the Freescale examples were a mess.  I suspect 16 bit frames could help a lot.

I plan to try DMA in the future.

The absolute limit for SPI at 24 MHz is 3000 KB/sec but I don't think I will get close to that for 4 KB writes, even with DMA.
Pages: 1 ... 54 55 [56] 57 58 ... 109