Go Down

Topic: 1284P - help jumping into the deep end.... (Read 1 time) previous topic - next topic

point5

Jul 27, 2012, 05:04 pm Last Edit: Jul 27, 2012, 07:57 pm by point5 Reason: 1
Hi,

I'm just looking to pull together my first microcontroller circuit using the Atmega 1294P and wondered if I could ask the good folk here a few questions?

- Would the pin mapping below give me good Arduino/Mega compatibility?
- If I want to run the 1284P @ 3V3 with an 8 Mhz crystal what fuses settings would I use?
- I propose using the Mighty-1284P Bootloader: https://github.com/maniacbug/mighty-1284p


Any pointers much appreciated :-)

BlueJakester

I can't answer your questions, but there is nice online fuse calculator here:

http://www.engbedded.com/fusecalc

cyclegadget

mighty-1284p / boards.txt

https://github.com/maniacbug/mighty-1284p/blob/master/boards.txt

Code: [Select]
##############################################################

mighty8.name=Original Mighty 1284p 8MHz
mighty8.upload.protocol=stk500v1
mighty8.upload.maximum_size=129024
mighty8.upload.speed=28800
mighty8.bootloader.low_fuses=0xff
mighty8.bootloader.high_fuses=0xdc
mighty8.bootloader.extended_fuses=0xfd
mighty8.bootloader.path=standard
mighty8.bootloader.file=ATmegaBOOT_1284P_8MHz.hex
mighty8.bootloader.unlock_bits=0x3F
mighty8.bootloader.lock_bits=0x0F
mighty8.build.mcu=atmega1284p
mighty8.build.f_cpu=8000000L
#mighty8.build.core=arduino:arduino
mighty8.build.core=standard
mighty8.build.variant=standard
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

CrossRoads

Add some more parts:
100nF, Aref to Gnd.
10K, reset to +3.3V.
Diode, 1n4148 or similar, reset (cathode) to +3.3V (anode).

Downloading sketches via FTDI Basic/CP2102 module? Add this:
100nF cap, from DTR on Serial/USB adapter to Reset.
6 pin connector with these pins:
DTR, Tx, Rx, +3.3, GND, GND

Downloading bootloader/sketches via ICSP? Add these:
6-pin 2x3 connector with these pins:
SCK, MISO, MOSI, +3.3, Reset, GND

Check Uno schematic for signal connections to the USB/Serial adapter (FTDI) and Programming adapter (ICSP).
Those 2 headers will make programming much easier for you, no need to pull the part out & plug it into something else and risk damaging the pins.

When you select Board type for programming: Looks like you have the pinouts I defined for Bobuino.
If you select Mighty 1284, signals will not be where you think they are.
(its a little odd seeing the signal names Under the pins, I guess that works too).
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

point5

Thanks folks - very helpful and more.... starting to come together now :-)..... see attached.

Not sure if I need R1 on the UART reset?
Not sure if I should be using D20 & D21 for I2C or the more usual A4 & A5?... keen to keep the software as compatible as possible if I can.
I guess I need some sort of 5V to 3V3 regulator on the UART input?

Do you think I should be adding anything else or make this sweet... or spot any oooopsies?

CrossRoads

UART connector is already pulled up via R5. A second resistor is not needed.
You should pullup RST on the RTC, don't want that pin floating.

D1 is installed backwards. Flip it around. Idea is that any spikes from the reset switch are taken out by the 3.3V supply.

1284 uses different pins for I2C, not shared with A4/A5.
You will talk over I2C with Wire.send() & Wire.receive() commands, the software mapping will send it out via physical pins 22 & 23.
If you want SCL/SDA to appear at A4/A5 as well, you can connect the pins and make sure the software sets A4/A5 as inputs so there is no interfence.

You have 2 10K pullup resistors for Reset, R1 and R5. Only need 1.  Same with the Reset switch.
If you want separate Reset for Xbee and uC, they need seperate names.

