Mega Junior,1284

As you have an ISP programmer you don't need to use a bootloader, its another source of potential errors. I'd try uploading the blink sketch without a bootloader. That will help you to confirm the board functions as expected. If you find the blink is much slower than expected check the fuses are correct - maybe the divide by 8 bit is programmed. Then test the serial port. When that works as expected then try using a bootloader.

Uploading the blink hex works as expected.
Running an echo sketch with a terminal emulator also works as expected.

Set the fuses to FD, D6 and D7, but still nogo with the bootloader.

I only like to use the bootlader during development stages.

There is an auto-reset enable jumper JP2 on the board. Do you have that jumpered? That should connect the DTR from the FTDI to the 1284P reset pin.

If everything in life were this simple :slight_smile:

Thanks hiduino. This solved the issue.

But of course a new one arrises.
I have a sketch that runs ok on my atmega and compiles ok with the MegaJr v1.1 board selected.

However, when I compile it for the MegaJr SMD board I get a compilation error.

Any idea were I can look to find the source of this?

Can you post the error message? It may help also of you turn on the verbose setting in the IDE preferences.

These are the errors:

C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:59: warning: only initialized variables can be placed into program memory area
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:401: error: 'digital_pin_to_pcint' was not declared in this scope
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: '__pcmsk' was not declared in this scope
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: expected primary-expression before ']' token
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: '__pcmsk' was not declared in this scope
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: 'digital_pin_to_pcint' was not declared in this scope
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: expected primary-expression before ']' token
C:\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:418: error: expected primary-expression before ']' token

Yes, there were some issues with the \variants\MegaJrSMD\pins_arduino.h file. I will review it again, but here a link to some of the issues.

http://forum.arduino.cc/index.php?topic=157654.msg1247340#msg1247340

You can try edit these changes to see if it helps.

Edit: There is another problem with the pins_arduino.h file. There appears to be a problem with how the digital pin to pin change interrupt mappings are defined. Which is affecting SoftwareSerial.
I'll try to work out the mappings.

@jbaum81 the pcint arrays do not work correctly with the macro substitutions. So I tried these changes instead.

These are the changes needed for the \variants\MegaJrSMD\pins_arduino.h file.

#define digitalPinToPCICR(p)    (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
#define digitalPinToPCICRbit(p) (((p) <=  7) ? 3 : \
			        (((p) <= 13) ? 1 : \
			        (((p) <= 19) ? 0 : \
			        (((p) <= 25) ? 2 : \
			        (((p) <= 27) ? 0 : \
			        (((p) <= 29) ? 1 : 2))))))
#define digitalPinToPCMSK(p)    (((p) <=  7) ? (&PCMSK3) : \
			        (((p) <= 13) ? (&PCMSK1) : \
			        (((p) <= 19) ? (&PCMSK0) : \
			        (((p) <= 25) ? (&PCMSK2) : \
			        (((p) <= 27) ? (&PCMSK0) : \
			        (((p) <= 29) ? (&PCMSK1) : \
			        (((p) <= 31) ? (&PCMSK2) : ((uint8_t *)0))))))))
#define digitalPinToPCMSKbit(p) (((p) <=  7) ? (p)         : \
			        (((p) <= 13) ? ((p) -  6 ) : \
			        (((p) <= 19) ? (21  - (p)) : \
			        (((p) <= 25) ? (27  - (p)) : \
			        (((p) <= 27) ? (27  - (p)) : \
			        (((p) <= 29) ? ((p) -  28) : (31 - (p))))))))

You can try the attached file below.

pins_arduino.h (6.69 KB)

The board now works fine. Great to have 128k of memory.

Next step is I want to have a board running at 3.3v. Max CPU frequency in that case is 10MHz.
How do I create a bootloader that works at 10 MHz?

If you look closely at the actually frequency curve in the d/s, you'll see you can "officially" run about 13Mhz at 3.3V.

Despite many people's dire warnings of gloom and doom over the past year, I've been running my 3.3V megas at 16 Mhz for over a year and a half.

Has anyone tetsed the analog comparator on the board?

I can't get it to work properly.

1284p runs fine @16MHz and 3.3V.

Anyone ever use a Mega 2560 @ 3V3 and 16 MHz?.. I'd sure like to. It would make a thing I'd like to build about 1/10th the work If I didn't have to 'mess' with providing interfaces to the GLCD and various radios and other sensors from 5 to 3V3.

Doc

Atmega2560 is not rated to work at that low a voltage:

ATmega2560/ATmega2561:
• 0 - 16 MHz @ 4.5V - 5.5V

You need to use Atmega2560V to go that low:
ATmega2560V/ATmega2561V:
• 0 - 2 MHz @ 1.8V - 5.5V, 0 - 8 MHz @ 2.7V - 5.5V

Docedison, the 2560 is of topic. perhaps you should start a separate post for that.

My 1284 also works fine at 16MHz @ 3.3v, so problem solved :slight_smile:

Only question remaining is about the analog comparator that doesn't seem to work.

I've never tried the analog comparator on any of these chips, but the problem is probably just in getting all the registers set properly. If you're relying on existing code from another processor, that might need some mods for a 1284.

Don't know if this topic is still alive but I can use some help in getting the Mega Junior added to Arduino IDE 1.6.x

Can anyone help me?

With the modern IDE, you're better off creating a "3rd party hw" addon.

You can download the MightyCore. It's recently updated and supports six other pin compatible microcontrollers as well :slight_smile: