Show Posts
Pages: 1 ... 8 9 [10] 11 12 ... 25
136  Using Arduino / Microcontrollers / Re: Beginner AVRDude questions on: May 15, 2013, 10:23:59 pm
1.  Do you have an auto-reset circuit hooked up from the FTDI RTS/DTR to the reset pin?  Also for auto-reset to work with uploads you should be using -carduino instead of -cstk500v1 with avrdude.

2.  The avrdude v5.10 lacks the wiring protocol support Arduino Mega2560 boards.  The avrdude.conf file with v5.10 also lacks some newer AVR chip definitions and the wiring programmer definition.


Awesome! Yes I do have auto-reset circuit. Thank you, -carduino works much better!
137  Using Arduino / Microcontrollers / Re: How to enable BOD fuse? on: May 15, 2013, 10:20:09 pm
You have the wrong baud rate for Arduino as ISP, should be -b19200.


I'm not using Arduino actually...
Tried 19200 it's not working at all at that baud smiley-sad
avrdude: stk500_getsync(): not in sync: resp=0x00
138  Using Arduino / Microcontrollers / Re: How to enable BOD fuse? on: May 15, 2013, 03:59:36 pm
Oh cool! Can it be done via USB?  I don't have dedicated ISP, and use Arduino as ISP...
Just Look in the avr-dude manual
It refuses to change high fuse bit smiley-sad
Code:
F:\>F:\Programs\WinAVR\bin\avrdude -patmega644p -cstk500v1 -P\\.\COM3 -b57600 -U
 efuse:w:0xfd:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e960a
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing |                                                    | 0% 0.00s ***faile
d;
Writing | ################################################## | 100% 0.13s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xfd:
avrdude: load data efuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xfd != 0x00
avrdude: verification error; content mismatch

avrdude: safemode: efuse changed! Was fd, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xed

avrdude done.  Thank you.

139  Using Arduino / Microcontrollers / Beginner AVRDude questions on: May 15, 2013, 01:52:11 pm
I never used AVRDude directly until today.
My goal is to use minimalist setup (i.e. standard install of WinAVR) to upload hex file via FTDI to custom ATMega644P board via a batch file that I will provide to 3rd party.
I got avrdude command from Arduino IDE 1.01 and it seems to be working with some minor issues. So my questions are:

1. After successful upload, if I try uploading second time I get Sync Error. Reinserting FTDI cable seems to help as well as opening and closing virtual COM port in program like RealTerm. Why is this happening? Any way around it other than what described earlier? smiley
2. Is custom avrdude.conf file needed?  It seems to work without specifying it (WinAVR just uses default unmodified file)
3. Arduino seems to have slightly newer version of AVRDude (5.11), even tho I got latest WinAVRDude (5.10). Just curious why would it be and should care about it much?

Anything else I need to watch out for?  As I mentioned goal is to give person who might not have any experience with AVRs easy way to upload hex firmware into device (i.e. Xronos clock).
I was thinking of just making batch file that will access COM port number and zipping up together with WinAVR folder and .hex file.   Then something similar for OSX too...

BTW here's command that I'm using:
Code:
F:\Programs\WinAVR\bin\avrdude -v -v -v -v -patmega644p -cstk500v1 -P\\.\COM6 -b57600 -D -Uflash:w:D:\projects\DIY\XRONOS\firmware\xronos1_05.cpp.hex:i
140  Using Arduino / Microcontrollers / Re: How to enable BOD fuse? on: May 15, 2013, 11:37:16 am
4,3V BOD has troubles working against USB Pwr and is very sensible , let's say it's on the hi end, more a 4,9 than a 4,3, I had my share of trouble trying out The BOD options.
BTW if you use avr-dude it's easy to program just the fuses without changing the program flash
Oh cool! Can it be done via USB?  I don't have dedicated ISP, and use Arduino as ISP...

I recommend fixing the power connector instead...

