Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Microcontrollers / Boot loader for ATmega8U2 on: February 25, 2012, 03:46:07 pm
Is there a boot loader for the ATmega8U2 that would allow for loading sketches via USB, much like the Leonardo?
2  Using Arduino / Microcontrollers / Re: ATmega1284P: End to End using 1.0 IDE on: February 23, 2012, 09:33:05 pm
I get the mappings from pins to ports, pins to bits, pins to timers. But the portions I posted I don't understand. Also, when I compare it to other variants the differences are quite significant. I did the pins_arduino.h file for the 32U4, as my board uses a different pin assignment (the whole purpose for making a board and not using vinciduino). There are quite a few differences between the 1284p and 32u4 files that are not just pin assignments.
3  Using Arduino / Microcontrollers / Re: ATmega1284P: End to End using 1.0 IDE on: February 23, 2012, 09:02:38 pm
I am trying to create a pins_arduino.h. But there are a few things I do not understand. I think I used the bobuino pins_arduino.h as a template. But what do I need to do with this, anything?

Code:
#define analogInputToDigitalPin(p)  ((p < NUM_ANALOG_INPUTS) ? 21 - (p) : -1)

extern const uint8_t digital_pin_to_pcint[NUM_DIGITAL_PINS];
extern const uint16_t __pcmsk[];
extern const uint8_t digital_pin_to_timer_PGM[NUM_DIGITAL_PINS];

#define ifpin(p,what,ifnot)     (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (what) : (ifnot))
#define digitalPinHasPWM(p)         ifpin(p,pgm_read_byte(digital_pin_to_timer_PGM + (p)) != NOT_ON_TIMER,1==0)

#define digitalPinToAnalogPin(p)    ( (p) >= 14 && (p) <= 21 ? (p) - 14 : -1 )
#define analogPinToChannel(p)     ( (p) < NUM_ANALOG_INPUTS ? NUM_ANALOG_INPUTS - (p) : -1 )

and

Code:
#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)

and finally here is the pin mapping I am using:

Code:
// *uino-1284p v0.8 pin assignment
//
// D0               9  - PD0                (PCINT24/RXD0/T3)
// D1               10 - PD1                (PCINT25/TXD0)
// D2               11 - PD2                (PCINT26/RXD1/INT0)
// D3               12 - PD3                (PCINT27/TXD1/INT1)
// D4               13 - PD4    PWM         (PCINT28/XCK1/OC1B)
// D5               14 - PD5    PWM         (PCINT29/OC1A)
// D6               15 - PD6    PWM         (PCINT30/OC2B/ICP)
// D7               16 - PD7    PWM         (PCINT31/OC2A)
//
// D8               42 - PB2                (PCINT10/INT2/AIN0)
// D9               43 - PB3    PWM         (PCINT11/OC0A/AIN1)
// D10      SS      44 - PB4    PWM         (PCINT12/OC0B/SS)
// D11      MOSI    1  - PB5                (PCINT13/ICP3/MOSI)
// D12      MISO    2  - PB6    PWM         (PCINT14/OC3A/MISO)
// D13      SCK     3  - PB7    PWM         (PCINT15/OC3B/SCK)
//
// D14      SDA     20 - PC1                (PCINT17/SDA)
// D15      SCL     19 - PC0                (PCINT16/SCL)
// D16      L1      40 - PB0                (PCINT8/T0/XCK0)
// D17      L2      41 - PB1                (PCINT9/T1/CLK0)
//
// D18              21 - PC2                (PCINT18/TCK)
// D19              22 - PC3                (PCINT19/TMS)
// D20              23 - PC4                (PCINT20/TDO)
// D21              24 - PC5                (PCINT21/TDI)
// D22              25 - PC6                (PCINT22/TOSC1)
// D23              26 - PC7                (PCINT23/TOSC2)
//
// A0       D24     37 - PA0                (PCINT0/ADC0)
// A1       D25     36 - PA1                (PCINT1/ADC1)
// A2       D26     35 - PA2                (PCINT2/ADC2)
// A3       D27     34 - PA3                (PCINT3/ADC3)
// A4       D28     33 - PA4                (PCINT4/ADC4)
// A5       D29     32 - PA5                (PCINT5/ADC5)
// A6       D30     31 - PA6                (PCINT6/ADC6)
// A7       D31     30 - PA7                (PCINT7/ADC7)
4  Using Arduino / Microcontrollers / Re: ATmega1284P: End to End using 1.0 IDE on: February 20, 2012, 06:02:39 pm
I have some pictures of the assembled boards if anyone is interested...
http://adis.ca/post/uino-32u4-uino-1284p-alive/
5  Using Arduino / Microcontrollers / Re: ATmega1284P: End to End using 1.0 IDE on: February 20, 2012, 05:59:42 pm
I can't help you with the 1284p, but the pins_arduino.h is already done for the 32u4 in hardware / arduino / variants / leonardo of the Arduino install folder.

Correct, but my 32U4 pinout is different then the Leonardo pinout. So I will still need to modify pins_arduino.h for both boards, and understand how that is done.
6  Using Arduino / Microcontrollers / Re: ATmega1284P: End to End using 1.0 IDE on: February 20, 2012, 04:38:33 pm
  • Modify the pins_arduino.h to reflect the pinout of the board I created.
  • Create a shield to exercise, verify the various functions of the pins. The way I see it, I need to verify the digital outputs and the PWM functions as well as the analog inputs at the very least.

