Pages: 1 ... 4 5 [6] 7 8 9   Go Down
Author Topic: Mega Junior,1284  (Read 11594 times)
0 Members and 3 Guests are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
just sun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi jbaum81,

i have setuped a 1284P on a BreadBoard for testing.
at the moment i have loaded it with the mighty 1284P optiboot 16MHz
but just out of interest i would love to try the 20MHz version.

i have looked at your version and found that you have lowFuse set to 0xD7
if i have interpreted the atmel datasheet the right way this means:
(table based on datasheet page 298; 27.2 Fuse bits and page 31..; 9. System clock and clock options)
Code:
CKDIF8  CKOUT  SUTn  CKSELn   hex    comment
               1 0   3 2 1 0      
1       1      1 1   0 1 1 1   0xF7  Full swing Crystal Oscillator, slowly rising power;  mighty modified;
1       1      0 1   0 1 1 1   0xD7  Full swing Crystal Oscillator, slowly rising power, BOD enabled; <--your version?!
1       1      1 1   1 1 1 1   0xFF  Low Power Crystal Oscillator,  slowly rising power; mighty optiboot;

[edit] corrected - read this message from oric_dan for orig.  [/edit]

[original]CKOUT is explained at page 39; 9.10 Clock Output Buffer: if set it will output the CPU-frequenz on the CLKO pin. (overriding normal port io functionality)
so do you using this for something?
or is there some other thinks i don't know about this? (i am new to bootloaders and system clock..)[/original]


and has someone a nice 'tutorial' how to compile the bootloaders self?
or is it to complicated and you have to know to much background infos?
thanks for your time.

sunny greetings stefan
« Last Edit: May 19, 2013, 04:05:35 pm by s-light » Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

jbaum is using the fix that was discovered on a couple of incredibly long threads about 1284
RX0 problems from back in february 2013. With the fuse bit settings used in the maniac 1284
bootloader files [low power oscillator], chip operation is disrupted because of crosstalk between
RX0 and the crystal pins. Maniacbug still hasn't fixed his files.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23710
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That crosstalk is not apparent in all designs.

I use these fuse settings for boards with the Bobuino pinout variant, and I don't see any crosstalk issues.

Code:
bobuino.name=Bobuino
bobuino.upload.protocol=arduino
bobuino.upload.maximum_size=130048
bobuino.upload.speed=115200
bobuino.bootloader.low_fuses=0xff
bobuino.bootloader.high_fuses=0xde
bobuino.bootloader.extended_fuses=0xfd
bobuino.bootloader.path=optiboot
bobuino.bootloader.file=optiboot_atmega1284p.hex
bobuino.bootloader.unlock_bits=0x3F
bobuino.bootloader.lock_bits=0x0F
bobuino.build.mcu=atmega1284p
bobuino.build.f_cpu=16000000L
#bobuino.build.core=arduino:arduino
bobuino.build.core=standard
bobuino.build.variant=bobuino
Not even on this wirewrap board, with no ground plane


* 1284_test_board_ICSP_FTDI.jpg (177.11 KB, 795x618 - viewed 12 times.)

* Bootloading-programming-wirewrap.jpg (554.4 KB, 2896x2327 - viewed 15 times.)

* Wirewrap_back1.jpg (798.25 KB, 1995x2404 - viewed 14 times.)
Logged

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.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I forgot to mention that a couple of us never saw the RX0 problem with our
boards, but a lot of other people did, and changing to full power oscillator is what
seemed to be the key to fixing it.
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the subject of the firmware, I've found an issue with my digital numbering (some typo's) in my pins_arduino.h file while fixing it I discovered the core seems to be ignoring my port numbering for A0-A7 and always wants to make PA0 A0, PA1 A1 and so on. This appears to affect the bobuino similarly . I'm not real strong in C so it may take me a few days to get it all ironed out but if someone wants to chip in and help find a fix it would be appreciated. I think I have A0 - A5 (PA7 - PA2) working correctly once I have that I'll post the contents of the pins file.
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

See if this helps,
https://github.com/maniacbug/mighty-1284p/issues/5
Logged

Zurich
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys,
what I did so far is to use the 1284p TQFP package uC on an Arduino Uno clone. The pins on the headers are the same as for the Uno. There are no extra headers for the additional port. I'm using the mighty-1284p 8MHz bootloader. My uC is running on 3.3V at 8MHz.

I did this wiring:


Code:
// ATMEL ATMEGA1284P TQFP
// ----------------------
//
//                  D10 D9  D8                  A0  A1  A2  A3
//
//                  PB4 PB3 PB2 PB1 PB0 GND VCC PA0 PA1 PA2 PA3
//
//                  44  43  42  41  40  39  38  37  36  35  34
//                 +------------------------------------------+
//  PB5  D11   1   |                                          |  33    PA4  A4
//                 |  O                                       |
//  PB6  D12   2   |                                          |  32    PA5  A5
//                 |                                          |
//  PB7  D13   3   |                                          |  31    PA6
//                 |                                          |
//  RESET      4   |                                          |  30    PA7
//                 |                                          |
//  VCC        5   |                                          |  29    AREF
//                 |                                          |
//  GND        6   |                                          |  28    GNC
//                 |                                          |
//  XTAL2      7   |                                          |  27    AVCC
//                 |                                          |
//  XTAL1      8   |                                          |  26    PC7
//                 |                                          |
//  PD0   D0   9   |                                          |  25    PC6
//                 |                                          |
//  PD1   D1  10   |                                          |  24    PC5
//                 |                                          |
//  PD2   D2  11   |                                          |  23    PC4
//                 +------------------------------------------+
//                  12  13  14  15  16  17  18  19  20  21  22
//
//                  PD3 PD4 PD5 PD6 PD7 VCC GND PC0 PC1 PC2 PC3
//
//                  D3  D4  D5  D6  D7



And I mapped it like this (pins_arduino.h):

Code:
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <avr/pgmspace.h>

*
   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 digitalPinHasPWM(p)         ((p) == 3 || (p) == 4 || (p) == 6 || (p) == 7 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15)

static const uint8_t SS   = 4;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK  = 7;

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

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)    (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
#define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0)))
#define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
#define digitalPinToPCMSKbit(p) ((p) % 8)

#ifdef ARDUINO_MAIN

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

// 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(2), /* 8, port B */
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(0),
_BV(1),
_BV(0), /* 16, port C */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7),
_BV(0), /* 24, port A */
_BV(1),
_BV(2),
_BV(3),
_BV(4),
_BV(5),
_BV(6),
_BV(7)
};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 8  - PD0 */
NOT_ON_TIMER, /* 9  - PD1 */
NOT_ON_TIMER, /* 10 - PD2 */
NOT_ON_TIMER, /* 11 - PD3 */
TIMER1B,      /* 12 - PD4 */
TIMER1A,      /* 13 - PD5 */
TIMER2B,      /* 14 - PD6 */
TIMER2A,      /* 15 - PD7 */
NOT_ON_TIMER, /* 0  - PB0 */
NOT_ON_TIMER, /* 1  - PB1 */
NOT_ON_TIMER, /* 2  - PB2 */
TIMER0A,      /* 3  - PB3 */
TIMER0B,        /* 4  - PB4 */
NOT_ON_TIMER, /* 5  - PB5 */
TIMER3A,        /* 6  - PB6 */
TIMER3B,        /* 7  - PB7 */
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


The bootloader was flashed using an AVRISP MKII without a problem. The sketches can be programmed using an FTDI breakout board as well.
I tested the Digital Pins D0-D13 and the Analog Pins A0-A5 as outputs (modified the Blink sketch to use all the pins to blink).

In order to make more tests I wanted to use an I2C sensor attached to A4 and A5 which does not work. Do I need to change the

Code:
const uint8_t PROGMEM digital_pin_to_timer_PGM[] {...};

directive in the pins_arduino.h somehow?

Thanks for your help,
Michael.
Logged

Kind Regards/Mit freundlichen Grüssen,
Dr. Michael Kroll.
---
Blog: http://www.mkroll.mobi
Forum: http://forum.mkroll.mobi
Twitter: @dr_m_kr

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23710
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I2C is not shared with A4/A5 on the 1284, they are on seperate hardware pins:

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

Use normal Wire.send, Wire. receive commands, but connect to different pins.
Logged

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.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bob, ya beat me to it by 1-minute. BTW, on another thread someone said the I2C pins are
not "fully open-drain" [or somesuch, whatever that means], so you cannot get I2C on a 5V
chip to talk to I2C on a 3.3V chip properly, or you'll overdrive the 3.3V pins. Do you know
anything thing about this?
Logged

Zurich
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

For SDA and SCL the pins are 16 and 17
Code:
static const uint8_t SDA = 17;
static const uint8_t SCL = 16;

But what 16 and 17? Pins of the chip? Cannot be. The datasheet states for the PDIP Package
that SDA is pin 23 and SCL is pin 22 for TQFP/QFN/MLF the pins are SDA 20 and SCL 19

So I'm very confused with that listing:

Can someone explain what this is all about?

Code:
static const uint8_t SS   = 4;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK  = 7;

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

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;

Thank you very much,
Michael.
Logged

Kind Regards/Mit freundlichen Grüssen,
Dr. Michael Kroll.
---
Blog: http://www.mkroll.mobi
Forum: http://forum.mkroll.mobi
Twitter: @dr_m_kr

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23710
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@oric_dan,
If the internal pullups to 5V are turned off, see 22.5.1, then external pullups to 3.3V can be used for interfacing to 3.3V devices.