I did all I could. Using highest quality silver plated DC sockets and quality DC adapter with good plug. Issue did occur with inferior parts... That should probably reduce chances of such issue almost to 0. But enabling BOD will add another layer of protection, so I think it should be good enough smiley
141  Using Arduino / Microcontrollers / Re: How to enable BOD fuse? on: May 12, 2013, 05:24:00 pm
I don't know about the calculator site, where is it???  That would sure be easier.

Anyway, to the best of my knowledge, yes you have to burn the boot-loader again to set the fuses.  avrdude.exe should be able to tell you the current value for the fuses for a chip that doesn't have that stuff locked out.  

I don't know why ArduinoISP can't burn them, does anybody else know???
Calculator is on this site
I just figured out that typing in values manually will show which values are set, so that part is clear smiley
So I do have to burn bootloader. That's ok, thank you! smiley
There are 3 BOD levels, which would be recommended to select? One that's set to 4.3V?
Edit: I tried 4.3V and it would reset all the time when powered by FTDI (strange, should be 5V). So I set it to 2.7V seems stable...
142  Using Arduino / Microcontrollers / How to enable BOD fuse? on: May 12, 2013, 05:13:49 pm
I'm using my custom Sanguino (ATMega644p) based board.
I've had some issues with loosing data stored in EEPROM due to bad power connector, however now I'm seeing much worse issues when program in Flash gets corrupted!  It happens very rarely (so far I've seen it twice in 3-4 months), every time when power is interrupted (i.e. DC plug wiggled). Program is either gone or corrupted, re-flashing it back solves the problem.
I've see other people reporting this issue, and many recommend enabling Brown Out Detection (BOD).
I'm looking for a guide how to enable it on ATMega644p w/ Sanguino bootloader/hardware definition.
Guessing I need to modify boards.txt file, specifically this line:
Code:
atmega644.bootloader.low_fuses=0xFF
atmega644.bootloader.high_fuses=0x9A
atmega644.bootloader.extended_fuses=0xFF
I know about fuse calculator site (not sure exactly which values I need to choose), so using it I can change above values, but do I need burn Bootloader again in order for them to be active in the chip?
From above values, any way to tell what it's set for right now?
Anything I need to do?
143  Using Arduino / Programming Questions / Re: Need help with complex #define statement on: May 11, 2013, 06:49:34 am
I would reccomend using fatlib16's class: http://arduino.cc/forum/index.php/topic,150325.msg1128634.html#msg1128634

This should combine the two though.
Code:
#define fWrite( _pin_, _state_ ) ( ( _pin_ < 16 ) ? fWriteA( _pin_, _state_ ) : fWriteB( _pin_, _state_ ) )

It is using the C/C++ pre-processor syntax. Search macros and defines.
Wow, thanks!  I haven't thought of that!  So that translates to if (_pin_ < 16) fWriteA; else fWriteB 
Neat!
I'll check out fatlib16's class too!
144  Using Arduino / Programming Questions / Need help with complex #define statement on: May 10, 2013, 09:49:19 pm
I need to modify definition of fWriteA to include all pins. How would I combine these 2 statements into one?
Code:
//Atmega644/1284 Version of fastWrite - for pins 0-15
#define fWriteA(_pin_, _state_) ( _pin_ < 8 ? (_state_ ? PORTB |= 1 << _pin_ : PORTB &= ~(1 << _pin_ )) : (_state_ ? PORTD |= 1 << (_pin_ -8) : PORTD &= ~(1 << (_pin_ -8) )))
//Atmega644/1284 Version of fastWrite - for pins 16-31 (Note: PORTA mapping reversed from others)
#define fWriteB(_pin_, _state_) ( _pin_ < 24 ? (_state_ ? PORTC |= 1 << (_pin_ -16) : PORTC &= ~(1 << (_pin_ -16))) : (_state_ ? PORTA |= 1 << (31- _pin_) : PORTA &= ~(1 << (31- _pin_) )))

Also would be great to know what syntax is this? smiley
145  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 07:14:11 pm
Thank you guys it was very educational!
I finally found a way around it. Library has Sleep() and Wakeup() functions, so I was able to disable RF12B with those when SD card was in use. It works now! smiley
146  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 10:17:44 am
Thanks a lot Paul, that's exactly what I was looking for! smiley
As to revealing what I'm trying to accomplish, well basically (it's kind of complex scenario):
I'm using SD card (to play audio via WaveHC library) and RF12B receiver and both are SPI devices.  They conflict with each other and I need to disable RF12B when SD card is in use. I can do that by pulling SS pin on receiver to HIGH.
However issue is that RF12B uses hardware interrupt and when it's triggered (which happens when chip thinks it received radio signal) library pulls SS pin low, thus killing SD card interface... This interrupt function is part of the RF12B library...
At least that's my understanding of how it works.
My idea is to add variable "cardinUse" and set to true every time I'm reading SD card and then set it to false after I'm done. I want to add "if" check inside RF12B function that get's triggered by interrupt to exit if (cardinUse).
Alternatively I tried using noInterrupts(); but it kills audio and freezes program(looks like waveHC library is also using interrupts).
So as I described in OP, I had issues passing this "cardinUse" to the library. Because  don't call this function directly (it's triggered by hardware interrupt) I can't pass it as function argument ,  so I needed to pass variable separately...
I can post whole code, but it's enormous, doubt anyone will have fun reading it...
147  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 09:29:07 am
It doesn't really matter what's inside .cpp or .h file, I'm just looking for theoretical example how to pass variable between sketch and library without passing it as function argument smiley
Here's an example of simple tutorial LED13 library:
LED13.h
Code:
#ifndef LED13_H
#define LED13_H

