Go Down

Topic: ATMEL Mega1284P evaluation board avalible (Read 81647 times) previous topic - next topic

CrossRoads

#345
Jul 27, 2011, 09:23 pm Last Edit: Jul 27, 2011, 09:29 pm by CrossRoads Reason: 1
The SD card socket on the top of the board has a seperate Slave Select from the uSD card socket on the bottom of the board.
(If a uSD card socket is mounted on the of the board in place of a SD card socket, the bottom uSD card socket can not be installed, they both use the same physical alignment hole.)
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.

mowcius

Quote
(If a uSD card socket is mounted on the of the board in place of a SD card socket, the uSD card socket can not be installed, they both use the same physical alignment hole.)

I'm sure you can get away with cutting off the alignment pin and soldering it carefully...

fat16lib

SdFat expects all cards to be on the same SPI bus.  On the 1284P this is PB4 - PB7.

Each card has a separate chip select.

pito


CrossRoads

"I'm sure you can get away with cutting off the alignment pin and soldering it carefully..."

Probably, is just 2 little plastic nubs - but they also have the same SS signal, that'd be a little trickier (doable, but trickier) to cut the trace and add a jumper wire.
I will have the top sockets share the same SS signal next time.
I suppose I could have an SD socket as an option for the bottom as well.
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.

CrossRoads

I am running the SDFat Quickstart file.

It starts, I get the messages, I enter my pin #, then nothing happens.
Should I be doing something else?

Quote
SD chip select is the key hardware option.
Common values are:
Arduino Ethernet shield, pin 4
Sparkfun SD shield, pin 8
Adafruit SD shields and modules, pin 10
The default chip select pin number is pin 4

Enter the chip select pin number: 30

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.

pito

..you have to add to the  sd2pinmap.h (in the sdfat lib folder) the 1284p definitions..

...for example

//------------------------------------------------------------------------------
#elif defined(__AVR_ATmega1284P__)

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 17;
uint8_t const SCL_PIN = 16;

// SPI port
uint8_t const SS_PIN   = 4; //12;
uint8_t const MOSI_PIN = 5; //13;
uint8_t const MISO_PIN = 6; //14;
uint8_t const SCK_PIN  = 7; //15;

