Show Posts
Pages: 1 ... 20 21 [22] 23 24 25
316  Using Arduino / Microcontrollers / Bootloader and MCU reset register on: June 21, 2011, 10:13:47 am
I'd like my application to be able to distinguish a power-on reset from an external reset.  It looks like the MCUSR register does what I want, except that the bootloader wipes this register when it runs:

  // Adaboot no-wait mod
  ch = MCUSR;
  MCUSR = 0;
  if (!(ch & _BV(EXTRF))) appStart();

Can I safely replace these lines with the following?

  if (!(MCUSR & _BV(EXTRF))) appStart();
317  Using Arduino / Microcontrollers / Re: changing a Pro Mini 3.3V 8Mhz to 5V 16Mhz on: June 21, 2011, 09:58:08 am
There are 3 timers, plus clock logic for each serial interface (SPI, TWI, and USART).  Although certain pins have several different functions, AFAIK the underlying timers related to those functions are not linked (except in so far as they all use the CPU clock signal).  So using the SPI interface (Arduino pins 10-13) of course means that you can't use the timer outputs OC2A or OC1B (because they share the same pins), but does not otherwise affect the running of Timer-1 and Timer-2.

I found this in the Arduino Playground, which explains how to change the timer clock-prescalers, and what the side-effects are:
For more sophisticated timer control you'll need to wade through the ATMEGA328 datasheet.

The oscillator on the Pro Mini boards is a ceramic, which takes the place of a crystal plus the two support capacitors.  The third connection is to ground.
318  Using Arduino / Microcontrollers / Re: changing a Pro Mini 3.3V 8Mhz to 5V 16Mhz on: June 20, 2011, 05:31:31 pm
I was under the impression that the serial interfaces all had separate clock logic, and were not tied to the timers.  Is this wrong?
319  Using Arduino / Microcontrollers / Re: changing a Pro Mini 3.3V 8Mhz to 5V 16Mhz on: June 20, 2011, 04:02:53 pm
Ye-es that right, but...

...the Pro-Mini is damn small, and myself I really wouldn't like to try de-soldering anything.  You don't need to remove the regulator to run it at 5V: just apply 5V to VCC.  However the oscillator is a 3-pin surface-mount ceramic, which would be extremely difficult to remove.

At 17-euro each, I'd suggest investing in another board.  You'll always find a use for the old one.  Alternatively, you might investigate low-level programming of the timers to get the frequencies you need.
320  Using Arduino / Microcontrollers / Re: New optiboot; beta testers welcome... on: June 19, 2011, 03:58:21 pm
Thanks for the explanations.  For me the new bootloader seems to be working fine.  I have also tested it with ArduinoISP, without disabling auto-reset.

  • Compiled under Windows-7 64-bit with the IDE v0022 tools
  • Uploaded optiboot_atmega328.hex to an Arduino Uno, via Optifix running on another Uno
  • Uploaded optiboot_atmega328.hex to an Arduino Uno, via IDE and ArduinoISP running on another Uno
  • Uploaded optiboot_atmega328.hex to a 5v 16MHz Ardunio Pro
  • Uploaded optiboot_atmega328_pro_8MHz.hex to a 3.3v 8MHz Ardunio Pro
  • All boards now report Firmware Version: 4.4 to AVRdude, and correctly accept sketch uploads from the IDE

The 8MHz and 16MHz Pro boards were tested using an FTDI USB-to-serial interface.  As with previous version of Optiboot, for the 8MHz boards I needed to reduce the baud rate to 57600 in the Makefile and in boards.txt.
321  Using Arduino / Microcontrollers / Re: New optiboot; beta testers welcome... on: June 18, 2011, 06:11:54 am
Very happy to see this project given new life.  I'm just reading through the source changes before trying out the new version, and have a couple of questions:

  • Am I right in thinking that the bootloader exits if it detects any corrupt serial communication, on the assumption that the baud-rate is wrong and therefore the data is not coming from a "normal" AVRdude upload?  Should we expect any communication data to be lost in this process, or will the application be able to re-read the corrupt character at the correct baud rate?
  • I see the version numbers are put into the last two bytes of the bootloader block, and are now accessible both to the application code and via the serial port.  But how do I query the version numbers over the serial port?

Thanks very much for making these updates, and for making the code available.
322  Using Arduino / Programming Questions / Re: I am looking for someone to program Arduino Uno for High Altitude Weather Balloo on: June 06, 2011, 07:20:11 am
Could you have the balloon log all its data to a memory card, and then transmit the whole lot once it is below, say, 3000m?  You avoid the problems of transmitting at very high altitudes, and also the risk of losing the data due to a bad crash-landing in an inaccessible area.  At 3000m it's unlikely to be out of range of a cellular phone network.

It would mean you couldn't chase the balloon whist it is in flight, but you could at least transmit the first part of the takeoff as the balloon ascends, to get an idea of the winds.
323  Using Arduino / Microcontrollers / Re: Breadboarded ATMega328 not responding on: June 05, 2011, 04:36:28 pm
Is your breadboard like this one?

324  Using Arduino / Microcontrollers / Re: Arduino Clone Resets itself on: May 23, 2011, 10:05:46 am
It sounds like a spike from the relay coil is causing the interference.  Does the relay have a suppression diode?

Otherwise, do you have anything connected to the reset pin on the clone board?  If not, try adding a resistor and/or capacitor as on the Uno.  Keep the wires connected to the reset pin short and well separated from the relay.
325  Using Arduino / Microcontrollers / Re: Bootloader for a 1284P @ 16MHz - problems :-( on: May 13, 2011, 01:29:36 pm
If you're using the Adaboot bootloader, then it should flash 4 times on startup, followed by another sequence of flashes to show the version number.

HEX files are ascii text, so can be combined in a text editor.  Just delete the EOF marker of the first file :00000001FF, and then past the second file below.
326  Using Arduino / Microcontrollers / Re: Bootloader for a 1284P @ 16MHz - problems :-( on: May 13, 2011, 07:20:59 am
Does the bootloader blink as it should after a reset?
Can you combine the bootloader hex file with a compiled sketch (blink, for example), and upload the combined hex file via ISP?
That would enable you to verify that the bootloader is running and passing control to the sketch correctly.
327  Using Arduino / Programming Questions / Re: Fastest way to count pulses on: May 09, 2011, 06:53:13 pm
OK, I have now chewed through more than 70 pages of timer documentation.  Phew!  smiley-roll-sweat
And I'm happy to report that it works very, very nicely.  Right now I have Timer-1 counting pulses down to 250ns apart, with no dropped counts.  Not one!  So, thanks very much to Coding Badly for the idea.

Next I need to deal with overflows, and test higher pulse-rates.  The external clock is sampled in sync with the CPU clock, which will limit me to less than half the CPU-frequency (p141-2 of the ATMEL datasheet).  Here's the code, in case anybody else ever needs a reliable and CPU-independent pulse-counter:

  Count pulses on pin 5 via Timer-1
  Start with rising edge on pin 2
  Stop with falling edge on pin 2
   - deal with overflows

#include <Streaming.h>

void setup() {

  pinMode(2, INPUT); digitalWrite(2, HIGH); // trigger on pin-2 = PD2 = interrupt-0
  pinMode(5, INPUT); digitalWrite(5, HIGH); // pulses on pin-5 = PD5 = T1

  TCCR0A=0; // setup timer-0
  TCCR2A=0; // setup timer-2
  TCCR1A=0; // setup timer-1

void loop() {
  Serial << "Counting:" << endl;
  while (1) {}

void counting_start() {
  Serial << "Ready ... ";
  TCCR1B=7; // start
  attachInterrupt(0, counting_stop, FALLING); // ready to stop 

void counting_stop() {
  unsigned long counts;

  TCCR1B=0; // stop
  counts = TCNT1;
  attachInterrupt(0, counting_start, RISING); // ready to start
  Serial << counts << " pulses" << endl;

328  Using Arduino / Microcontrollers / Re: Two easy ISP Questions on: May 08, 2011, 06:08:06 pm

Shouldn't this be 57600?
329  Using Arduino / Microcontrollers / Re: Install Bootloader to use 8Mhz internal resonator - and upload program after? on: May 04, 2011, 12:09:23 pm
Isn't the bootloader you're using compiled to run at 16MHz?  I only have experience with Optiboot, but it looks like there's an 8MHz version of ATmegaBOOT supplied with IDE v0022.  Try changing these two lines in boards.txt:

330  Using Arduino / Microcontrollers / Re: Arduino Pro Mini 328 - 3.3V/8MHz modded on: April 30, 2011, 09:28:42 am
Get Westfw's Optifix sketch from here:
Load the sketch file into an editor and scroll down to the hex data at the end.  This is the Optiboot binary.  To adapt the code to run properly on an 8MHz board, alter just the 3rd and 4th lines of the hex data as follows:
Pages: 1 ... 20 21 [22] 23 24 25