#include "Arduino.h"


class LED13 {
public:
LED13();
~LED13();
    void on();
void off();
void blink(int time);
};

#endif

LED13.cpp
Code:
#include "LED13.h" //include the declaration for this class

const byte LED_PIN = 13; //use the LED @ Arduino pin 13


//<<constructor>> setup the LED, make pin 13 an OUTPUT
LED13::LED13(){
    pinMode(LED_PIN, OUTPUT); //make that pin an OUTPUT
}

//<<destructor>>
LED13::~LED13(){/*nothing to destruct*/}

//turn the LED on
void LED13::on(){
digitalWrite(LED_PIN,HIGH); //set the pin HIGH and thus turn LED on
}

//turn the LED off
void LED13::off(){
digitalWrite(LED_PIN,LOW); //set the pin LOW and thus turn LED off
}

//blink the LED in a period equal to paramterer -time.
void LED13::blink(int time){
on(); //turn LED on
delay(time/2);  //wait half of the wanted period
off(); //turn LED off
delay(time/2);  //wait the last half of the wanted period
}

So in the above example, can someone show me how to declare a variable so I can change it's value in the main sketch and library will see that it changed?
148  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 08:46:41 am
Ok I'll try it another way smiley
Here's Sketch "A.ino"
Code:
#include <B.h>
void setup() {
  Serial.begin (115200);
}
void loop() {
  if (myVar) Serial.println ("True!")
}

How would I declare "myVar" in B.h/B.cpp so I can access it from "A.ino"?

I've tried declaring myVar in B.h,and in B.cpp (as bool myVar;)  but I still get error "myVar not declared" smiley-sad
149  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 07:42:38 am
The library can't see your sketch's globals.  That's why you get the error.

You can add a global to the library, which then your function can see.

Or you could add an additional argument to a library function and pass the boolean in that way.

-br

Thank you. Could you give me an example of how to define global var in library and then address it from the sketch?
I added in the .cpp file:
uint8_t myVar;

but when I try to assign value to myVar from sketch it tells me "myVar" was no declared in this scope.  I do have #include in the beginning...
150  Using Arduino / Programming Questions / How to pass variable to library? on: May 08, 2013, 06:46:45 am
I'm trying to modify existing library (RF12B) and send to it a variable (boolean) from my sketch.  As a simple example, let's say I have
Code:
boolean myVar=true;
In the library .cpp file I add:
Code:
if (myVar) Serial.prinln "True";

But I get error:
RFM12B.cpp:22: error: 'myVar' was not declared in this scope

So how can I pass it to the library's function?
Pages: 1 ... 8 9 [10] 11 12 ... 25