I can see a programming conflict for you to watch out for:
If you program with an Atmel AVR ISP MKii, it senses the voltage on the ICSP connector and adjusts signal levels accordingly. You put 3.3V on that pin, power the board from a 3.3V source, all is good.
If you download a sketch via the UART header, use an FTDI Basic set for 3.3V, all is good.
http://www.gravitech.us/arliandpropr.html
Either change 5V to 3.3V on those, or add a jumper or something so that 5V and 3.3V can be connected for bringing in 3.3V on those pins.

If you use Arduino as ISP, or any other programmer, I am not sure the levels will be at 3.3V.
I would remove the Xbee and any installed SD/uSD card during programming to ensure they are not damaged.
The 1284 at 8MHz will program just fine from 3.3V or 5V.  Similarly, I don't think the RTC cares.

I see a solder jumper on the square wave output - that is generally an open drain output, it will need a pullup resistor as well.

You have 10 IO you have not brought out to any connector. I would at least put a 1-hole header (see Sparkfun M01) next to the uC pins so one could access them if needed.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

point5

Thanks CrossRoads, very helpful indeed.  I have updated the circuit and will post again over the weekend once I have added the additional headers..... off to watch the olympics now :-)

Not sure what to do about the 5V still, I can see myself burning something by accident - what would be the best of introducing a regulator into the circuit to avoid too much smoke?  Also, are there some reverse polarity projects I should put in place?... I will be adding a 5V DC input header to the board too.

CrossRoads

Its not just power - its the signal levels.
Devices powered from 3.3V don't want to see their IO driven much past 3.6 or maybe 3.8V.

Why do you want to bring 5V into the board when everything is running on 3.3V?

Maybe add zeners across the pins to ensure the signals are held low no matter what.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

point5

Hi CrossRoads,

I guess I just need to be careful to input 3V3 when connecting up to the USB :-)

Attached is the latest iteration of the schematic - now included are some headers for Ethernet etc (May well change the Ethernet to a WIZ820io module if I can find an Eagle LBR).  Also added a power LED & 3V3 regulator from 5V input along with TX & RX LEDs.

Getting there hopefully :-)

CrossRoads

Where is the resistor for Xbee reset? As drawn, it is a floating input pin.

Diode D2 - what will reduce the LD1117AS33 from 3.3 down to ~2.6.
Put the diode on the other side to provide reverse polarity protetion from Vin.
Add 10uF cap in parallel with C11. I would personnally add 10 uF with C10 too.
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00002116.pdf

One more cap - 100nF on SD card socket Vdd pin.

Your Power, Rx, Tx LEDs are backwards - they need to be flipped so a High on the 3 signals will turn the LEDs on.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

point5

Oooops some silly mistakes there... thanks again for helping me with this :-).... you can see I need it.

Do you think the SOT223 version of the 1117 regulator be up to this application?
Also, can the 100nF filter cap c11 on the power supply circuit be a ceramic type or best to stick with electrolytic?
Do you think I should change the current limiting resistors for the LEDs to 1K?
Should I have a protection diode on the DC_IN GND too?

Here is the latest version....

point5

Hi, so good progress with this 1284p project, thanks for all your help :-)  All up and running on 3V3 @ 8mhz and responding well.  My next task is to get the pin map sorted but I'm not sure what I'm doing.... does anyone know of a good tutorial or can help me match the pins_arduino.h below with my schematic below?  Thanks.

Code: [Select]
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <avr/pgmspace.h>

// ATMEL ATMEGA1284P
//
//                       +---\/---+
//           (D 8) PB0  1|        |40  PA0 (AI 5 / D29)
//           (D 9) PB1  2|        |39  PA1 (AI 4 / D28)
//     INT2 (D 14) PB2  3|        |38  PA2 (AI 3 / D27)
//      PWM (D 15) PB3  4|        |37  PA3 (AI 2 / D26)
//   PWM/SS (D 10) PB4  5|        |36  PA4 (AI 1 / D25)
//     MOSI (D 11) PB5  6|        |35  PA5 (AI 0 / D24)
// PWM/MISO (D 12) PB6  7|        |34  PA6 (AI 6 / D30)
//  PWM/SCK (D 13) PB7  8|        |33  PA7 (AI 7 / D31)
//                 RST  9|        |32  AREF
//                 VCC 10|        |31  GND
//                 GND 11|        |30  AVCC
//               XTAL2 12|        |29  PC7 (D 23)
//               XTAL1 13|        |28  PC6 (D 22)
//       RX0 (D 0) PD0 14|        |27  PC5 (D 21) TDI
//       TX0 (D 1) PD1 15|        |26  PC4 (D 20) TDO
//  RX1/INT0 (D 2) PD2 16|        |25  PC3 (D 19) TMS
//  TX1/INT1 (D 3) PD3 17|        |24  PC2 (D 18) TCK
//       PWM (D 4) PD4 18|        |23  PC1 (D 17) SDA
//       PWM (D 5) PD5 19|        |22  PC0 (D 16) SCL
//       PWM (D 6) PD6 20|        |21  PD7 (D 7) PWM
//                       +--------+
//

/*
   PCINT15-8: D7-0  : bit 1
   PCINT31-24: D15-8  : bit 3
   PCINT23-16: D23-16 : bit 2
   PCINT7-0: D31-24   : bit 0
   */

#define NUM_DIGITAL_PINS            31
#define NUM_ANALOG_INPUTS           8
//#define analogInputToDigitalPin(p)  ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)
#define analogInputToDigitalPin(p)  ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)

#define digitalPinToAnalogPin(p)    ( (p) >= 24 && (p) <= 31 ? ((p) < 30 ? 5-((p)-24) : ((p) - 24)) : (((p)<=5) ? 5-(p) : (((p)<=7) ? (p) : -1 )) )
#define digitalPinHasPWM(p)         ((p) == 4 || (p) == 5 || (p) == 6 || (p) == 7 || (p) == 10 || (p) == 12 || (p) == 13 || (p) == 15)

static const uint8_t SS   = 10;
static const uint8_t MOSI = 11;
static const uint8_t MISO = 12;
static const uint8_t SCK  = 13;

static const uint8_t SDA = 17;
static const uint8_t SCL = 16;
static const uint8_t LED = 23;

static const uint8_t A0 = 24;
static const uint8_t A1 = 25;
static const uint8_t A2 = 26;
static const uint8_t A3 = 27;
static const uint8_t A4 = 28;
static const uint8_t A5 = 29;
static const uint8_t A6 = 30;
static const uint8_t A7 = 31;

#define digitalPinToPCICR(p)    ifpin(p,&PCICR,(uint8_t *)0)
#define digitalPinToPCICRbit(p) ifpin(p,digital_pin_to_pcint[p] >> 3,(uint8_t *)0)
#define digitalPinToPCMSK(p)    ifpin(p,__pcmsk[digital_pin_to_pcint[]],(uint8_t *)0)
#define digitalPinToPCMSKbit(p) ifpin(p,digital_pin_to_pcint[p] & 0x7,(uint8_t *)0)

#ifdef ARDUINO_MAIN

#define PA 1
#define PB 2
#define PC 3
#define PD 4

const uint8_t digital_pin_to_pcint[NUM_DIGITAL_PINS] =
{
  24, // D0 PD0
  25, // D1 PD1
  26, // D2 PD2
  27, // D3 PD3
  28, // D4 PD4
  29, // D5 PD5
  30, // D6 PD6
  31, // D7 PD7
  8, // D8 PB0
  9, // D9 PB1
  12, // D10 PB4
  13, // D11 PB5
  14, // D12 PB6
  15, // D13 PB7
  10, // D14 PB2
  11, // D15 PB3
  16, // D16 PC0
  17, // D17 PC1
  18, // D18 PC2
  19, // D19 PC3
  20, // D20 PC4
  21, // D21 PC5
  22, // D22 PD6
  23, // D23 PC7

  5, // D31 PA7
  4, // D30 PA6
  3, // D24 PA5
  2, // D25 PA4
  1, // D26 PA3
  0, // D27 PA2
  6, // D28 PA1
  7, // D29 PA0

//  7, // D31 PA7
//  6, // D30 PA6
//  0, // D24 PA5
//  1, // D25 PA4
//  2, // D26 PA3
//  3, // D27 PA2
//  4, // D28 PA1
//  5, // D29 PA0
};