static const pin_map_t digitalPinMap[] = {
  {&DDRA, &PINA, &PORTA, 0},  // A0  0   ADC0
  {&DDRA, &PINA,...................


pito

@crossroads: maybe off the topic:
1. which microsdcard socket you use (the TFP09-12-2B ?)
2. the two positioning holes are large enough ?
(looking for the eagle lib part so asking whether it worked fine..).P.

CrossRoads

pito,
Thanks for #351, fat16lib wrote back to me also that sd2pinmap.h would need to change. Will check that out when I get home.  Looks like I need to mimic the contents of what I put in pins_arduino.c (all 32 IO pins ? Or just the 4 pins used for SPI ?)

uSD connecter, I used the Molex connecter that dipmicro sells, they have a library symbol for it also.
http://www.dipmicro.com/store/CON-MICROSD1
"MicroSD/TransFlash push/push connector. This connector is designed for SMT PCB mount, extensive use without mounting may loosen the pins. The free Eagle library provided by Roman Vaughan from Auckland, New Zealand is with his permission available here. " (actual link shows up on page)

Mounted nicely, even tho it was hand soldered (by my wife, very nice touch).  Haven't tried it with a card yet.
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.

pito

..put there everything as you may see with the other mcu's there..
the sdcard shall then work when connected properly.. those demos wait on "type any character to start" so you have to push the button  :)
Run sdinfo.pde and you may see then what is your card like. In the older sdfat versions there is sdfatbench.pde - it measures the r/w speeds.. I would recommend you to have a look on the examples from older versions of sdfat as well..

Thanks for sdcard socket info, I've seen tons of those sockets on ebay and it seems it is the one I'll order.
P.

CrossRoads

Thanks pito, am looking forward to checking that out after work.
Robert
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.

CrossRoads

#356
Jul 29, 2011, 07:14 am Last Edit: Jul 29, 2011, 07:17 am by CrossRoads Reason: 1
Okay, with fat16lib's & pito's help I was came up with the following change to Sd2PinMap.h

Code: [Select]

#elif defined(__AVR_ATmega1284P__)
// add this if use these other chips
// ||defined(__AVR_ATmega644P__) || defined(__AVR_ATmega324P__)

// ATMEL ATMEGA1284P / BOBUINO
//
// Make it agree with the as-built hardware & pins_arduino.c
//
//                    +---\/---+
//  INT0 (D 4)  PB0  1|        |40  PA0 (AI 0 / D14)
//  INT1 (D 5)  PB1  2|        |39  PA1 (AI 1 / D15)
//  INT2 (D 6)  PB2  3|        |38  PA2 (AI 2 / D16)
//   PWM (D 7)  PB3  4|        |37  PA3 (AI 3 / D17)
//   PWM (D 10) PB4  5|        |36  PA4 (AI 4 / D18)
//  MOSI (D 11) PB5  6|        |35  PA5 (AI 5 / D19)
//  MISO (D 12) PB6  7|        |34  PA6 (AI 6 / D21)
//   SCK (D 13) PB7  8|        |33  PA7 (AI 7 / D22)
//              RST  9|        |32  AREF
//              VCC 10|        |31  GND
//              GND 11|        |30  AVCC
//            XTAL2 12|        |29  PC7 (D 29)
//            XTAL1 13|        |28  PC6 (D 28)
//  RX0 (D 0)   PD0 14|        |27  PC5 (D 27) TDI
//  TX0 (D 1)   PD1 15|        |26  PC4 (D 26) TDO
//  RX1 (D 2)   PD2 16|        |25  PC3 (D 25) TMS
//  TX1 (D 3)   PD3 17|        |24  PC2 (D 24) TCK
//  PWM (D 30)  PD4 18|        |23  PC1 (D 23) SDA
//  PWM (D 8 )  PD5 19|        |22  PC0 (D 22) SCL
//  PWM (D 9)   PD6 20|        |21  PD7 (D 31) PWM
//                    +--------+
//
// NOT_ON_TIMER, /* 0  - PD0 */  
// NOT_ON_TIMER, /* 1  - PD1 */
// NOT_ON_TIMER, /* 2  - PD2 */
// NOT_ON_TIMER,   /* 3  - PD3 */  
// NOT_ON_TIMER, /* 4  - PB0 */
// NOT_ON_TIMER, /* 5  - PB1 */
// NOT_ON_TIMER, /* 6  - PB2 */
// TIMER0A, /* 7  - PB3, PWM */
// TIMER1A, /* 8  - PD5, PWM */
// TIMER2B, /* 9  - PD6, PWM */
// TIMER0B, /* 10 - PB4, PWM */
// NOT_ON_TIMER, /* 11 - PB5 */
// NOT_ON_TIMER,   /* 12 - PB6 */
// NOT_ON_TIMER,   /* 13 - PB7 */
// NOT_ON_TIMER,   /* 14 - PA0 */
// NOT_ON_TIMER,   /* 15 - PA1 */
// NOT_ON_TIMER, /* 16 - PA2 */
// NOT_ON_TIMER, /* 17 - PA3 */
// NOT_ON_TIMER, /* 18 - PA4 */
// NOT_ON_TIMER, /* 19 - PA5 */
// NOT_ON_TIMER, /* 20 - PA6 */
// NOT_ON_TIMER, /* 21 - PA7 */
// NOT_ON_TIMER, /* 22 - PC0 */
// NOT_ON_TIMER, /* 23 - PC1 */
// NOT_ON_TIMER, /* 24 - PC2 */
// NOT_ON_TIMER, /* 25 - PC3 */
// NOT_ON_TIMER, /* 26 - PC4 */
// NOT_ON_TIMER, /* 27 - PC5 */
// NOT_ON_TIMER, /* 28 - PC6 */
// NOT_ON_TIMER, /* 29 - PC7 */
// TIMER1B, /* 30 - PD4, PWM */
// TIMER2A /* 31 - PD7, PWM */


// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 23;  // C1 23
uint8_t const SCL_PIN = 22;  // C0 22

// SPI port
  uint8_t const SS_PIN = 18;   // D 30
// uint8_t const SS_PIN = 21;  // D 31 Swap when testing the other SD card

  uint8_t const MOSI_PIN = 6;  // D 11  MOSI
  uint8_t const MISO_PIN = 7;  // D 12  MISO
  uint8_t const SCK_PIN =  8;  // D 13  SCK

have also tried the SPI section above as:
Code: [Select]

// SPI port
  uint8_t const SS_PIN = 30;   // D 30
// uint8_t const SS_PIN = 31;  // D 31 Swap when testing the other SD card

  uint8_t const MOSI_PIN = 11;  // D 11  MOSI
  uint8_t const MISO_PIN = 12;  // D 12  MISO
  uint8_t const SCK_PIN =  13;  // D 13  SCK

and the actual port to pin mapping:
Code: [Select]

static const pin_map_t digitalPinMap[] = {
 {&DDRD, &PIND, &PORTD, 0},  // D0  0
 {&DDRD, &PIND, &PORTD, 1},  // D1  1
 {&DDRD, &PIND, &PORTD, 2},  // D2  2
 {&DDRD, &PIND, &PORTD, 3},  // D3  3
 {&DDRB, &PINB, &PORTB, 0},  // B0  4
 {&DDRB, &PINB, &PORTB, 1},  // B1  5
 {&DDRB, &PINB, &PORTB, 2},  // B2  6
 {&DDRB, &PINB, &PORTB, 3},  // B3  7
 {&DDRD, &PIND, &PORTD, 5},  // D5  8
 {&DDRD, &PIND, &PORTD, 6},  // D6  9
 {&DDRB, &PINB, &PORTB, 4},  // B4 10
 {&DDRB, &PINB, &PORTB, 5},  // B5 11
 {&DDRB, &PINB, &PORTB, 6},  // B6 12
 {&DDRB, &PINB, &PORTB, 7},  // B7 13
 {&DDRA, &PINA, &PORTA, 0},  // A0 14
 {&DDRA, &PINA, &PORTA, 1},  // A1 15
 {&DDRA, &PINA, &PORTA, 2},  // A2 16
 {&DDRA, &PINA, &PORTA, 3},  // A3 17
 {&DDRA, &PINA, &PORTA, 4},  // A4 18
 {&DDRA, &PINA, &PORTA, 5},  // A5 19
 {&DDRA, &PINA, &PORTA, 6},  // A6 20
 {&DDRA, &PINA, &PORTA, 7},  // A7 21
 {&DDRC, &PINC, &PORTC, 0},  // C0 22
 {&DDRC, &PINC, &PORTC, 1},  // C1 23
 {&DDRC, &PINC, &PORTC, 2},  // C2 24
 {&DDRC, &PINC, &PORTC, 3},  // C3 25
 {&DDRC, &PINC, &PORTC, 4},  // C4 26
 {&DDRC, &PINC, &PORTC, 5},  // C5 27
 {&DDRC, &PINC, &PORTC, 6},  // C6 28
 {&DDRC, &PINC, &PORTC, 7},  // C7 29
 {&DDRD, &PIND, &PORTD, 4},  // D4 30
 {&DDRD, &PIND, &PORTD, 7}   // D7 31

};

and commented out 1284 in the 644/1284 part:
Code: [Select]

#elif defined(__AVR_ATmega644P__)||\
     defined(__AVR_ATmega644__)
// || defined(__AVR_ATmega1284P__)
// Sanguino


Result with either set of SPI pins is the sketches (SdFormatter, Bench, QuickStart) get to this line

 if (!card.init(spiSpeed, chipSelect)) {

and stop.

What am I missing still?

If I run "Blink" with D11, 12, 13, 30 I can see the lines toggling at the SD socket on the right pins, so I know the signals are getting there.
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.

pito

#357
Jul 29, 2011, 10:37 am Last Edit: Jul 29, 2011, 02:57 pm by pito Reason: 1
..this works with mine (my own board!):

PS: the evidence provided by the toggling the "arduino_lines" with a help of some arduino functions within the Blink demo may not necessarily mean the sdfat uses those "arduino_line" numbers internally.. I think the SPI is hardwired into the sdfat.. So as I've written in #351 do use 4,5,6,7 (the magic numbers  :smiley-eek:), and restart IDE..

PS1: with pin/lines mapping from (vanilla):           #include "pins_duino644.cxx"

PS2: .. provided you are using the PB4 as the SS !!

As I can see from the schematics you are using PD4 for the top sdcard and PC6 for the bottom sdcard as the SS. Is that correct??
If yes, then based on above PS1 (double check the count,pls):
SS_top card: PD4 -> 12                  (12,5,6,7)
SS_bottom card: PC6 -> 21            (21,5,6,7)

It may differ of course when using other pin mapping as in PS1: !

Code: [Select]
//------------------------------------------------------------------------------
#elif defined(__AVR_ATmega1284P__)
// ala BahBots & Sanguino

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 17;
uint8_t const SCL_PIN = 16;

// SPI port
uint8_t const SS_PIN   = 4; //12;
uint8_t const MOSI_PIN = 5; //13;
uint8_t const MISO_PIN = 6; //14;
uint8_t const SCK_PIN  = 7; //15;

static const pin_map_t digitalPinMap[] = {
 {&DDRA, &PINA, &PORTA, 0},  // A0  0   ADC0
 {&DDRA, &PINA, &PORTA, 1},  // A1  1   ADC1
 {&DDRA, &PINA, &PORTA, 2},  // A2  2   ADC2
 {&DDRA, &PINA, &PORTA, 3},  // A3  3   ADC3
 {&DDRA, &PINA, &PORTA, 4},  // A4  4   ADC4
 {&DDRA, &PINA, &PORTA, 5},  // A5  5   ADC5
 {&DDRA, &PINA, &PORTA, 6},  // A6  6   ADC6
 {&DDRA, &PINA, &PORTA, 7},  // A7  7   ADC7
 {&DDRB, &PINB, &PORTB, 0},  // B0  8
 {&DDRB, &PINB, &PORTB, 1},  // B1  9
 {&DDRB, &PINB, &PORTB, 2},  // B2 10 AIN0 INT2
 {&DDRB, &PINB, &PORTB, 3},  // B3 11 AIN1 OC0A (PWM)
 {&DDRB, &PINB, &PORTB, 4},  // B4 12   SS   OC0B (PWM)
 {&DDRB, &PINB, &PORTB, 5},  // B5 13   MOSI ICP3
 {&DDRB, &PINB, &PORTB, 6},  // B6 14   MISO OC3A (PWM)
 {&DDRB, &PINB, &PORTB, 7},  // B7 15   SCK  OC3B (PWM)
 {&DDRC, &PINC, &PORTC, 0},  // C0 16 SCL
 {&DDRC, &PINC, &PORTC, 1},  // C1 17 SDA
 {&DDRC, &PINC, &PORTC, 2},  // C2 18 TCK
 {&DDRC, &PINC, &PORTC, 3},  // C3 19 TMS
 {&DDRC, &PINC, &PORTC, 4},  // C4 20 TDO
 {&DDRC, &PINC, &PORTC, 5},  // C5 21 TDI
 {&DDRC, &PINC, &PORTC, 6},  // C6 22 TOSC1
 {&DDRC, &PINC, &PORTC, 7},  // C7 23 TOSC2
 {&DDRD, &PIND, &PORTD, 0},  // D0 24 RXD0
 {&DDRD, &PIND, &PORTD, 1},  // D1 25 TXD0
 {&DDRD, &PIND, &PORTD, 2},  // D2 26 RXD1
 {&DDRD, &PIND, &PORTD, 3},  // D3 27 TXD1
 {&DDRD, &PIND, &PORTD, 4},  // D4 28 OC1B (PWM)
 {&DDRD, &PIND, &PORTD, 5},  // D5 29 OC1A (PWM)
 {&DDRD, &PIND, &PORTD, 6},  // D6 30 OC2B (PWM) ICP
 {&DDRD, &PIND, &PORTD, 7}   // D7 31 OC2A (PWM)
};
//------------------------------------------------------------------------------

fat16lib

There are five important pin types for SPI on an avr processor.  These are SS, SCK, MISO, MOSI, and chip select.

On the 1284P these definitions must map like this
Code: [Select]

uint8_t const SS_PIN   = <pin number for PB4>;
uint8_t const MOSI_PIN = <pin number for PB5>;
uint8_t const MISO_PIN = <pin number for PB6>;
uint8_t const SCK_PIN  = <pin number for PB7>;

SS is not the same as chip select and must be defined as above.  For SPI to work correctly on an avr, SS must be either set to output mode or held high in input mode http://atmel.com/dyn/resources/prod_documents/doc2585.pdf.

SdFat sets SS to output mode even if SS is not chip select.

Chip select for a SPI device can be any pin.  SdFat uses SS by default:
Code: [Select]
/** The default chip select pin for the SD card is SS. */
uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;

The above definition is only used when the chip select pin is not specified in the init() call.

The definitions for this array must match the way you setup The Arduino pins_arduino.c and pins_arduino.h files.
Code: [Select]
static const pin_map_t digitalPinMap[] = {
These definitions are currently used for software SPI in SdFat and other libraries associated with SdFat.

pito

#359
Jul 29, 2011, 04:30 pm Last Edit: Jul 29, 2011, 04:54 pm by pito Reason: 1
.. can we somehow bitbang the SPI (softspi) to be used with sdfat?

and would not be better then to define everything at one place like :

#define SS_ISNOT_CS

uint8_t const CS1_PIN   = <pin number for PXY>;
uint8_t const SS_PIN   = <pin number for PB4>;
uint8_t const MOSI_PIN = <pin number for PB5>;
uint8_t const MISO_PIN = <pin number for PB6>;
uint8_t const SCK_PIN  = <pin number for PB7>;
uint8_t const  SD_CHIP_SELECT_PIN = CS1_PIN;

when the SS is not being used as the CS (but must be set to output or the input pulled high), and the SS shall be then set properly inside the sdfat as well..

@crossroads - then you have to set SS to output when not used as the CS, and it may work..

Go Up