I would really appreciate any information or instructions on how to go about defining pins in pins_arduino.h. I not only have to do this for the *uino-1284p but also for the *uino-32u4.
7  Using Arduino / Microcontrollers / Re: ATmega1284P: End to End using 1.0 IDE on: February 20, 2012, 04:34:32 pm
I finally completed my *uino-1284p board. I successfully loaded the firmware into the ATmega8u2 doing the USB to serial task using avrdude command line on a Mac. I was dreading this task a little, but it turned out there is really good information in the Arduino firmware folder. Using the mighty-1284p files I was able to load the bootloader into the ATmega1284p. I only tried the "Original Mighty 1284p", not the optiboot one. Will try optiboot as well. I was also able to load a sketch to do some blink lights.

Next I need to accomplish two things:

  • Modify the pins_arduino.h to reflect the pinout of the board I created.
  • Create a shield to exercise, verify the various functions of the pins. The way I see it, I need to verify the digital outputs and the PWM functions as well as the analog inputs at the very least.

I assembled the version 0.3 board. So far I encountered two issues. The first issue is the polarity of the reverse polarity protection diode on the external power input is marked wrong. If connected as indicated the board won't power up with proper polarity connected. The second issue is the reset tact switch. I do not know what footprint I picked, I thought it was a standard tact switch, but it is smaller, small enough that a "regular" tact switch won't fit. I will have to find the proper part to fit that space.

If anyone is interested in a bare PCB I will gladly mail one out to you.

  • *uino-1284p version 0.3
  • *uino-1284p version 0.2
8  Using Arduino / Microcontrollers / Re: How to burn bootloader hex using AVR MKII on Mac on: February 17, 2012, 04:01:24 pm
But would that also work to burn the software into the ATmega8U2 doing the USB to serial conversion?
9  Using Arduino / Microcontrollers / How to burn bootloader hex using AVR MKII on Mac on: February 17, 2012, 12:28:44 pm
How would I go about burning the bootloader into the AVR chip using an AVR ISP MKII? I would like to program the hex file without using the Arduino IDE.
10  Using Arduino / Programming Questions / Re: Use define, const, or enum? on: January 21, 2012, 05:07:37 pm
  • Modify the Arduino IDE so "-fshort-enums" is passed to the compiler.  If you choose this option please ask for the changes to be merged.
  • Using your example above, simply change the type of state (extern uint8_t state;).  The rest of your code will work unaltered.

I changed it to extern uint8_t state;. The result is 3366 bytes, so no difference in code size between using enum, const or define. I suppose it then comes down to preference, readability, etc...

Thank you!
11  Using Arduino / Programming Questions / Re: Use define, const, or enum? on: January 21, 2012, 03:08:20 pm
As an old-school guy, I always use #define, and that is still a very commonly seen idiom for any constant requirements.

Well, to me a variable is just that, a container to hold value that is changed by the program. As such I would expect it to be stored in RAM. A #define to me is like a macro, something the compiler replaces with the value, something that is defined once and cannot be changed during program execution.

Personally I prefer #define. But then I am learning a lot and I am not adverse to doing things in a different way of it is beneficial.
12  Using Arduino / Programming Questions / Re: Multiple source files and global variables on: January 21, 2012, 02:38:49 pm
Oh... this means then,

"extern int foo;" -> declares a variable which essentially informs the compiler we intent to use it
"int foo;" -> defines the variable and causes memory to be allocated, but the content is undefined
"int foo = 42;" -> defines and initializes the variable, memory is allocated and set to the value (42)

Thank you!
13  Using Arduino / Programming Questions / Re: Use define, const, or enum? on: January 21, 2012, 01:54:11 pm
Using a tiny test I created for a different problem, found out that using enum uses more memory. Somewhere I read that enum is an int, is that true? If so, then it would make sense since int is 2 bytes versus char 1 byte. Is it possible to make the enum and uint8_t?

Code:
enum state_t {
  high,
  low
};

extern state_t state;

Result:  Binary sketch size: 3380 bytes (of a 30720 byte maximum)

Code:
#define low    1
#define high   0

extern char state;

Result:  Binary sketch size: 3366 bytes (of a 30720 byte maximum)

Code:
const char low = 1;
const char high = 0;

extern char state;

Result:  Binary sketch size: 3366 bytes (of a 30720 byte maximum)
14  Using Arduino / Programming Questions / Re: Use define, const, or enum? on: January 21, 2012, 01:09:54 pm

Great, that explains the const versus define very well.

But what about enum? What is accomplished by using enum instead of multiple const?
Code:
const char BLUE = 0;
const char RED = 1;
const char GREEN = 2;

versus
Code:
enum colors {
  BLUE,
  RED,
  GREEN
};

And I'd be using it like this:
Code:
    switch (get_color()) {
        case BLUE:
            [do something...]
            break;
        case RED;
            [do something else...]
            break;
        case GREEN;
            [do something different...]
            break;
    }
15  Using Arduino / Programming Questions / Re: Use define, const, or enum? on: January 21, 2012, 12:30:26 pm
How do I find it? The forum search didn't bring up anything useful, mostly hits for posts that containe "enum" and the other terms in a totally unrelated context.
Pages: [1] 2 3 ... 7