const uint16_t __pcmsk[] =
{
  (uint16_t)&PCMSK0,
  (uint16_t)&PCMSK1,
  (uint16_t)&PCMSK2,
  (uint16_t)&PCMSK3
};

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
(uint16_t) &DDRA,
(uint16_t) &DDRB,
(uint16_t) &DDRC,
(uint16_t) &DDRD,
};

const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
(uint16_t) &PORTA,
(uint16_t) &PORTB,
(uint16_t) &PORTC,
(uint16_t) &PORTD,
};

const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
(uint16_t) &PINA,
(uint16_t) &PINB,
(uint16_t) &PINC,
(uint16_t) &PIND,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PD, /* 0 */
PD,
PD,
PD,
PD,
PD,
PD,
PD,
PB, /* 8 */
PB,
PB,
PB,
PB,
PB,
PB,
PB,
PC, /* 16 */
PC,
PC,
PC,
PC,
PC,
    PC,
PC,
PA, /* 24 */
PA,
PA,
PA,
PA,
PA,
PA,
PA  /* 31 */
};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /* 0, port D */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(0), /* 8, port B */
_BV(1),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(2),
_BV(3),
_BV(0), /* 16, port C */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(5), /* 24, port A */
_BV(4),
_BV(3),
_BV(2),
_BV(1),
_BV(0),
_BV(6),
_BV(7)
};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 1 - PD0 */
NOT_ON_TIMER, /* 2 - PD1 */
NOT_ON_TIMER, /* 3 - PD2 */
NOT_ON_TIMER, /* 4 - PD3 */
TIMER1B,      /* 5 - PD4 */
TIMER1A,      /* 6 - PD5 */
TIMER2B,      /* 7 - PD6 */
TIMER2A,      /* 8 - PD7 */

NOT_ON_TIMER, /* 8  - PB0 */
NOT_ON_TIMER, /* 9  - PB1 */
TIMER0B, /* 10 - PB4 */
NOT_ON_TIMER, /* 11 - PB5 */
TIMER3A, /* 12 - PB6 */
TIMER3B, /* 13 - PB7 */
NOT_ON_TIMER, /* 14 - PB2 */
TIMER0A,      /* 15 - PB3 */

NOT_ON_TIMER, /* 16 - PC0 */
NOT_ON_TIMER,   /* 17 - PC1 */
NOT_ON_TIMER,   /* 18 - PC2 */
NOT_ON_TIMER,   /* 19 - PC3 */
NOT_ON_TIMER,   /* 20 - PC4 */
NOT_ON_TIMER,   /* 21 - PC5 */
NOT_ON_TIMER,   /* 22 - PC6 */
NOT_ON_TIMER,   /* 23 - PC7 */
NOT_ON_TIMER,   /* 24 - PA0 */
NOT_ON_TIMER,   /* 25 - PA1 */
NOT_ON_TIMER,   /* 26 - PA2 */
NOT_ON_TIMER,   /* 27 - PA3 */
NOT_ON_TIMER,   /* 28 - PA4 */
NOT_ON_TIMER,   /* 29 - PA5 */
NOT_ON_TIMER,   /* 30 - PA6 */
NOT_ON_TIMER    /* 31 - PA7 */
};

#endif // ARDUINO_MAIN

#endif // Pins_Arduino_h
// vim:ai:cin:sts=2 sw=2 ft=cpp

Go Up