22.2.2 Electrical Interconnection
As depicted in Figure 22-1, both bus lines are connected to the positive supply voltage through pull-up resistors.
The bus drivers of all TWI-compliant devices are open-drain or open-collector. This implements a wired-AND function
which is essential to the operation of the interface. A low level on a TWI bus line is generated when one or
more TWI devices output a zero. A high level is output when all TWI devices tri-state their outputs, allowing the
pull-up resistors to pull the line high. Note that all AVR devices connected to the TWI bus must be powered in order
to allow any bus operation.
The number of devices that can be connected to the bus is only limited by the bus capacitance limit of 400 pF and
the 7-bit slave address space. A detailed specification of the electrical characteristics of the TWI is given in ”Twowire
Serial Interface Characteristics” on page 313. Two different sets of specifications are presented there, one relevant
for bus speeds below 100kHz, and one valid for bus speeds up to 400kHz.



22.5.1 SCL and SDA Pins
These pins interface the AVR TWI with the rest of the MCU system. The output drivers contain a slew-rate limiter in
order to conform to the TWI specification. The input stages contain a spike suppression unit removing spikes
shorter than 50 ns. Note that the internal pull-ups in the AVR pads can be enabled by setting the PORT bits corresponding
to the SCL and SDA pins, as explained in the I/O Port section. The internal pull-ups can in some systems
eliminate the need for external ones.

@Mkroll,
If you look at these 3 arrays:
const uint8_t PROGMEM digital_pin_to_port_PGM[] =

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =

const uint8_t PROGMEM digital_pin_to_timer_PGM[] =


The first assigns Ports to software-named pins, (D0-31)
the second assigns pins within the ports, (also for D0-31)
the third assigns whether the pin has a timer associated  with it for PWM (for D0-31 again).

Linking them together, you can see that PC0 is D16 and PC1 is D17.
Reviewing the '1284 datasheet, PC0 is SCL and PC1 is SDA.

Then it is up to the user to connect the physical pin for PC0 and PC1 to the I2C devices.
The code does not know or care which physical package the chip die is in, only that PC0 and PC1 will be manipulated for I2C.

There also a  couple other lines that map analog pins to digital pins, and PWM pins to digital pins

#define analogInputToDigitalPin(p)  ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)

#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 4 || (p) == 6 || (p) == 7 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15)

and similar for PCINTs:
(Pin Change Interrupt Control Register, and Pin Change Mask Register, names are something along those lines)

#define digitalPinToPCICR(p)    (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
#define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0)))
#define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
#define digitalPinToPCMSKbit(p) ((p) % 8 )







« Last Edit: May 14, 2013, 02:41:30 pm by CrossRoads » Logged

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.

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
just sun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

jbaum is using the fix that was discovered on a couple of incredibly long threads about 1284
RX0 problems from back in february 2013. With the fuse bit settings used in the maniac 1284
bootloader files [low power oscillator], chip operation is disrupted because of crosstalk between
RX0 and the crystal pins. Maniacbug still hasn't fixed his files.

Hi oric_dan,
yea i have read a lot of this - it makes sens to use the full swing if you dont care about power..
my main question is :
Why is the CKOUT activated?

sunny greetings stefan
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why is the CKOUT activated?
I'm not sure what you're referring to. CKOUT = pin 2 on the chip?

You only need to use the XTAL1,XTAL2 pins.
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
just sun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey all,

you are right - CKOUT is PB1 == pin number 2 on the dip == pin number 41 on the TQFP;
he maps PB1 to Arduino D1 (check in the pins_arduino.h file)

if i interpret the fuse settings right -
the fuse for CKOUT is set - so it would output the cpu_clock on this pin.
and that means you cant use this pin as Digital IO -
so i just want to know why jbaum has choose to do this.
it could be that i have misunderstood the datasheet..
pleas check my explanation / table in my earlier post
if i have all thinks understood right - it shows - what the settings i have found in the make file - would mean...
iam in the process of learning about bootloaders - so i want just to understand what is going on...
sunny greetings stefan
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmm, I'm no expert on these darn fuses, but I think you had your original post
"backwards". 0xD = 1101, not 1011.
Code:
CKDIF8  CKOUT  SUTn  CKSELn   hex    comment
               1 0   3 2 1 0      
1       1      1 1   0 1 1 1   0xF7  Full swing Crystal Oscillator, slowly rising power;  mighty modified;
1       0      1 1   0 1 1 1   0xD7  Full swing Crystal Oscillator, slowly rising power, CKOUT Enabled; <--your version?!
1       1      1 1   1 1 1 1   0xFF  Low Power Crystal Oscillator,  slowly rising power; mighty optiboot;

Code:
Table 27-5. Fuse Low byte.
Fuse Low byte Bit no. Description Default value
CKDIV8 (4)    7 Divide clock by 8        0 (programmed)
CKOUT (3)     6 Clock output             1 (unprogrammed)
SUT1          5 Select start-up time     1 (unprogrammed) (1)
SUT0          4 Select start-up time     0 (programmed) (1)
CKSEL3        3 Select Clock source      0 (programmed) (2)
CKSEL2        2 Select Clock source      0 (programmed) (2)
CKSEL1        1 Select Clock source      1 (unprogrammed) (2)
CKSEL0        0 Select Clock source      0 (programmed) (2)
« Last Edit: May 19, 2013, 03:43:17 pm by oric_dan » Logged

Pages: 1 ... 4 5 [6] 7 8 9   Go Up
Jump to: